matlab - extracting contents and calculating area within an image -


objective :

i need extract , highlight specific color given image[say x] , need calculate area of x.

i need in :

detecting individual labels in image[below] in form of circle.

what have done :

below code , have attached rgb variable's image[below]. have extracted "beige color" given image(that x) , labeled it.

to detect individual component, tried classical "coins example [identifying different coin values image using matlab", first detect element. here regions not uniform, so, bit confused.

code :

clear all; clc; close all; = imread('19.jpg'); %figure;imshow(i);  b = white_beige(i); // function used threshold rgb image                         lab colorspace. here, extract beige                         color present in image , provide final                         black , white image presence of beige                         color black , rest white.   %figure; imshow(b); bw2 = imfill(~b,'holes'); figure; imshow(bw2);  border = imclearborder(bw2); [obl,nbobobjets] = bwlabel(border,8); rgb = label2rgb(obl,'jet',[0 0 0]);  figure, imshow(rgb); 

enter image description here

any appreciated

maybe help:

note in code "area" occupied color represented real number on interval (0, 1), 0 means no pixel in image color, , 1 means of pixels in image color.

[a, map] = imread('l8izu_2.png');  image(a); % display image  if ~isempty(map)     = ind2rgb(x, map); % convert image rgb end  color_counts = zeros(256, 256, 256); % color_counts(x, y, z) records number of pixels in image % have rgb color [x-1, y-1, z-1];  % example color_counts(1, 1, 1) records number of pixels in % image have color [0, 0, 0];  % example, color_counts(65, 43, 11) records number of % pixels in image of color [64, 42, 10];  time_of_last_progress_report = clock;  % traverse image pixel pixel m = 1:size(a, 1)     n = 1:size(a, 2)          current_time = clock;         if etime(current_time, time_of_last_progress_report) > 2             percent_progress = 100*(((m - 1)*size(a, 2) + n)/(size(a, 1)*size(a, 2)));             disp(strcat(num2str(percent_progress),'% of image has been scanned'));             time_of_last_progress_report = clock;         end         current_color = a(m, n, :);         current_color = squeeze(current_color);         % squeeze removes singleton dimensions         % in other words, squeeze converts current_color 1x1x3 array         % 3x1 array          index = current_color + uint8(ones(size(current_color)));          % let index = [1, 3, 4];         % want increment color_counts(1, 3, 4);         % however, color_counts([1, 3, 4]), or color_counts(index),         % not return reference 1 single element @ location         % instead, color_counts([1, 3, 4]) returns 1x3 vector containing         % 1st, 3rd, , 4th elements of color_counts array          % convert index cell array , convert cell         % array comma separated list.         index2 = num2cell(index);         old_count = color_counts(index2{:});         color_counts(index2{:}) = 1 + old_count;     end end  disp(' ');% line break disp('now sorting colors how apeared....');  color_counts_linear = reshape(color_counts, 1, numel(color_counts)); [color_counts_sorted, indicies] = sort(color_counts_linear, 'descend'); [r,g,b] = ind2sub(size(color_counts),indicies);  r = r - ones(size(r)); g = g - ones(size(g)); b = b - ones(size(b)); areas = (1/(size(a, 1)*size(a, 2))) * color_counts_sorted;  % display top 5 common colors disp(' '); % line break disp('top 5 common colors:'); k = 1:min(5, numel(areas))     disp(strcat('[', num2str(r(k)), ',', num2str(b(k)), ',', num2str(g(k)),'] : ', num2str(100*areas(k)), '%')); end 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -