Module API¶
ASTROALIGN aligns stellar images using no WCS information.
It does so by finding similar 3point asterisms (triangles) in both images and deducing the affine transformation between them.
General registration routines try to match feature points, using corner detection routines to make the point correspondence. These generally fail for stellar astronomical images, since stars have very little stable structure and so, in general, indistinguishable from each other.
Asterism matching is more robust, and closer to the human way of matching stellar images.
Astroalign can match images of very different field of view, pointspread functions, seeing and atmospheric conditions.
 Martin Beroiz

astroalign.
MIN_MATCHES_FRACTION
= 0.8¶ The minimum fraction of triangle matches to accept a transformation.
If the minimum fraction yields more than 10 triangles, 10 is used instead.
Default: 0.8

exception
astroalign.
MaxIterError
¶ Raise if maximum iterations reached.

astroalign.
NUM_NEAREST_NEIGHBORS
= 5¶ The number of nearest neighbors of a given star (including itself) to construct the triangle invariants.
Default: 5

astroalign.
PIXEL_TOL
= 2¶ The pixel distance tolerance to assume two invariant points are the same.
Default: 2

astroalign.
apply_transform
(transform, source, target, fill_value=None, propagate_mask=False)¶ Apply the transformation
transform
tosource
.The output image will have the same shape as
target
.Parameters:  transform – A scikitimage
SimilarityTransform
object.  source – A 2D NumPy, CCData or NDData array of the source image to be transformed.
 target – A 2D NumPy, CCData or NDData array of the target image. Only used to set the output image shape.
 fill_value (float) – A value to fill in the areas of aligned_image where footprint == True.
 propagate_mask (bool) – Wether to propagate the mask in source.mask onto footprint.
Returns: aligned_image
is a numpy 2D array of the transformed source.footprint
is a mask 2D array with True on the regions with no pixel information.Return type: aligned_image, footprint
 transform – A scikitimage

astroalign.
find_transform
(source, target, max_control_points=50, detection_sigma=5, min_area=5)¶ Estimate the transform between
source
andtarget
.Return a SimilarityTransform object
T
that maps pixel x, y indices from the source image s = (x, y) into the target (destination) image t = (x, y). T contains parameters of the tranformation:T.rotation
,T.translation
,T.scale
,T.params
.Parameters:  source – A 2D NumPy, CCData or NDData array of the source image to be transformed or an interable of (x, y) coordinates of the source control points.
 target – A 2D NumPy, CCData or NDData array of the target (destination) image or an interable of (x, y) coordinates of the target control points.
 max_control_points – The maximum number of control pointsources to find the transformation.
 detection_sigma (int) – Factor of background stddev above which is considered a detection. This value is ignored if input are not images.
 min_area (int) – Minimum number of connected pixels to be considered a source. This value is ignored if input are not images.
Returns: The transformation object and a tuple of corresponding star positions in source and target.
Return type: T, (source_pos_array, target_pos_array)
Raises: TypeError
– If input type ofsource
ortarget
is not supported.ValueError
– If it cannot find more than 3 stars on any input.MaxIterError
– If no transformation is found.

astroalign.
register
(source, target, fill_value=None, propagate_mask=False, max_control_points=50, detection_sigma=5, min_area=5)¶ Transform
source
to coincide pixel to pixel withtarget
.Parameters:  source – A 2D NumPy, CCData or NDData array of the source image to be transformed.
 target – A 2D NumPy, CCData or NDData array of the target image. Used to set the output image shape as well.
 fill_value – A value to fill in the areas of aligned_image where footprint == True.
 propagate_mask (bool) – Wether to propagate the mask in source.mask onto footprint.
 max_control_points – The maximum number of control pointsources to find the transformation.
 detection_sigma (int) – Factor of background stddev above which is considered a detection.
 min_area (int) – Minimum number of connected pixels to be considered a source.
Returns: aligned_image
is a numpy 2D array of the transformed source.footprint
is a mask 2D array with True on the regions with no pixel information.Return type: aligned_image, footprint
Raises: TypeError
– If input type ofsource
ortarget
is not supported.ValueError
– If it cannot find more than 3 stars on any input.MaxIterError
– If no transformation is found.