extract points of acircle [message #93542] |
Tue, 16 August 2016 08:21  |
Ali Gamal
Messages: 98 Registered: June 2013
|
Member |
|
|
Hi,
I want to plot four circles on picture then extract mean x,y for every circle
I use this program.
;******************************************
FUNCTION CIRCLE, xcenter, ycenter, radius
points = (2 * !PI / 99.0) * FINDGEN(100)
x = xcenter + radius * COS(points )
y = ycenter + radius * SIN(points )
RETURN, TRANSPOSE([[x],[y]])
END
restore,file='sm.isv' ;/v
sm1=sm[*,*,5]
window,0,xs=999,ys=512
tvscl,sm1
n=5
for i=0,n-1 do begin
radius=10*i
pp=circle(200,352,radius)
cgPlotS, pp,color='red',thick=2.0, /Device
;*************************************
at this point no problem, I want to print mean(x,y) for every circle
how can I do it ?
help, please
|
|
|
Re: extract points of acircle [message #93548 is a reply to message #93542] |
Wed, 17 August 2016 09:06   |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Tuesday, August 16, 2016 at 11:21:20 AM UTC-4, AGW wrote:
> Hi,
> I want to plot four circles on picture then extract mean x,y for every circle
> I use this program.
>
> ;******************************************
> FUNCTION CIRCLE, xcenter, ycenter, radius
> points = (2 * !PI / 99.0) * FINDGEN(100)
> x = xcenter + radius * COS(points )
> y = ycenter + radius * SIN(points )
> RETURN, TRANSPOSE([[x],[y]])
> END
>
> restore,file='sm.isv' ;/v
> sm1=sm[*,*,5]
> window,0,xs=999,ys=512
> tvscl,sm1
>
> n=5
> for i=0,n-1 do begin
> radius=10*i
> pp=circle(200,352,radius)
> cgPlotS, pp,color='red',thick=2.0, /Device
>
> ;*************************************
>
> at this point no problem, I want to print mean(x,y) for every circle
>
> how can I do it ?
Not sure what you are after. The mean value of the sampled coordinates of a circle is just the centroid. In your example, AVERAGE(pp[0,*]) is simply 200 and AVERAGE(pp[1,*]) is 352. Did you want to extract some information about the picture inside the circle?
|
|
|
Re: extract points of acircle [message #93559 is a reply to message #93542] |
Thu, 18 August 2016 07:30   |
Ali Gamal
Messages: 98 Registered: June 2013
|
Member |
|
|
On Tuesday, August 16, 2016 at 5:21:20 PM UTC+2, AGW wrote:
> Hi,
> I want to plot four circles on picture then extract mean x,y for every circle
> I use this program.
>
> ;******************************************
> FUNCTION CIRCLE, xcenter, ycenter, radius
> points = (2 * !PI / 99.0) * FINDGEN(100)
> x = xcenter + radius * COS(points )
> y = ycenter + radius * SIN(points )
> RETURN, TRANSPOSE([[x],[y]])
> END
>
> restore,file='sm.isv' ;/v
> sm1=sm[*,*,5]
> window,0,xs=999,ys=512
> tvscl,sm1
>
> n=5
> for i=0,n-1 do begin
> radius=10*i
> pp=circle(200,352,radius)
> cgPlotS, pp,color='red',thick=2.0, /Device
>
> ;*************************************
>
> at this point no problem, I want to print mean(x,y) for every circle
>
> how can I do it ?
>
> help, please
every point in circle have a coordinates x,y, I want to extract this coordinates for every circle
|
|
|
Re: extract points of acircle [message #93560 is a reply to message #93559] |
Thu, 18 August 2016 10:46   |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
Its not the most efficient way, but I would use the program dist_circle.pro
http://idlastro.gsfc.nasa.gov/ftp/pro/image/dist_circle.pro
dist_circle, dim, N, xcenter, ycenter
g = where( dim lt radius)
where N is the dimension of the square array. g will give the 1-d index of every pixel within the specified radius. You can use ARRAY_INDICES() to convert this 1d index into separate X and Y subscript values. --Wayne
On Thursday, August 18, 2016 at 10:30:18 AM UTC-4, AGW wrote:
> On Tuesday, August 16, 2016 at 5:21:20 PM UTC+2, AGW wrote:
>> Hi,
>> I want to plot four circles on picture then extract mean x,y for every circle
>> I use this program.
>>
>> ;******************************************
>> FUNCTION CIRCLE, xcenter, ycenter, radius
>> points = (2 * !PI / 99.0) * FINDGEN(100)
>> x = xcenter + radius * COS(points )
>> y = ycenter + radius * SIN(points )
>> RETURN, TRANSPOSE([[x],[y]])
>> END
>>
>> restore,file='sm.isv' ;/v
>> sm1=sm[*,*,5]
>> window,0,xs=999,ys=512
>> tvscl,sm1
>>
>> n=5
>> for i=0,n-1 do begin
>> radius=10*i
>> pp=circle(200,352,radius)
>> cgPlotS, pp,color='red',thick=2.0, /Device
>>
>> ;*************************************
>>
>> at this point no problem, I want to print mean(x,y) for every circle
>>
>> how can I do it ?
>>
>> help, please
>
> every point in circle have a coordinates x,y, I want to extract this coordinates for every circle
|
|
|
Re: extract points of acircle [message #93561 is a reply to message #93542] |
Thu, 18 August 2016 12:33  |
Ali Gamal
Messages: 98 Registered: June 2013
|
Member |
|
|
On Tuesday, August 16, 2016 at 5:21:20 PM UTC+2, AGW wrote:
> Hi,
> I want to plot four circles on picture then extract mean x,y for every circle
> I use this program.
>
> ;******************************************
> FUNCTION CIRCLE, xcenter, ycenter, radius
> points = (2 * !PI / 99.0) * FINDGEN(100)
> x = xcenter + radius * COS(points )
> y = ycenter + radius * SIN(points )
> RETURN, TRANSPOSE([[x],[y]])
> END
>
> restore,file='sm.isv' ;/v
> sm1=sm[*,*,5]
> window,0,xs=999,ys=512
> tvscl,sm1
>
> n=5
> for i=0,n-1 do begin
> radius=10*i
> pp=circle(200,352,radius)
> cgPlotS, pp,color='red',thick=2.0, /Device
>
> ;*************************************
>
> at this point no problem, I want to print mean(x,y) for every circle
>
> how can I do it ?
>
> help, please
please, I want more explain
|
|
|