cell edge detection issue
3 views (last 30 days)
Show older comments
I am trying to detect the cell edge of an image using matlab 'sobel' edge detection function. In the image below, within the red circle I am trying to detect the blue region using this function. I understand this will be an irregular shape and I am wondering how accurately matlab can detect this shape. Before, I tried to detect the edge by changing the original data to grayscale data. However, the matlab edge detection function didn't give me accurate results. Could anyone give me some advice please. I have attached the code below. ( C60 represent my data input which is my grayscale image data).
B=zeros(166);
% C=double(C60);
C=C60;
for i=1:size(C,1)-2
for j=1:size(C,2)-2
%Sobel mask for x-direction:
Gx(i)=((2*C(i+2,j+1)+C(i+2,j)+C(i+2,j+2))-(2*C(i,j+1)+C(i,j)+C(i,j+2)));
%Sobel mask for y-direction:
Gy(j)=((2*C(i+1,j+2)+C(i,j+2)+C(i+2,j+2))-(2*C(i+1,j)+C(i,j)+C(i+2,j)));
%The gradient of the image
B(i,j)=abs(Gx(i))+abs(Gy(j));
C60(i,j)=sqrt(Gx(i).^2+Gy(j).^2);
end
end
figure,imshow(C60); title('Sobel gradient');
C601=max(C60,50);
C601(C601==round(50))=0;
C601=uint8(C601);
b=~C601;
figure,imshow(~C601);title('Edge detected Image');
0 Comments
Answers (1)
Image Analyst
on 22 Feb 2015
Of course not. Of course changing the image to gray level won't work well. You're throwing away the information you need to find the blue stuff. I have no idea why you think you'd need to use edge detection. Why does everyone think edge detection is the cure all for every situation? From what I've seen in this forum, it rarely is. You need to use color segmentation. I have several demos in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 It will be easy for you to take one and make very minor modifications to find the sky blue color that you want.
3 Comments
Image Analyst
on 22 Feb 2015
I don't know what " where one cell means another" means. Means another cell????
My demos let you find certain colors, such as sky blue. Generally they produce a binary image that is a "map" of where that color is in the image. To get the outline of the "map" use bwboundaries() - that will give you a list of (x,y) coordinates that are the outer boundary of the color regions.
Post your "C60" image without the red oval annotation if you want help.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!