Module Methods

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 3-point 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, point-spread functions, seeing and atmospheric conditions.

  1. 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

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.align_image(ref_image, img2transf, n_ref_src=50, n_img_src=70, px_tol=2.0)

Deprecated: Alias for register for backwards compatibility.

astroalign.apply_transform(transform, source, target)

Applies the transformation transform to source.

The output image will have the same shape as target.

Parameters:
  • transform – A scikit-image 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.
Returns:

A numpy 2D array of the transformed source. If source is a masked array the returned image will also be a masked array with outside pixels set to True.

astroalign.find_affine_transform(test_srcs, ref_srcs, max_pix_tol=2.0, min_matches_fraction=0.8, invariant_map=None)

Deprecated: Alias for find_transform for backwards compatibility.

astroalign.find_transform(source, target)

Estimate the transform between source and target.

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 (array-like) – Either a numpy array of the source image to be transformed or an interable of (x, y) coordinates of the target control points.
  • target (array-like) – 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 of source or target is not supported.
  • Exception – If it cannot find more than 3 stars on any input.
astroalign.register(source, target)

Transform source to coincide pixel to pixel with target.

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.
Returns:

A numpy 2D array of the transformed source. If source is a masked array the returned image will also be a masked array with outside pixels set to True.