comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: FG question: retrieve points within polygon
items: Re: FG question: retrieve points within polygon

FG question: retrieve points within polygon
type: item
description: 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
creator: Helder Marchetto
date: 2014-12-04T09:50:38-00:00

Re: FG question: retrieve points within polygon
type: item
description: 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.
creator: lecacheux.alain
date: 2014-12-04T13:51:27-00:00

Re: FG question: retrieve points within polygon
type: item
description: 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…
creator: Helder Marchetto
date: 2014-12-04T14:32:24-00:00

Re: FG question: retrieve points within polygon
type: item
description: 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 e…
creator: lecacheux.alain
date: 2014-12-04T15:24:08-00:00

Re: FG question: retrieve points within polygon
type: item
description: On Thursday, December 4, 2014 4:24:11 PM UTC+1, alx wrote: > 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 coul…
creator: Helder Marchetto
date: 2014-12-04T15:41:24-00:00

Re: FG question: retrieve points within polygon
type: item
description: On Thursday, December 4, 2014 8:41:26 AM UTC-7, Helder wrote: > On Thursday, December 4, 2014 4:24:11 PM UTC+1, alx wrote: >> 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 tryin…
creator: Jim Pendleton
date: 2014-12-04T23:58:45-00:00

Re: FG question: retrieve points within polygon
type: item
description: On Friday, December 5, 2014 12:58:48 AM UTC+1, Jim P wrote: > On Thursday, December 4, 2014 8:41:26 AM UTC-7, Helder wrote: >> On Thursday, December 4, 2014 4:24:11 PM UTC+1, alx wrote: >>> 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 th…
creator: Helder Marchetto
date: 2014-12-05T09:16:12-00:00

Re: FG question: retrieve points within polygon
type: item
description: On Friday, December 5, 2014 2:16:16 AM UTC-7, Helder wrote: > On Friday, December 5, 2014 12:58:48 AM UTC+1, Jim P wrote: >> On Thursday, December 4, 2014 8:41:26 AM UTC-7, Helder wrote: >>> On Thursday, December 4, 2014 4:24:11 PM UTC+1, alx wrote: >>>> 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, a…
creator: Jim Pendleton
date: 2014-12-05T16:23:27-00:00