comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Filling a contour
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Filling a contour [message #60721 is a reply to message #60716] Sat, 07 June 2008 06:19 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
> I have created a single contour and converted it into a 'contour
> image'. That is to say that I have created an N x M image array and
> populated it with 0's and placed a 1 where a contour point resides. I
> would like to be able to fill the interior of the contour with 1's.
> Any ideas? Thanks

If the contour is closed in the image, then an interior point is
defined as having an odd number of contour crossings to the edge in
each direction. So I would create a new NxM array of "number of
contour crossings between x=0 and this point" and the same for y
(which, since everything is either 0 or 1, is simply the cumulative
sum). Then test for positions where both of these are odd and set
those to 1.

xcrossings = total(contour_image, 1, /cumulative)
ycrossings = total(contour_image, 2, /cumulative)
interior = where(xcrossings mod 2 and ycrossings mod 2, ninterior)
if ninterior gt 0 then contour_image[interior]=1

-Jeremy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: efficient comparing 1D and 3D arrays
Next Topic: Re: Best inverse of IDLanROI::ComputeMask

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 04:06:55 PDT 2025

Total time taken to generate the page: 1.59816 seconds