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

Home » Public Forums » archive » pollyfillv, area of a blob, etc...
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
pollyfillv, area of a blob, etc... [message #59581] Wed, 02 April 2008 23:16 Go to next message
JP is currently offline  JP
Messages: 55
Registered: April 2008
Member
G'day everyone,

I need to create a mask of pixels contained within a polygon. I tried
with POLYFILLV, but the problem I have is that my polygons are small
compared to the pixel size and in some cases there are no pixel
centers within my polygon and POLYFILLV returns -1.

I found the discussions about this, including "POLYFILLV weirdness",
"Area of a Blob", etc. For my particular application it doesn't really
matter the criteria I use for selecting the pixels, but at least I
need to get the array indices for the pixels that "touch" each
polygon.

By the way, ENVI's vector to ROI procedure is probably using
POLYFILLV as well and I don't get any ROI out of those small
polygons.

Any help will be very much appreciated.

JP
Re: pollyfillv, area of a blob, etc... [message #59646 is a reply to message #59581] Fri, 04 April 2008 07:18 Go to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
JP wrote:
> G'day everyone,
>
> I need to create a mask of pixels contained within a polygon. I tried
> with POLYFILLV, but the problem I have is that my polygons are small
> compared to the pixel size and in some cases there are no pixel
> centers within my polygon and POLYFILLV returns -1.
>
> I found the discussions about this, including "POLYFILLV weirdness",
> "Area of a Blob", etc. For my particular application it doesn't really
> matter the criteria I use for selecting the pixels, but at least I
> need to get the array indices for the pixels that "touch" each
> polygon.

Then you just need to add to the mask all pixels that contain at least
one vertex and you will have solved your problem with small polygons.

Paolo

>
> By the way, ENVI's vector to ROI procedure is probably using
> POLYFILLV as well and I don't get any ROI out of those small
> polygons.
>
> Any help will be very much appreciated.
>
> JP
Re: pollyfillv, area of a blob, etc... [message #59649 is a reply to message #59581] Fri, 04 April 2008 05:31 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
James Kuyper writes:

> Taking the mean of the
> vertices is at best an approximation.

But a pretty darn good one, under the circumstances. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: pollyfillv, area of a blob, etc... [message #59657 is a reply to message #59581] Fri, 04 April 2008 04:03 Go to previous message
jameskuyper is currently offline  jameskuyper
Messages: 79
Registered: October 2007
Member
JP wrote:
> On Apr 4, 1:16 am, David Fanning <n...@dfanning.com> wrote:
>> I suppose the centroid of the polygon is the average
>> value of it vertices, or maybe the mean if you didn't
>> want to overbias outliers.
>
> I guess you meant "the average value of it vertices, or maybe the
> MEDIAN" ??
>
> In any case, thank you. I didn't realize that the centroid is just the
> mean of the vertices in the two dimensions.

It isn't. David's routine calculates the centroid of the vertices
themselves; that's not the same as the centroid of the polygon that they
define.

Consider the polygon [[0,0],[1,0],[1,1],[0,1],[0,0.5]]. It's centroid is
clearly [0.5,0.5], the same as the one for [[0,0],[1,0],[1,1],[0,1]],
but the vertices have a different average. Taking the mean of the
vertices is at best an approximation.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Curl, Gradient and Divergence
Next Topic: Does the ENVI_SVM_DOIT function have memory leak problem?

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

Current Time: Wed Oct 08 17:28:26 PDT 2025

Total time taken to generate the page: 0.00571 seconds