rebin_detector.pro

来自「IDL语言编写的用于天文自适应光学仿真的软件CAOS V6.0的第一部分。」· PRO 代码 · 共 48 行

PRO
48
字号
; $Id: rebin_detector.pro,v 1.2 2002/03/14 11:49:10 riccardi Exp $

;+
; REBIN_DETECTOR
;
; Result = REBIN_DETECTOR(Image, N)
;
; INPUT
; Image:	immagine MxM da rebinnare
; N:		dimensione della matrice rebinnata (NxN)
;			(M deve essere un multiplo intero di N)
;
; OUTPUT
; ritorna una matrice NxN in cui ogni elemento e` la media
; degli elementi di Image in una zona quadrata corrispondente
;
; nel caso M=4 e N=2, Result(0,1) e` la media dei valori
; Image(0,2), Image(1,2),
; Image(0,3), Image(1,3)
;-
function rebin_detector, image, nsamp

	n = n_elements(image(*,0))
	if ((n mod nsamp) ne 0) then begin
		print, 'rebin_detector: wrong rebin size'
		return, 0
	endif

	pix_size = n/nsamp

	mask = bytarr(n,n)
	mask(0:pix_size-1,0:pix_size-1) = 1B

	rebinned_image = image(0)+bytarr(nsamp,nsamp)

	for j=0,nsamp-1 do begin
		for i=0,nsamp-1 do begin
			rebinned_image(i,j)=total(image(where(mask)))
			mask = shift(temporary(mask),pix_size,0)
		endfor
		mask = shift(temporary(mask),0,pix_size)
	endfor

	; ritorna la media, NON la somma
	return, rebinned_image/pix_size^2
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?