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

Home » Public Forums » archive » FG question: retrieve points within polygon
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: FG question: retrieve points within polygon [message #89805 is a reply to message #89797] Thu, 04 December 2014 05:51 Go to previous messageGo to previous message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
On Thursday, December 4, 2014 10:50:42 AM UTC+1, Helder wrote:
> Hi,
> I'm looking for an easier way to get the indices inside a polygon or ellipse created in function graphics.
> So here is a basic example that states what I want to do:
>
> ;first generate the graphics
> img = dist(600)
> w = window(dimensions=[500,500])
> im = image(img, current=w)
> pl = polygon([0.25,0.75,0.75,0.25],[0.25,0.25,0.75,0.75],/norm,ta rget=im)
> ;make some changes to the polygon
> pl.rotate, 12
>
> ;now extract the mean value of the points of the image that are inside the polygon
>
> pl->getData, xx, yy
> o = obj_new('idlanroi', xx*600d, yy*600d, /double, type=2)
> mask = o->ComputeMask(dimensions=[600,600])
> obj_destroy, o
> pts = where(mask, cnt)
> meanVal = mean(img[pts])
> print, 'the mean value inside the polygon is ', meanVal
>
>
>
> So this method works fine. It's maybe not the most obvious, but works. Now the question is... How do I get the same result for an ellipse?
> Of course I could calculate the perimeter points of the ellipse and use the same method as above, but that would not really be... well ... cool.
>
> Any better way to do this? I couldn't find any FG method to get such info.
>
> Thanks,
> Helder

If you could plot an ellipse with FG, you know its equation from the parameters (center, axes, orientation) you have given in the call. Let it be F(x,y)=0.
Then the indices of the (x,y) points inside the ellipse are those for which F(x,y) is strictly negative.
alx.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Dot miscentered in \sun symbol of cgsymbol?
Next Topic: Re: FG question: retrieve points within polygon

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

Current Time: Wed Oct 08 17:30:22 PDT 2025

Total time taken to generate the page: 0.01140 seconds