pollyfillv, area of a blob, etc... [message #59581] |
Wed, 02 April 2008 23:16  |
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  |
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 #59657 is a reply to message #59581] |
Fri, 04 April 2008 04:03  |
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.
|
|
|