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