| |
- builtins.object
-
- Aligner
-
- FFTAligner
-
- PaddedFFTAligner
- FeatureAligner
- PCCAligner
class Aligner(builtins.object) |
|
Abstract class that defines an algorithm for aligning two images onto each other. |
|
Methods defined here:
- align(self, constraint, precalc1=None, precalc2=None)
- Performs the alignment of two images, finding the pixel offset that best aligns the
two images. The offset should be from image1 to image2. The return value should be a Constraint
object, with at least the dx, dy fields filled in to represent the offset of image2 needed
to align the two images. If the function finds the images don't overlap, None should be returned.
If a constraint is specified, this method should only return a constraint that fits within the error
of given constraint, meaning within constraint.error pixels from the (constraint.dx, constraint.dy)
offset.
- precalculate(self, image, box)
- Performs an arbitrary precalculation step specific to the alignment algorithm.
This would be a step in the algorithm that only has to be run once per image,
and can be cached for each calculation done with the same image. The result of
this function will be passed to the align function as the precalc1 or precalc2 argument
- precalculate_if_needed(self, constraint, precalc1, precalc2)
- resize_if_needed(self, image, box=None, downscale_factor=None, padding=None)
- # Helper functions for subclasses:
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class FFTAligner(Aligner) |
|
FFTAligner(num_peaks=2, precalculate_fft=True, downscale_factor=None, upscale_factor=1)
An aligner that uses the phase cross correlation algorithm to estimate the proper alignment of two images.
The algorithm is the same as described in Kuglin, Charles D. "The phase correlation image alignment method."
http://boutigny.free.fr/Astronomie/AstroSources/Kuglin-Hines.pdf |
|
- Method resolution order:
- FFTAligner
- Aligner
- builtins.object
Methods defined here:
- __init__(self, num_peaks=2, precalculate_fft=True, downscale_factor=None, upscale_factor=1)
- num_peaks: int default 2
Sets the number of peaks in the resulting phase cross correlation image to be checked. Sometimes the highest
peak is not actually the best offset for alignment so checking multiple peaks can help find the one that
has the highest ncc score. Increasing this will also increase processing time, possibly dramatically.
precalculate_fft: bool default True
Whether or not the FFT of the images should be precalculated and cached or be calculated every time.
The FFT is able to be precalculated however it does take up a large amount of memory, so if memory
is a limiting factor setting this to False can help
downscale_factor: int, optional
This algorithm is rather slow when calculating large numbers of constraints, and one way to improve
speed is by downscaling the images before running the algorithm. This will improve runtime at the expense
of precision, the constraints calculated will have a nonzero error value. Also, if the downscale factor
is large enough the algorithm can begin to fail and not find any overlap, in general the largest recommended
value is around 32, but it depends on how large the features in your images are.
- align(self, constraint, precalc1=None, precalc2=None)
- Performs the alignment of two images, finding the pixel offset that best aligns the
two images. The offset should be from image1 to image2. The return value should be a Constraint
object, with at least the dx, dy fields filled in to represent the offset of image2 needed
to align the two images. If the function finds the images don't overlap, None should be returned.
If a constraint is specified, this method should only return a constraint that fits within the error
of given constraint, meaning within constraint.error pixels from the (constraint.dx, constraint.dy)
offset.
- align_full(self, constraint, precalc1=None, precalc2=None)
- precalculate(self, image, box=None)
- Performs an arbitrary precalculation step specific to the alignment algorithm.
This would be a step in the algorithm that only has to be run once per image,
and can be cached for each calculation done with the same image. The result of
this function will be passed to the align function as the precalc1 or precalc2 argument
Methods inherited from Aligner:
- precalculate_if_needed(self, constraint, precalc1, precalc2)
- resize_if_needed(self, image, box=None, downscale_factor=None, padding=None)
- # Helper functions for subclasses:
Data descriptors inherited from Aligner:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class FeatureAligner(Aligner) |
|
FeatureAligner(num_features=2000)
|
|
- Method resolution order:
- FeatureAligner
- Aligner
- builtins.object
Methods defined here:
- __init__(self, num_features=2000)
- Initialize self. See help(type(self)) for accurate signature.
- align(self, constraint, precalc1=None, precalc2=None)
- Performs the alignment of two images, finding the pixel offset that best aligns the
two images. The offset should be from image1 to image2. The return value should be a Constraint
object, with at least the dx, dy fields filled in to represent the offset of image2 needed
to align the two images. If the function finds the images don't overlap, None should be returned.
If a constraint is specified, this method should only return a constraint that fits within the error
of given constraint, meaning within constraint.error pixels from the (constraint.dx, constraint.dy)
offset.
- precalculate(self, image, box=None)
- Performs an arbitrary precalculation step specific to the alignment algorithm.
This would be a step in the algorithm that only has to be run once per image,
and can be cached for each calculation done with the same image. The result of
this function will be passed to the align function as the precalc1 or precalc2 argument
Methods inherited from Aligner:
- precalculate_if_needed(self, constraint, precalc1, precalc2)
- resize_if_needed(self, image, box=None, downscale_factor=None, padding=None)
- # Helper functions for subclasses:
Data descriptors inherited from Aligner:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class PCCAligner(Aligner) |
|
PCCAligner(**kwargs)
An aligner that invokes the skimage.registration.phase_cross_correlation method
An alternative to the FFTAligner which implements the same algorithm |
|
- Method resolution order:
- PCCAligner
- Aligner
- builtins.object
Methods defined here:
- __init__(self, **kwargs)
- Initialize self. See help(type(self)) for accurate signature.
- align(self, constraint, precalc1=None, precalc2=None)
- Performs the alignment of two images, finding the pixel offset that best aligns the
two images. The offset should be from image1 to image2. The return value should be a Constraint
object, with at least the dx, dy fields filled in to represent the offset of image2 needed
to align the two images. If the function finds the images don't overlap, None should be returned.
If a constraint is specified, this method should only return a constraint that fits within the error
of given constraint, meaning within constraint.error pixels from the (constraint.dx, constraint.dy)
offset.
Methods inherited from Aligner:
- precalculate(self, image, box)
- Performs an arbitrary precalculation step specific to the alignment algorithm.
This would be a step in the algorithm that only has to be run once per image,
and can be cached for each calculation done with the same image. The result of
this function will be passed to the align function as the precalc1 or precalc2 argument
- precalculate_if_needed(self, constraint, precalc1, precalc2)
- resize_if_needed(self, image, box=None, downscale_factor=None, padding=None)
- # Helper functions for subclasses:
Data descriptors inherited from Aligner:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class PaddedFFTAligner(FFTAligner) |
|
PaddedFFTAligner(num_peaks=2, precalculate_fft=True, downscale_factor=None, upscale_factor=1)
|
|
- Method resolution order:
- PaddedFFTAligner
- FFTAligner
- Aligner
- builtins.object
Methods defined here:
- align(self, constraint, precalc1=None, precalc2=None)
- Performs the alignment of two images, finding the pixel offset that best aligns the
two images. The offset should be from image1 to image2. The return value should be a Constraint
object, with at least the dx, dy fields filled in to represent the offset of image2 needed
to align the two images. If the function finds the images don't overlap, None should be returned.
If a constraint is specified, this method should only return a constraint that fits within the error
of given constraint, meaning within constraint.error pixels from the (constraint.dx, constraint.dy)
offset.
- precalculate(self, image, box=None)
- Performs an arbitrary precalculation step specific to the alignment algorithm.
This would be a step in the algorithm that only has to be run once per image,
and can be cached for each calculation done with the same image. The result of
this function will be passed to the align function as the precalc1 or precalc2 argument
Methods inherited from FFTAligner:
- __init__(self, num_peaks=2, precalculate_fft=True, downscale_factor=None, upscale_factor=1)
- num_peaks: int default 2
Sets the number of peaks in the resulting phase cross correlation image to be checked. Sometimes the highest
peak is not actually the best offset for alignment so checking multiple peaks can help find the one that
has the highest ncc score. Increasing this will also increase processing time, possibly dramatically.
precalculate_fft: bool default True
Whether or not the FFT of the images should be precalculated and cached or be calculated every time.
The FFT is able to be precalculated however it does take up a large amount of memory, so if memory
is a limiting factor setting this to False can help
downscale_factor: int, optional
This algorithm is rather slow when calculating large numbers of constraints, and one way to improve
speed is by downscaling the images before running the algorithm. This will improve runtime at the expense
of precision, the constraints calculated will have a nonzero error value. Also, if the downscale factor
is large enough the algorithm can begin to fail and not find any overlap, in general the largest recommended
value is around 32, but it depends on how large the features in your images are.
- align_full(self, constraint, precalc1=None, precalc2=None)
Methods inherited from Aligner:
- precalculate_if_needed(self, constraint, precalc1, precalc2)
- resize_if_needed(self, image, box=None, downscale_factor=None, padding=None)
- # Helper functions for subclasses:
Data descriptors inherited from Aligner:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |