cell edge detection issue

3 views (last 30 days)
yingjie
yingjie on 22 Feb 2015
Commented: yingjie on 23 Feb 2015
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');

Answers (1)

Image Analyst
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
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.
yingjie
yingjie on 23 Feb 2015
Thanks for your answer. I think my problem is about cell edge detection which I have to use the edge detection function to get the cell edge of a cell in my plot. Then I have to extract the data from it. At first, in order to get the answer, I changed my original data into grayscale image data which is from 0 to 255. Then, I used sobel edge detection function to try to get the edge of the cell. But the problem is I cant get the exact edge region which I wanted to get as the edge detection function cant give me all the information about the edge region. I am not sure is this the edge detection function's problem or the grayscale data problem? I have generated the plots which I processed my edge data below.
<<
>>

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!