Re: find the maximum diameter of an object in an image [message #45866 is a reply to message #45857] |
Mon, 10 October 2005 13:03  |
Andrew Cool
Messages: 219 Registered: January 1996
|
Senior Member |
|
|
Jeff N. wrote:
> Hi folks,
>
> I have some CT data (of meteorites, not people) that I'm extracting
> slices of. The actual images I'm taking slices of are images where
> grains in the image have been set to 1, and everything else set to
> 0....so these are binary images. What I want to do is take a slice out
> of the CT volume, find the grains in the slice (which I'm doing with
> David Fanning's FIND_BOUNDARY() function), and then find the longest
> straight line that you can draw through the object (that goes from one
> boundary, through the center point, and then to the opposite boundary),
> which is its maximum diameter. FIND_BOUNDARY() gives me both the
> outline of the object and the center point, so I have that to work
> with. It also gives me perimeter and area, so I'm wondering if there
> isn't some kind of geometry trick that I haven't thought of that will
> get me what I need. If I do a principal components analysis on the
> boundary coordinates, wouldn't that be the maximum diameter?
>
> If anyone can point me in the right direction, or has some code they'd
> like to share, I'll be very grateful.
>
> Thanks,
> Jeff
Hi Jeff,
It's 0500 here, I've been up since 0330 with a bad sinus headache, and
I'm no math-head, but I'll have a go anyway...
I assume that you have the coordinates for every point on the
perimeter?
for every point do
calculate dist to centre
calculate angle to centre (0..359 deg say)
store dist in an array data[angle]
end
The diameter at say 45deg is then data[44] + data[44+180]
(avoid wrapping beyond 359 of course)
I guess you only need to check from 0..179 anyway, half way around
the perimeter?
Should be easy to pull out the maximum in a one liner from there.
Not flash, not hires, but should work?
Cheers,
Andrew (who's on his third coffee...)
|
|
|