Module API¶
ASTROALIGN is a simple package that will try to align two stellar astronomical images, especially when there is no WCS information available.
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.
MAX_CONTROL_POINTS
= 50¶ The maximum control points (stars) to use to build the invariants.
Default: 50

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
¶

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)¶ Applies the transformation
transform
tosource
.The output image will have the same shape as
target
.Parameters:  transform – A scikitimage
SimilarityTransform
object.  source (numpy array) – A 2D numpy array of the source image to be transformed.
 target (numpy array) – A 2D numpy 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: A tuple (aligned_image, footprint). 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.
 transform – A scikitimage

astroalign.
find_transform
(source, target)¶ 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 (arraylike) – Either a numpy array of the source image to be transformed or an interable of (x, y) coordinates of the target control points.
 target (arraylike) – Either a numpy array of the target (destination) image or an interable of (x, y) coordinates of the target control points.
Returns: The transformation object and a tuple of corresponding star positions in source and target.:
T, (source_pos_array, target_pos_array)
Raises: TypeError
– If input type ofsource
ortarget
is not supported.Exception
– If it cannot find more than 3 stars on any input.

astroalign.
register
(source, target, fill_value=None, propagate_mask=False)¶ Transform
source
to coincide pixel to pixel withtarget
.Parameters:  source (numpy array) – A 2D numpy array of the source image to be transformed.
 target (numpy array) – A 2D numpy 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: A tuple (aligned_image, footprint). 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.