Monday, 14 July 2014

how to count number of cells in image

a=imread('normal.jpg');
[m n p]=size(a);
 r=a(:,:,1);
 g=a(:,:,2);
 b=a(:,:,3);
for i=1:m
    for j=1:n
        for k=1:p
        if (r(i,j)>200)||(g(i,j)>160)||(b(i,j)>200)
      d(i,j)=0;
  else
      d(i,j)=a(i,j);
        end
    end
    end
end
imshow(d);
b=imcomplement(d);
figure,imshow(b);
[l num]=bwlabel(b,4);
figure,disp(l);
for i=1:num
    imshow(l==i);
   % pause(1);
 end



No comments:

Post a Comment