idlastro / FITS I/O: CORREL_IMAGES

[Source code]

NAME
CORREL_IMAGES
PURPOSE
Compute the 2-D cross-correlation function of two images
EXPLANATION
Computes the 2-D cross-correlation function of two images for
a range of (x,y) shifting by pixels of one image relative to the other.
CALLING SEQUENCE
Result = CORREL_IMAGES( image_A, image_B, 
                 [XSHIFT=, YSHIFT=, XOFFSET_B=, YOFFSET_B=, REDUCTION=, 
                 MAGNIFICATION=, /NUMPIX, /MONITOR  )
INPUTS
image_A, image_B = the two images of interest.
OPTIONAL INPUT KEYWORDS
XSHIFT = the + & - shift to be applied in X direction, default=7.
YSHIFT = the Y direction + & - shifting, default=7.
XOFFSET_B = initial X pixel offset of image_B relative to image_A.
YOFFSET_B = Y pixel offset, defaults are (0,0).
REDUCTION = optional reduction factor causes computation of
                Low resolution correlation of bin averaged images,
                thus faster. Can be used to get approximate optimal
                (x,y) offset of images, and then called for successive
                lower reductions in conjunction with CorrMat_Analyze
                until REDUCTION=1, getting offset up to single pixel.
MAGNIFICATION = option causes computation of high resolution correlation
                of magnified images, thus much slower.
                Shifting distance is automatically = 2 + Magnification,
                and optimal pixel offset should be known and specified.
                Optimal offset can then be found to fractional pixels
                using CorrMat_Analyze( correl_images( ) ).
/NUMPIX - if set, causes the number of pixels for each correlation
                to be saved in a second image, concatenated to the
                correlation image, so Result is fltarr( Nx, Ny, 2 ).
/MONITOR causes the progress of computation to be briefly printed.
OUTPUTS
Result is the cross-correlation function, given as a matrix.
PROCEDURE
Loop over all possible (x,y) shifts, compute overlap and correlation
for each shift. Correlation set to zero when there is no overlap.
MODIFICATION HISTORY
Written, July,1991, Frank Varosi, STX @ NASA/GSFC
Use ROUND instead of NINT, June 1995, Wayne Landsman HSTX
Avoid divide by zero errors, W. Landsman HSTX April 1996
 Remove use of !DEBUG    W. Landsman   June 1997
Subtract mean of entire image before computing correlation, not just 
   mean of overlap region   H. Ebeling/W. Landsman   June 1998
Always REBIN() using floating pt arithmetic W. Landsman  Nov 2007