image_registration Package¶
image_registration
Package¶
image_registration Package¶
This is an Astropy affiliated package.
Functions¶
|
Find the offsets between image 1 and image 2 using the DFT upsampling method (http://www.mathworks.com/matlabcentral/fileexchange/18401-efficient-subpixel-image-registration-by-cross-correlation/content/html/efficient_subpixel_registration.html) combined with \(\chi^2\) to measure the errors on the fit |
|
Find the offsets between image 1 and image 2 using an iterative DFT upsampling method combined with \(\chi^2\) to measure the errors on the fit |
|
|
|
Use cross-correlation and a 2nd order taylor expansion to measure the offset between two images |
|
Determine the shift between two FITS images using the cross-correlation technique. |
|
Sub-pixel image registration (see dftregistration for lots of details) |
|
Run the tests for the package. |
register_images
Module¶
image_registration.register_images Module¶
Functions¶
|
Sub-pixel image registration (see dftregistration for lots of details) |
- image_registration.register_images.register_images(im1, im2, usfac=1, return_registered=False, return_error=False, zeromean=True, DEBUG=False, maxoff=None, nthreads=1, use_numpy_fft=False)[source]
Sub-pixel image registration (see dftregistration for lots of details)
- Parameters:
- im1np.ndarray
- im2np.ndarray
The images to register.
- usfacint
upsampling factor; governs accuracy of fit (1/usfac is best accuracy)
- return_registeredbool
Return the registered image as the last parameter
- return_errorbool
Does nothing at the moment, but in principle should return the “fit error” (it does nothing because I don’t know how to compute the “fit error”)
- zeromeanbool
Subtract the mean from the images before cross-correlating? If no, you may get a 0,0 offset because the DC levels are strongly correlated.
- maxoffint
Maximum allowed offset to measure (setting this helps avoid spurious peaks)
- DEBUGbool
Test code used during development. Should DEFINITELY be removed.
- Returns:
- dx,dyfloat,float
REVERSE of dftregistration order (also, signs flipped) for consistency with other routines. Measures the amount im2 is offset from im1 (i.e., shift im2 by these #’s to match im1)
chi2_shifts
Module¶
image_registration.chi2_shifts Module¶
Chi^2 shifts¶
Various tools for calculating shifts based on the chi^2 method
Functions¶
|
Find the offsets between image 1 and image 2 using the DFT upsampling method (http://www.mathworks.com/matlabcentral/fileexchange/18401-efficient-subpixel-image-registration-by-cross-correlation/content/html/efficient_subpixel_registration.html) combined with \(\chi^2\) to measure the errors on the fit |
|
Find the offsets between image 1 and image 2 using an iterative DFT upsampling method combined with \(\chi^2\) to measure the errors on the fit |
|
|
cross_correlation_shifts
Module¶
image_registration.cross_correlation_shifts Module¶
Functions¶
|
Use cross-correlation and a 2nd order taylor expansion to measure the offset between two images |
|
Determine the shift between two FITS images using the cross-correlation technique. |
- image_registration.cross_correlation_shifts.cross_correlation_shifts(image1, image2, errim1=None, errim2=None, maxoff=None, verbose=False, gaussfit=False, return_error=False, zeromean=True, **kwargs)[source]
Use cross-correlation and a 2nd order taylor expansion to measure the offset between two images
Given two images, calculate the amount image2 is offset from image1 to sub-pixel accuracy using 2nd order taylor expansion.
- Parameters:
- image1: np.ndarray
The reference image
- image2: np.ndarray
The offset image. Must have the same shape as image1
- errim1: np.ndarray [optional]
The pixel-by-pixel error on the reference image
- errim2: np.ndarray [optional]
The pixel-by-pixel error on the offset image.
- maxoff: int
Maximum allowed offset (in pixels). Useful for low s/n images that you know are reasonably well-aligned, but might find incorrect offsets due to edge noise
- zeromeanbool
Subtract the mean from each image before performing cross-correlation?
- verbose: bool
Print out extra messages?
- gaussfitbool
Use a Gaussian fitter to fit the peak of the cross-correlation?
- return_error: bool
Return an estimate of the error on the shifts. WARNING: I still don’t understand how to make these agree with simulations. The analytic estimate comes from http://adsabs.harvard.edu/abs/2003MNRAS.342.1291Z At high signal-to-noise, the analytic version overestimates the error by a factor of about 1.8, while the gaussian version overestimates error by about 1.15. At low s/n, they both UNDERestimate the error. The transition zone occurs at a total S/N ~ 1000 (i.e., the total signal in the map divided by the standard deviation of the map - it depends on how many pixels have signal)
- **kwargs are passed to correlate2d, which in turn passes them to convolve.
- The available options include image padding for speed and ignoring NaNs.
References
From http://solarmuri.ssl.berkeley.edu/~welsch/public/software/cross_cor_taylor.pro
Examples
>>> import numpy as np >>> im1 = np.zeros([10,10]) >>> im2 = np.zeros([10,10]) >>> im1[4,3] = 1 >>> im2[5,5] = 1 >>> import image_registration >>> yoff,xoff = image_registration.cross_correlation_shifts(im1,im2) >>> im1_aligned_to_im2 = np.roll(np.roll(im1,int(yoff),1),int(xoff),0) >>> assert (im1_aligned_to_im2-im2).sum() == 0
Subpackages¶
- fft_tools Package
fft_tools
Package- image_registration.fft_tools Package
convolve_nd
Module- image_registration.fft_tools.convolve_nd Module
correlate2d
Module- image_registration.fft_tools.correlate2d Module
fast_ffts
Module- image_registration.fft_tools.fast_ffts Module
shift
Module- image_registration.fft_tools.shift Module
zoom
Module- image_registration.fft_tools.zoom Module
scale
Module- image_registration.fft_tools.scale Module
upsample
Module- image_registration.fft_tools.upsample Module
- FITS_tools Package