find_circle.pro
来自「IDL语言编写的用于天文自适应光学仿真的软件CAOS V6.0的第一部分。」· PRO 代码 · 共 34 行
PRO
34 行
; $Id: find_circle.pro,v 1.2 2002/03/14 11:49:12 riccardi Exp $
function find_circle,mask,circle,ASPECT=ar,COORDINATES=coord
;+ finds the center and radius of the smallest circle containing the area defined by 2-D mask
;usage: err=find_circle(mask,circle,ASPECT=aspect,COORDINATES=coord)
; the first two elements of circle are x,y coordinates of the circle, the third the radius
; (taking into account the aspect ratio between the x and y axis).
; ASPECT defines the y/x aspect ratio.
; COORDINATES return the x and y coordinates of the pixels within the mask, taking into account the aspect ratio.
;-
sz=size(mask)
if sz[0] ne 2 then begin
message,"Mask array must be 2-D!",/cont
return,-1
endif
if n_elements(ar) eq 0 then begin
ar=1.0
endif else ar=float(ar[0])
bad=mask gt 0.0
x=rebin(findgen(sz(1)),sz(1),sz(2),/sa)
y=transpose(rebin(findgen(sz(2)),sz(2),sz(1),/sa))
circle=fltarr(3)
xc=total(x*bad)/total(bad)
yc=total(y*bad)/total(bad)
idx_red=where(bad)
xred=x(idx_red)
yred=y(idx_red)
dist=(xred-xc)^2+(ar*(yred-yc))^2
maxdist=max(dist)
circle=[xc,yc,sqrt(maxdist)]
coord=[[xred],[yred]]
return,0
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?