How to find out the distance between the inner and outer edge of the image using the Matlab command [x,y]=ginput(1)?
Show older comments
Where ever you click on the following link image, matlab code must find out the two edges and find out the distance between the those two points using [x,y]=ginput(1). http://imageshack.us/photo/my-images/600/imfill.jpg
Accepted Answer
More Answers (2)
Sean de Wolski
on 2 Jan 2013
0 votes
11 Comments
Image Analyst
on 2 Jan 2013
Yes, so would I. improfile() is also somewhat similar. Amongst numerous posts on this he seems to be bouncing back and forth between using automatic (i.e. regionprops) methods to find circle diameters and using manual methods by having the user manually specify points. I'm still puzzled why he can't just pick a method and go with it, and why there are lots of posts on this same ring/target/circle diameter issue.
Sean de Wolski
on 2 Jan 2013
Edited: Sean de Wolski
on 2 Jan 2013
improfile()!; I learn something new every day
Naresh Naik
on 3 Jan 2013
Walter Roberson
on 3 Jan 2013
If you threshold that image, leaving white as logical true (or 1), then regionprops() is going to return statistics for two objects, one for the solid white inner core of the circle, and the other for the remaining white background. The centroid property of the object with the eccentricity closest to 0 will be the centroid of the solid white inner core of the circle, no matter where it is in the image.
And if you invert the image either at the time of thresholding or immediately afterwards, so that the dark area becomes logical 1, then regionprops would, for the single-circle image, find only one object, and the centroid of that one object would be the centroid of the black ring. The regionprops MajorAxisLength would then be the outer diameter of the black ring. The calculation from more regionprops properties,
sqrt( 4 * (FilledArea - Area)/pi )
will then be the inner diameter of the black ring.
Naresh Naik
on 4 Jan 2013
Edited: Naresh Naik
on 4 Jan 2013
Teja Muppirala
on 4 Jan 2013
The outer diameter is given by
sqrt( 4 * (FilledArea)/pi )
which is
sqrt( 4 * (48540)/pi )
ans =
248.6022
This is in agreement with what you found manually.
Walter Roberson
on 4 Jan 2013
Odd. Why would MajorAxisLength be substantially different than the outer diameter in the case of a circle? Unless there are some stray pixels being picked up??
Naresh Naik
on 4 Jan 2013
Edited: Naresh Naik
on 4 Jan 2013
Walter Roberson
on 4 Jan 2013
When you showed "Area: 19363" and so on, how did you generate that information? Show the code from the regionprops() call on to the place you display that information.
Naresh Naik
on 4 Jan 2013
Edited: Walter Roberson
on 4 Jan 2013
Walter Roberson
on 4 Jan 2013
info = regionprops(L,'Area','FilledArea');
OD = sqrt(4*(info.FilledArea)/pi)
Walter Roberson
on 3 Jan 2013
0 votes
threshold. Logically negate so the circle becomes the 1's. bwboundaries that. The result for that image would be a 2 x 1 cell array, each entry of which is an array of row and column coordinates that together form one of the boundaries. Find the minimum of the euclidean distances between all points in the first cell and all points in the second cell, and you will have found the minimum distances between the inner and outer boundaries.
You can toss in a ginput(1) if you really want; you would just ignore the value it returns.
Categories
Find more on Axis Labels 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!