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 #89815 is a reply to message #89809] Thu, 04 December 2014 07:24 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 3:32:26 PM UTC+1, Helder wrote:
> On Thursday, December 4, 2014 2:51:28 PM UTC+1, alx wrote:
>> 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.
>
> Hi Alx,
> I wanted to avoid doing myself the calculation, but even trying I found that it is not that possible. It seems like the ellipse() function simply generates a polygon() function. Once created, I could not retrieve the center or radius (major or minor) and cannot therefore compute using the ellipse equation. What I can do is use the undocumented getData method as I would for a polygon and then proceed as if it were a polygon.
>
> Still, a mask method would be a nice add to the FG.
>
> Cheers,
> Helder

Hi Helder,
If you draw the ellipse by calling the ELLIPSE function, you should know everything. If you draw it by hand, you can get the rectangle containing the ellipse by doing (after selecting it):
pos = GetWindows(/CURRENT).GetSelect().Position
then, center and axis lengthes.
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 13:35:44 PDT 2025

Total time taken to generate the page: 0.00435 seconds