Edge detection of a nail
4 views (last 30 days)
Show older comments
Muzammil Mumtaz
on 10 Oct 2014
Commented: Image Analyst
on 12 Oct 2014
I am working on a assignment in which i have to detect the edges of nail. i tried to do this using bwboundaries command i did my work to some extent but the problem is that it detected the boundary of the large circle as well. however i just want to detect the nail edges. is there anyway by which i can do this ?
0 Comments
Accepted Answer
Mohammad Abouali
on 10 Oct 2014
Edited: Mohammad Abouali
on 10 Oct 2014
reverse your mask (so the big black circle becomes white) then calculate the convex hull of that using (bwconvhull). This gives you the entire circle.
Then mask your original mask with the convex hull of your circle, this would set the outer perimeter to black.
Then use your method to get the boundary again.
I downloaded the image you posted and something like this will happen
I=imread('~/Desktop/lateralview.jpg');
I=double(rgb2gray(I))/255; % The image that I downloaded was rgb image. You might be able to skip this step.
Mask=logical(round(I));
bigCircleMask=bwconvhull(~Mask);
newMask=bwmorph(and(Mask, bigCircleMask),'majority');
This is the mask of big circle.
This is the new mask of the nail.
Now use your own algorithm to detect the edges of the nail.
If you want you can go one step further and fit a circle using imfindcircle of matlab to get a better circular mask of the bigCircle.
2 Comments
Image Analyst
on 12 Oct 2014
The convex hull is like you put a rubber band around your region.
bwboundaries gives you a cell array, where each cell is an outline. They have to be cells because each outline has a different length. See the FAQ: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F Saying boundary = B{k}; extracts that one particular boundary so that you can pass it into plot and display it as an outline over the image.
More Answers (1)
Image Analyst
on 10 Oct 2014
Simply mask the image by the know location of the circle, which I assume will be in the same location for every image. See my attached masking demo.
Then use bwareaopen, or my attached ExtractNLargestBlobs function to get just the big nail and not all those other blobs in the array.
0 Comments
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!