|
Bsoft
1.9
Bernard's software package
|
Header file for functions to align images. More...
Go to the source code of this file.
Macros | |
| #define | NANG 16 |
| #define | NPOLANG 720 |
Functions | |
| Transform | img_align (Bimage *p1, Bimage *p2, Vector3< int > tile_size, double res_lo, double res_hi, double max_shift, int filter_flag, int refine_flag) |
| Aligns the second image to the first. More... | |
| double | img_align2D_pps (Bimage *p, Bimage *pref, int fullasu, double res_hi, double res_lo, double shift_limit, fft_plan planf, fft_plan planb) |
| Finds the best in-plane alignment for two 2D images using polar power spectra. More... | |
| double | img_align2D (Bimage *p, Bimage *pref, int fullasu, double res_polar, int ann_min, int ann_max, Bimage *pmask, double shift_limit, fft_plan planf_1D, fft_plan planb_1D, fft_plan planf_2D, fft_plan planb_2D) |
| Finds the best in-plane alignment for two 2D images using polar power spectra. More... | |
| int | img_align2D (Bimage *p, Bimage *pref, int ann_min, int ann_max, double res_lo, double res_hi, double shift_limit) |
| Finds the best in-plane alignment for two 2D images using polar power spectra. More... | |
| double | img_correlate_annuli (Bimage *pol, Bimage *polref, int fullasu, int ann_min, int ann_max, fft_plan planf, fft_plan planb, double &cc_max) |
| Correlate annuli of a polar image. More... | |
Header file for functions to align images.
Definition in file img_align.h.
| #define NANG 16 |
Definition at line 13 of file img_align.h.
| #define NPOLANG 720 |
Definition at line 14 of file img_align.h.
| Transform img_align | ( | Bimage * | p1, |
| Bimage * | p2, | ||
| Vector3< int > | tile_size, | ||
| double | res_lo, | ||
| double | res_hi, | ||
| double | max_shift, | ||
| int | filter_flag, | ||
| int | refine_flag | ||
| ) |
Aligns the second image to the first.
| *p1 | first image. |
| *p2 | second image (transformed) |
| tile_size | 3-valued vector for the size of sub-images. |
| res_lo | low resolution limit for cross-correlation. |
| res_hi | high resolution limit for cross-correlation. |
| max_shift | maximum shift allowed (default 1/4 of tile). |
| filter_flag | flag to filter micrograph extremes. |
| refine_flag | flag to turn on refinement of shift. |
The second image is transformed to fit on the first image.
Definition at line 152 of file img_align.cpp.
| double img_align2D | ( | Bimage * | p, |
| Bimage * | pref, | ||
| int | fullasu, | ||
| double | res_polar, | ||
| int | ann_min, | ||
| int | ann_max, | ||
| Bimage * | prs_mask, | ||
| double | shift_limit, | ||
| fft_plan | planf_1D, | ||
| fft_plan | planb_1D, | ||
| fft_plan | planf_2D, | ||
| fft_plan | planb_2D | ||
| ) |
Finds the best in-plane alignment for two 2D images using polar power spectra.
| *p | 2D image. |
| *pref | reference 2D image. |
| fullasu | flag to indicate projections for the full ASU (default half). |
| res_polar | polar resolution limit. |
| ann_min | minimum annulus (>=0). |
| ann_max | maximum annulus (< image radius). |
| *prs_mask | dual mask. |
| shift_limit | maximum shift from nominal origin of box. |
| planf_1D | FFT forward plan for polar images. |
| planb_1D | FFT backward plan for polar images. |
| planf_2D | FFT forward plan for 2D images. |
| planb_2D | FFT backward plan for 2D images. |
Both the image and reference is converted to polar images using the current origins. The annuli of the polar images are cross-correlated to find the rotation angle. The reference is rotated and cross-correlated with the image to determine a new origin for the image. This is iterated untill the rotation angle and origin of the image does not change any more, or a maximum number of iterations. The cross-correlation is done with the provided mask.. The correlation coefficient return is the cross-correlation peak. The input images must be equal-sized square 2D images.
Definition at line 417 of file img_align.cpp.
| int img_align2D | ( | Bimage * | p, |
| Bimage * | pref, | ||
| int | ann_min, | ||
| int | ann_max, | ||
| double | res_lo, | ||
| double | res_hi, | ||
| double | shift_limit | ||
| ) |
Finds the best in-plane alignment for two 2D images using polar power spectra.
| *p | 2D image. |
| *pref | reference 2D image. |
| ann_min | minimum annulus (>=0). |
| ann_max | maximum annulus (< image radius). |
| res_lo | low resolution limit (angstrom). |
| res_hi | high resolution limit (angstrom). |
| shift_limit | maximum shift from nominal origin of box. |
This is a simplified interface to the other function img_align2D. All the fourier transform and rotation functions are handled internally.
Definition at line 494 of file img_align.cpp.
| double img_align2D_pps | ( | Bimage * | p, |
| Bimage * | pref, | ||
| int | fullasu, | ||
| double | res_hi, | ||
| double | res_lo, | ||
| double | shift_limit, | ||
| fft_plan | planf, | ||
| fft_plan | planb | ||
| ) |
Finds the best in-plane alignment for two 2D images using polar power spectra.
| *p | 2D image (carries new origin and angle). |
| *pref | reference 2D image. |
| fullasu | flag to indicate projections for the full ASU (default half). |
| res_hi | high resolution limit. |
| res_lo | low resolution limit. |
| shift_limit | maximum shift from nominal origin of box. |
| planf | FFT forward plan. |
| planb | FFT backward plan. |
The rotation angle is found by cross-correlating the annuli of the polar transforms of the power spectra of the image and the reference image. If the full asu flag is not set, the annular cross-correlation is done both forwards and backwards to detect mirror images, with the sign of the angle indicating which direction is best (>0 => forwards, <0 => backwards). The resolution limit specified in the image is used to low-pass filter the cross-correlation. The shift is then determined by cross-correlation after rotating the reference image, as well as its 180° rotation to deal with that ambiguity in the power spectrum. The correlation coefficient return is the cross-correlation peak. The input images must be equal-sized square 2D images. The origin and rotation angle is returned in the image structure.
Definition at line 319 of file img_align.cpp.
| double img_correlate_annuli | ( | Bimage * | pol, |
| Bimage * | polref, | ||
| int | fullasu, | ||
| int | ann_min, | ||
| int | ann_max, | ||
| fft_plan | planf, | ||
| fft_plan | planb, | ||
| double & | cc_max | ||
| ) |
Correlate annuli of a polar image.
| *pol | image polar power spectrum transform. |
| *polref | reference image polar power spectrum transform. |
| fullasu | flag to indicate projections for the full ASU (default half). |
| ann_min | low resolution cutoff (in inverse pixels). |
| ann_max | high resolution cutoff (in inverse pixels). |
| planf | FFT forward plan. |
| planb | FFT backward plan. |
| &cc_max | pointer to correlation coefficient for return. |
The input images must be transformed polar images, with each annulus corresponding to a row in the image. The polar image annuli between the given limits are cross-correlated one by one, and a sum of all annuli calculated, weighted by annulus index. The maximum value in the annulus sum corresponds to the best fit angle. Both image and mirror image are assessed, yielding a negative angle when the mirror image gives a larger correlation. FFTW library (www.fftw.org).
Definition at line 558 of file img_align.cpp.