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

Home » Public Forums » archive » extract circle from data with idl
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
extract circle from data with idl [message #94780] Wed, 11 October 2017 05:23 Go to next message
termybel is currently offline  termybel
Messages: 5
Registered: October 2017
Junior Member
How can extract an circle or an ellipse from my data with IDL?
With a contour plot my data form a circle, I need to know the center of this circle. From the geometry I know that if I know 3 points I can extract a circle, are there routine or function something else in IDL that using, reading my data, can give me the center?
Re: extract circle from data with idl [message #94781 is a reply to message #94780] Wed, 11 October 2017 05:41 Go to previous messageGo to next message
Markus Schmassmann is currently offline  Markus Schmassmann
Messages: 129
Registered: April 2016
Senior Member
On 10/11/2017 02:23 PM, termybel@gmail.com wrote:
> How can extract an circle or an ellipse from my data with IDL?
> With a contour plot my data form a circle, I need to know the center
> of this circle. From the geometry I know that if I know 3 points I
> can extract a circle, are there routine or function something else in
> IDL that using, reading my data, can give me the center?

;; without using the properties of the circle or ellipse:

; DATA being the data to be contoured
data=2-(([-1:1:.1]^2)#replicate(1.,21))-(replicate(1.,21)#([ -1:1:.1]^2))
; LEVEL the appropriate level to contour
level=1.
contour, data, path_info=li, path_xy=lines, /path_data_coord, $
levels=[level], /path_double
if n_elements(li) ne 1 then message, 'not exactly 1 contour'

cont_obj =obj_new('IDLanROI',lines)
void= cont_obj.ComputeGeometry(centroid=center)

print, center[0:1]

;; otherwise use math to calculate the center
Re: extract circle from data with idl [message #94782 is a reply to message #94780] Wed, 11 October 2017 05:47 Go to previous messageGo to next message
Helder is currently offline  Helder
Messages: 10
Registered: October 2017
Junior Member
On Wednesday, 11 October 2017 14:23:33 UTC+2, term...@gmail.com wrote:
> How can extract an circle or an ellipse from my data with IDL?
> With a contour plot my data form a circle, I need to know the center of this circle. From the geometry I know that if I know 3 points I can extract a circle, are there routine or function something else in IDL that using, reading my data, can give me the center?

Hi,
you might also want to have a look at this article:
http://www.idlcoyote.com/ip_tips/fit_ellipse.html
Cheers,
Helder
Re: extract circle from data with idl [message #94786 is a reply to message #94781] Thu, 12 October 2017 05:10 Go to previous messageGo to next message
termybel is currently offline  termybel
Messages: 5
Registered: October 2017
Junior Member
Thanks to answer but I have a probelm.

You puth this: if n_elements(li) ne 1 then message, 'not exactly 1 contour'

and my program say: not exactly 1 contour

How I can solve it?

If I ask in idl " help,/str,li" and the answer is:

Structure CONTOUR_DBL_PATH_STRUCTURE, 6 tags, length=24, data length=20:
TYPE BYTE 1
HIGH_LOW BYTE 1
LEVEL INT 0
N LONG 7
OFFSET LONG 0
VALUE DOUBLE 9.0000000

and for " help,/str,lines"
LINES DOUBLE = Array[2, 5447]

My contour isn't a perfect circle. Maybe is this the problem?

This is my program where the image is a flat field panel minus dark:

file_ff1='ff_100s_3.fits' ;immagine
immagine_ff1=readfits (file_ff1, header1) ; leggo l'immagine del flat field panel
file_dark='ff_100s_dark_3.fits' ;immagine
immagine_dark=readfits (file_dark, header1) ; leggo l'immagine della dark

n=100. ; secondi di esposizione dell'immagine
ffp=(immagine_ff1-immagine_dark)/n

; contour per selezionare soglie di equivalore

speriamo=fltarr(2048,2048) ; creo una matrice 2048x2048
dimensioni=size(speriamo,/dimensions)
cubo=where(ffp lt 9.5 or ffp gt 10)



wrong_matrix=array_indices(dimensioni, cubo,/dimensions)
indxw=reform(wrong_matrix(0,*))
indyw=reform(wrong_matrix(1,*))
;ffp(indxw,indyw)=0.
;c = CONTOUR(ffp, dimensions=[512,512], Title='prova cubo')

; DATA being the data to be contoured
level=9
contour, smooth(ffp(250:1700, 250:1700),3), path_info=li,closed=1 , path_xy=lines, /path_data_coord, levels=[level], /path_double
; lix=lines(0,*)
; liy=lines(1,*)
; liyd=deriv(lix,liy)
;ind=where(abs(liyd) le 0.0001)

if n_elements(li) ne 1 then message, 'not exactly 1 contour'


cont_obj =obj_new('IDLanROI',lines)
void= cont_obj.ComputeGeometry(centroid=center)
;fit_ellipse(
print, center[0:1]

end
Re: extract circle from data with idl [message #94787 is a reply to message #94786] Thu, 12 October 2017 07:27 Go to previous messageGo to next message
Markus Schmassmann is currently offline  Markus Schmassmann
Messages: 129
Registered: April 2016
Senior Member
On 10/12/2017 02:10 PM, termybel@gmail.com wrote:
> Thanks to answer but I have a probelm.
>
> You puth this: if n_elements(li) ne 1 then message, 'not exactly 1 contour'
>
> and my program say: not exactly 1 contour
>
> How I can solve it?
>
> If I ask in idl " help,/str,li" and the answer is:
>
> Structure CONTOUR_DBL_PATH_STRUCTURE, 6 tags, length=24, data length=20:
> TYPE BYTE 1
> HIGH_LOW BYTE 1
> LEVEL INT 0
> N LONG 7
> OFFSET LONG 0
> VALUE DOUBLE 9.0000000
>
> and for " help,/str,lines"
> LINES DOUBLE = Array[2, 5447]
>
> My contour isn't a perfect circle. Maybe is this the problem?
>
> This is my program where the image is a flat field panel minus dark:
>
> file_ff1='ff_100s_3.fits' ;immagine
> immagine_ff1=readfits (file_ff1, header1) ; leggo l'immagine del flat field panel
> file_dark='ff_100s_dark_3.fits' ;immagine
> immagine_dark=readfits (file_dark, header1) ; leggo l'immagine della dark
>
> n=100. ; secondi di esposizione dell'immagine
> ffp=(immagine_ff1-immagine_dark)/n
>
> ; contour per selezionare soglie di equivalore
>
> speriamo=fltarr(2048,2048) ; creo una matrice 2048x2048
> dimensioni=size(speriamo,/dimensions)
> cubo=where(ffp lt 9.5 or ffp gt 10)
>
>
>
> wrong_matrix=array_indices(dimensioni, cubo,/dimensions)
> indxw=reform(wrong_matrix(0,*))
> indyw=reform(wrong_matrix(1,*))
> ;ffp(indxw,indyw)=0.
> ;c = CONTOUR(ffp, dimensions=[512,512], Title='prova cubo')
>
> ; DATA being the data to be contoured
> level=9
> contour, smooth(ffp(250:1700, 250:1700),3), path_info=li,closed=1 , path_xy=lines, /path_data_coord, levels=[level], /path_double
> ; lix=lines(0,*)
> ; liy=lines(1,*)
> ; liyd=deriv(lix,liy)
> ;ind=where(abs(liyd) le 0.0001)
>
> if n_elements(li) ne 1 then message, 'not exactly 1 contour'
>
>
> cont_obj =obj_new('IDLanROI',lines)
> void= cont_obj.ComputeGeometry(centroid=center)
> ;fit_ellipse(
> print, center[0:1]
>
> end

contour, smooth(ffp(250:1700, 250:1700),3), path_info=li,closed=1 , $
path_xy=lines, /path_data_coord, levels=[level], /path_double
contour, smooth(ffp(250:1700, 250:1700),3), levels=[level]
; shows you there are more than 1 contour,
; you need to identify the correct one
; often the best is the longest
void=max(li.n,j)
line=[*,li[j].offset+lindgen(li[j].n)]
plot, line[0,*],line[1,*]
cont_obj =obj_new('IDLanROI',line)
Re: extract circle from data with idl [message #94790 is a reply to message #94787] Sun, 15 October 2017 08:43 Go to previous messageGo to next message
termybel is currently offline  termybel
Messages: 5
Registered: October 2017
Junior Member
Il giorno giovedì 12 ottobre 2017 16:27:18 UTC+2, Markus Schmassmann ha scritto:
> On 10/12/2017 02:10 PM, termybel@gmail.com wrote:
>> Thanks to answer but I have a probelm.
>>
>> You puth this: if n_elements(li) ne 1 then message, 'not exactly 1 contour'
>>
>> and my program say: not exactly 1 contour
>>
>> How I can solve it?
>>
>> If I ask in idl " help,/str,li" and the answer is:
>>
>> Structure CONTOUR_DBL_PATH_STRUCTURE, 6 tags, length=24, data length=20:
>> TYPE BYTE 1
>> HIGH_LOW BYTE 1
>> LEVEL INT 0
>> N LONG 7
>> OFFSET LONG 0
>> VALUE DOUBLE 9.0000000
>>
>> and for " help,/str,lines"
>> LINES DOUBLE = Array[2, 5447]
>>
>> My contour isn't a perfect circle. Maybe is this the problem?
>>
>> This is my program where the image is a flat field panel minus dark:
>>
>> file_ff1='ff_100s_3.fits' ;immagine
>> immagine_ff1=readfits (file_ff1, header1) ; leggo l'immagine del flat field panel
>> file_dark='ff_100s_dark_3.fits' ;immagine
>> immagine_dark=readfits (file_dark, header1) ; leggo l'immagine della dark
>>
>> n=100. ; secondi di esposizione dell'immagine
>> ffp=(immagine_ff1-immagine_dark)/n
>>
>> ; contour per selezionare soglie di equivalore
>>
>> speriamo=fltarr(2048,2048) ; creo una matrice 2048x2048
>> dimensioni=size(speriamo,/dimensions)
>> cubo=where(ffp lt 9.5 or ffp gt 10)
>>
>>
>>
>> wrong_matrix=array_indices(dimensioni, cubo,/dimensions)
>> indxw=reform(wrong_matrix(0,*))
>> indyw=reform(wrong_matrix(1,*))
>> ;ffp(indxw,indyw)=0.
>> ;c = CONTOUR(ffp, dimensions=[512,512], Title='prova cubo')
>>
>> ; DATA being the data to be contoured
>> level=9
>> contour, smooth(ffp(250:1700, 250:1700),3), path_info=li,closed=1 , path_xy=lines, /path_data_coord, levels=[level], /path_double
>> ; lix=lines(0,*)
>> ; liy=lines(1,*)
>> ; liyd=deriv(lix,liy)
>> ;ind=where(abs(liyd) le 0.0001)
>>
>> if n_elements(li) ne 1 then message, 'not exactly 1 contour'
>>
>>
>> cont_obj =obj_new('IDLanROI',lines)
>> void= cont_obj.ComputeGeometry(centroid=center)
>> ;fit_ellipse(
>> print, center[0:1]
>>
>> end
>
> contour, smooth(ffp(250:1700, 250:1700),3), path_info=li,closed=1 , $
> path_xy=lines, /path_data_coord, levels=[level], /path_double
> contour, smooth(ffp(250:1700, 250:1700),3), levels=[level]
> ; shows you there are more than 1 contour,
> ; you need to identify the correct one
> ; often the best is the longest
> void=max(li.n,j)
> line=[*,li[j].offset+lindgen(li[j].n)]
> plot, line[0,*],line[1,*]
> cont_obj =obj_new('IDLanROI',line)

I don't know why but IDL say this message:

line=[*,li[j].offset+lindgen(li[j].n)]
^
% Syntax error.
Re: extract circle from data with idl [message #94791 is a reply to message #94787] Sun, 15 October 2017 09:08 Go to previous messageGo to next message
termybel is currently offline  termybel
Messages: 5
Registered: October 2017
Junior Member
Il giorno giovedì 12 ottobre 2017 16:27:18 UTC+2, Markus Schmassmann ha scritto:
> On 10/12/2017 02:10 PM, termybel@gmail.com wrote:
>> Thanks to answer but I have a probelm.
>>
>> You puth this: if n_elements(li) ne 1 then message, 'not exactly 1 contour'
>>
>> and my program say: not exactly 1 contour
>>
>> How I can solve it?
>>
>> If I ask in idl " help,/str,li" and the answer is:
>>
>> Structure CONTOUR_DBL_PATH_STRUCTURE, 6 tags, length=24, data length=20:
>> TYPE BYTE 1
>> HIGH_LOW BYTE 1
>> LEVEL INT 0
>> N LONG 7
>> OFFSET LONG 0
>> VALUE DOUBLE 9.0000000
>>
>> and for " help,/str,lines"
>> LINES DOUBLE = Array[2, 5447]
>>
>> My contour isn't a perfect circle. Maybe is this the problem?
>>
>> This is my program where the image is a flat field panel minus dark:
>>
>> file_ff1='ff_100s_3.fits' ;immagine
>> immagine_ff1=readfits (file_ff1, header1) ; leggo l'immagine del flat field panel
>> file_dark='ff_100s_dark_3.fits' ;immagine
>> immagine_dark=readfits (file_dark, header1) ; leggo l'immagine della dark
>>
>> n=100. ; secondi di esposizione dell'immagine
>> ffp=(immagine_ff1-immagine_dark)/n
>>
>> ; contour per selezionare soglie di equivalore
>>
>> speriamo=fltarr(2048,2048) ; creo una matrice 2048x2048
>> dimensioni=size(speriamo,/dimensions)
>> cubo=where(ffp lt 9.5 or ffp gt 10)
>>
>>
>>
>> wrong_matrix=array_indices(dimensioni, cubo,/dimensions)
>> indxw=reform(wrong_matrix(0,*))
>> indyw=reform(wrong_matrix(1,*))
>> ;ffp(indxw,indyw)=0.
>> ;c = CONTOUR(ffp, dimensions=[512,512], Title='prova cubo')
>>
>> ; DATA being the data to be contoured
>> level=9
>> contour, smooth(ffp(250:1700, 250:1700),3), path_info=li,closed=1 , path_xy=lines, /path_data_coord, levels=[level], /path_double
>> ; lix=lines(0,*)
>> ; liy=lines(1,*)
>> ; liyd=deriv(lix,liy)
>> ;ind=where(abs(liyd) le 0.0001)
>>
>> if n_elements(li) ne 1 then message, 'not exactly 1 contour'
>>
>>
>> cont_obj =obj_new('IDLanROI',lines)
>> void= cont_obj.ComputeGeometry(centroid=center)
>> ;fit_ellipse(
>> print, center[0:1]
>>
>> end
>
> contour, smooth(ffp(250:1700, 250:1700),3), path_info=li,closed=1 , $
> path_xy=lines, /path_data_coord, levels=[level], /path_double
> contour, smooth(ffp(250:1700, 250:1700),3), levels=[level]
> ; shows you there are more than 1 contour,
> ; you need to identify the correct one
> ; often the best is the longest
> void=max(li.n,j)
> line=[*,li[j].offset+lindgen(li[j].n)]
> plot, line[0,*],line[1,*]
> cont_obj =obj_new('IDLanROI',line)

I don't know why but IDL says this message (it doesn't read the *):

line=[*,li[j].offset+lindgen(li[j].n)]
^
% Syntax error.
Re: extract circle from data with idl [message #94792 is a reply to message #94791] Mon, 16 October 2017 02:20 Go to previous messageGo to next message
Markus Schmassmann is currently offline  Markus Schmassmann
Messages: 129
Registered: April 2016
Senior Member
On 10/15/2017 06:08 PM, termybel@gmail.com wrote:
> Il giorno giovedì 12 ottobre 2017 16:27:18 UTC+2, Markus Schmassmann ha scritto:
>> On 10/12/2017 02:10 PM, termybel@gmail.com wrote:
>>> Thanks to answer but I have a probelm.
>>>
>>> You puth this: if n_elements(li) ne 1 then message, 'not exactly 1 contour'
>>>
>>> and my program say: not exactly 1 contour
>>>
>>> How I can solve it?
>>>
>>> If I ask in idl " help,/str,li" and the answer is:
>>>
>>> Structure CONTOUR_DBL_PATH_STRUCTURE, 6 tags, length=24, data length=20:
>>> TYPE BYTE 1
>>> HIGH_LOW BYTE 1
>>> LEVEL INT 0
>>> N LONG 7
>>> OFFSET LONG 0
>>> VALUE DOUBLE 9.0000000
>>>
>>> and for " help,/str,lines"
>>> LINES DOUBLE = Array[2, 5447]
>>>
>>> My contour isn't a perfect circle. Maybe is this the problem?
>>>
>>> This is my program where the image is a flat field panel minus dark:
>>>
>>> file_ff1='ff_100s_3.fits' ;immagine
>>> immagine_ff1=readfits (file_ff1, header1) ; leggo l'immagine del flat field panel
>>> file_dark='ff_100s_dark_3.fits' ;immagine
>>> immagine_dark=readfits (file_dark, header1) ; leggo l'immagine della dark
>>>
>>> n=100. ; secondi di esposizione dell'immagine
>>> ffp=(immagine_ff1-immagine_dark)/n
>>>
>>> ; contour per selezionare soglie di equivalore
>>>
>>> speriamo=fltarr(2048,2048) ; creo una matrice 2048x2048
>>> dimensioni=size(speriamo,/dimensions)
>>> cubo=where(ffp lt 9.5 or ffp gt 10)
>>>
>>>
>>>
>>> wrong_matrix=array_indices(dimensioni, cubo,/dimensions)
>>> indxw=reform(wrong_matrix(0,*))
>>> indyw=reform(wrong_matrix(1,*))
>>> ;ffp(indxw,indyw)=0.
>>> ;c = CONTOUR(ffp, dimensions=[512,512], Title='prova cubo')
>>>
>>> ; DATA being the data to be contoured
>>> level=9
>>> contour, smooth(ffp(250:1700, 250:1700),3), path_info=li,closed=1 , path_xy=lines, /path_data_coord, levels=[level], /path_double
>>> ; lix=lines(0,*)
>>> ; liy=lines(1,*)
>>> ; liyd=deriv(lix,liy)
>>> ;ind=where(abs(liyd) le 0.0001)
>>>
>>> if n_elements(li) ne 1 then message, 'not exactly 1 contour'
>>>
>>>
>>> cont_obj =obj_new('IDLanROI',lines)
>>> void= cont_obj.ComputeGeometry(centroid=center)
>>> ;fit_ellipse(
>>> print, center[0:1]
>>>
>>> end
>>
>> contour, smooth(ffp(250:1700, 250:1700),3), path_info=li,closed=1 , $
>> path_xy=lines, /path_data_coord, levels=[level], /path_double
>> contour, smooth(ffp(250:1700, 250:1700),3), levels=[level]
>> ; shows you there are more than 1 contour,
>> ; you need to identify the correct one
>> ; often the best is the longest
>> void=max(li.n,j)
>> line=[*,li[j].offset+lindgen(li[j].n)]
>> plot, line[0,*],line[1,*]
>> cont_obj =obj_new('IDLanROI',line)
>
> I don't know why but IDL says this message (it doesn't read the *):
>
> line=[*,li[j].offset+lindgen(li[j].n)]
> ^
> % Syntax error.
>
; sorry, it should be
line=lines[*,li[j].offset+lindgen(li[j].n)]
Re: extract circle from data with idl [message #94793 is a reply to message #94792] Mon, 16 October 2017 03:23 Go to previous message
termybel is currently offline  termybel
Messages: 5
Registered: October 2017
Junior Member
Il giorno lunedì 16 ottobre 2017 11:20:59 UTC+2, Markus Schmassmann ha scritto:
> On 10/15/2017 06:08 PM, termybel@gmail.com wrote:
>> Il giorno giovedì 12 ottobre 2017 16:27:18 UTC+2, Markus Schmassmann ha scritto:
>>> On 10/12/2017 02:10 PM, termybel@gmail.com wrote:
>>>> Thanks to answer but I have a probelm.
>>>>
>>>> You puth this: if n_elements(li) ne 1 then message, 'not exactly 1 contour'
>>>>
>>>> and my program say: not exactly 1 contour
>>>>
>>>> How I can solve it?
>>>>
>>>> If I ask in idl " help,/str,li" and the answer is:
>>>>
>>>> Structure CONTOUR_DBL_PATH_STRUCTURE, 6 tags, length=24, data length=20:
>>>> TYPE BYTE 1
>>>> HIGH_LOW BYTE 1
>>>> LEVEL INT 0
>>>> N LONG 7
>>>> OFFSET LONG 0
>>>> VALUE DOUBLE 9.0000000
>>>>
>>>> and for " help,/str,lines"
>>>> LINES DOUBLE = Array[2, 5447]
>>>>
>>>> My contour isn't a perfect circle. Maybe is this the problem?
>>>>
>>>> This is my program where the image is a flat field panel minus dark:
>>>>
>>>> file_ff1='ff_100s_3.fits' ;immagine
>>>> immagine_ff1=readfits (file_ff1, header1) ; leggo l'immagine del flat field panel
>>>> file_dark='ff_100s_dark_3.fits' ;immagine
>>>> immagine_dark=readfits (file_dark, header1) ; leggo l'immagine della dark
>>>>
>>>> n=100. ; secondi di esposizione dell'immagine
>>>> ffp=(immagine_ff1-immagine_dark)/n
>>>>
>>>> ; contour per selezionare soglie di equivalore
>>>>
>>>> speriamo=fltarr(2048,2048) ; creo una matrice 2048x2048
>>>> dimensioni=size(speriamo,/dimensions)
>>>> cubo=where(ffp lt 9.5 or ffp gt 10)
>>>>
>>>>
>>>>
>>>> wrong_matrix=array_indices(dimensioni, cubo,/dimensions)
>>>> indxw=reform(wrong_matrix(0,*))
>>>> indyw=reform(wrong_matrix(1,*))
>>>> ;ffp(indxw,indyw)=0.
>>>> ;c = CONTOUR(ffp, dimensions=[512,512], Title='prova cubo')
>>>>
>>>> ; DATA being the data to be contoured
>>>> level=9
>>>> contour, smooth(ffp(250:1700, 250:1700),3), path_info=li,closed=1 , path_xy=lines, /path_data_coord, levels=[level], /path_double
>>>> ; lix=lines(0,*)
>>>> ; liy=lines(1,*)
>>>> ; liyd=deriv(lix,liy)
>>>> ;ind=where(abs(liyd) le 0.0001)
>>>>
>>>> if n_elements(li) ne 1 then message, 'not exactly 1 contour'
>>>>
>>>>
>>>> cont_obj =obj_new('IDLanROI',lines)
>>>> void= cont_obj.ComputeGeometry(centroid=center)
>>>> ;fit_ellipse(
>>>> print, center[0:1]
>>>>
>>>> end
>>>
>>> contour, smooth(ffp(250:1700, 250:1700),3), path_info=li,closed=1 , $
>>> path_xy=lines, /path_data_coord, levels=[level], /path_double
>>> contour, smooth(ffp(250:1700, 250:1700),3), levels=[level]
>>> ; shows you there are more than 1 contour,
>>> ; you need to identify the correct one
>>> ; often the best is the longest
>>> void=max(li.n,j)
>>> line=[*,li[j].offset+lindgen(li[j].n)]
>>> plot, line[0,*],line[1,*]
>>> cont_obj =obj_new('IDLanROI',line)
>>
>> I don't know why but IDL says this message (it doesn't read the *):
>>
>> line=[*,li[j].offset+lindgen(li[j].n)]
>> ^
>> % Syntax error.
>>
> ; sorry, it should be
> line=lines[*,li[j].offset+lindgen(li[j].n)]

Thank you so much! :D :D :D
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Using color tables in function graphics
Next Topic: graphic functions - CopyWindow()

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

Current Time: Wed Oct 08 07:16:48 PDT 2025

Total time taken to generate the page: 0.00520 seconds