Finding outer and inner edge of an ear image

17 visualizzazioni (ultimi 30 giorni)
I am using MATLAB 2013a. I used lot of edge detector techniques to find out both the edges, but I am able to find only outer edge.If anyone can help me with the code to find both the edges that will be great help for my work. The final image after finding edges resembles the attached image. Reply as soon as possible. Thank you.
  1 Commento
Sukhada Vengurlekar
Sukhada Vengurlekar il 19 Mar 2016
Modificato: Sukhada Vengurlekar il 19 Mar 2016
Now I am able to detect outer as well as inner edge using attached code. Now what I am trying to do is I want to draw a line passing though 2 extreme endpoints(ymax,ymin) of outer edge(refer "rdgedetected.jpg"). Is there any direct function to do so or I have to do it by scanning each pixel and using Index value(=1) of it?? I don't have any idea about using for loop to scan pixel values in matlab. Thanks in adv
y=imread('C:\Users\Sukhada\Desktop\2.jpg');
imshow(y);
gy=rgb2gray(y);
figure,imshow(gy);
et=edge(gy,'canny',.305);
figure,imshow(et);

Accedi per commentare.

Risposta accettata

Image Analyst
Image Analyst il 19 Mar 2016
Regarding your new question about finding the "extreme endpoints", do you mean the two points that are farthest away from each other, or do you mean the actual endpoints of the line, which may not necessarily be the two points farthest from each other?
To find the two points farthest from each other, regardless if they're endpoints of a line/curve or somewhere in the middle of the curve, just so a nested for loop. Don't worry - it will be fast. See attached demo.
If you mean the endpoints of the curves only, then you need to get them using bwmorph(binaryImage, 'endpoints') and use the Pythagorean Theorem on all pairs of points.
  10 Commenti
Image Analyst
Image Analyst il 27 Mar 2016
I think the example I gave should be enough help. You should be able to modify it. All you need to do is to find the points - try linspace() - and use the same method I used for drawing a line through that point. It's just the point slope formula you learned in high school.
Sukhada Vengurlekar
Sukhada Vengurlekar il 5 Apr 2016
I could draw lines but not getting the meaning of following line which I adapted from your code.
line([1, columns], [y1, y2], 'color', 'w', 'LineWidth', 1);
Because I have to use it to find intersection points of perpendicular lines and edge of the ear. What exactly the bwboundaries() returns?? I searched a lot but ended with introduction of lot of errors while running the code. So can you suggest any helping function which will work fine with my requirement and can give me desired output? (code files are attached)

Accedi per commentare.

Più risposte (3)

Ahmet Cecen
Ahmet Cecen il 8 Mar 2016
A cheap trick would be to use bwconncomp on your edge image, and then use a for loop to only keeps the ones that contain a pixel with an element that has the maximum or minimum observed coordinate of edge pixels possible. That will give you the outermost shell in all cases except in the case where your outer edge happens to be slightly connected from a point to your inner edge.

Image Analyst
Image Analyst il 9 Mar 2016
You can fill it and call bwperim():
binaryImage = imfill(edgeImage, 'holes');
outerPerimeter = bwperim(binaryImage);

Sukhada Vengurlekar
Sukhada Vengurlekar il 9 Mar 2016
I tried following code.. but only able to get outer edge as shown in attached figure.
I = imread('C:\Users\Sukhada\Desktop\a1.jpg'); t1=graythresh(I); k1=im2bw(I,t1); k1=~k1; se = strel('disk',1); k0=imfill(~k1,'holes'); % new cc = bwconncomp(k0); % new k0(cc.PixelIdxList{1})=0; % new k1 = imfill(k1,'holes'); cellMask = k1 | k0; % new cellContours = bwperim(cellMask); % new cellContours2 = edge(cellMask,'canny',[],sqrt(2)); % new k1=~k1; bw = edge(k1,'canny',[],sqrt(2)); figure,imshow(bw); title('original') figure,imshow(cellContours); title('new, bwperim()') figure,imshow(cellContours2); title('new, edge()')
But I want both the outer and inner edges.. Can anyone correct the mistakes?? I want output as shown in "output" image.
  5 Commenti
daniel Rodrigues
daniel Rodrigues il 21 Lug 2017
I'm doing a job and I'm having the same problem, did you solve it?
Image Analyst
Image Analyst il 21 Lug 2017
Why are you working on this? Who wants to know about ears? Is it some kind of biometric application? What's the "use case"? Just curious.
What kind of image are you starting with? You forgot to post it.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by