### Install Latest Stable Version Source: https://github.com/quatrope/astroalign/blob/master/docs/installation.md Use this command to install the latest stable release of astroalign from the Python Package Index. ```bash pip install astroalign ``` -------------------------------- ### Install Development Version from GitHub Source: https://github.com/quatrope/astroalign/blob/master/docs/installation.md Clone the repository and install the package in editable mode to use the latest development code. ```bash git clone https://github.com/quatrope/astroalign cd astroalign pip install -e . ``` -------------------------------- ### Run Tests with pytest Source: https://github.com/quatrope/astroalign/blob/master/README.md Execute the project's tests using pytest. Ensure your installation is working correctly by running this command. ```bash pytest -v ``` -------------------------------- ### Clean Image Before Registration Source: https://github.com/quatrope/astroalign/blob/master/docs/examples.md For CCDs with defects like hot or dead pixels, clean the image first using `cosmicray_lacosmic` before attempting registration. This example also shows increasing `min_area`. ```python >>> from ccdproc import cosmicray_lacosmic as lacosmic >>> clean_source, mask = lacosmic(myimage) >>> registered_image, footprint = aa.register(clean_source, clean_target, min_area=9) ``` -------------------------------- ### Register Color Images with Pillow Source: https://github.com/quatrope/astroalign/blob/master/docs/tutorial.md Astroalign can process color images if the channel index is the last axis. This example shows how to register images using Pillow, converting the result back to a Pillow image. ```python from PIL import Image import astroalign as aa source = Image.open("source.jpg") target = Image.open("target.jpg") registered, footprint = aa.register(source, target) registered = Image.fromarray(registered.astype("unit8")) ``` -------------------------------- ### Find Transformation from Images or Star Lists Source: https://github.com/quatrope/astroalign/blob/master/docs/tutorial.md Use find_transform to inspect transformation parameters or get star correspondences. Inputs can be image arrays or iterables of (x, y) star positions. ```python transf, (source_list, target_list) = aa.find_transform(source, target) ``` -------------------------------- ### Apply Transformation to Points Source: https://github.com/quatrope/astroalign/blob/master/docs/tutorial.md Apply a previously estimated transformation matrix to a set of source points to get the transformed destination points. The `tform.params` attribute holds the transformation matrix. ```python >>> dst_calc = aa.matrix_transform(src, tform.params) ``` -------------------------------- ### Define Similarity Transform Source: https://github.com/quatrope/astroalign/blob/master/docs/tutorial.md Define a similarity transformation using scikit-image's SimilarityTransform class. This example creates a 90-degree clockwise rotation with a translation. ```python >>> import numpy as np >>> from skimage.transform import SimilarityTransform >>> transf = SimilarityTransform(rotation=np.pi/2., translation=(1, 0)) ``` -------------------------------- ### Run Tests with Python Source: https://github.com/quatrope/astroalign/blob/master/README.md Execute the project's tests directly using the Python interpreter. This is an alternative to using pytest. ```bash python tests/test_align.py ``` -------------------------------- ### Register Images Source: https://github.com/quatrope/astroalign/blob/master/docs/tutorial.md Use this for a simple, common case of transforming one image to match another when WCS information is unavailable. It registers source image to target image. ```python import astroalign as aa registered_image, footprint = aa.register(source, target) ``` -------------------------------- ### Estimate Affine Transform Source: https://github.com/quatrope/astroalign/blob/master/docs/tutorial.md Use this when you know the correspondence between source and target points to estimate the affine transformation. Requires NumPy arrays for source and destination points. ```python >>> src = np.array([(127.03, 85.98), (23.11, 31.87), (98.84, 142.99), ... (150.93, 85.02), (137.99, 12.88)]) >>> dst = np.array([(175.13, 111.36), (0.58, 119.04), (181.55, 206.49), ... (205.60, 91.89), (134.61, 7.94)]) >>> tform = aa.estimate_transform('affine', src, dst) ``` -------------------------------- ### Apply Transformation Source: https://github.com/quatrope/astroalign/blob/master/docs/tutorial.md Apply a found transformation to a source image to align it with a target. This is useful when the transformation parameters are satisfactory. ```python if transf.rotation > MIN_ROT: registered_image = aa.apply_transform(transf, source, target) ``` -------------------------------- ### Register with Increased Minimum Area Source: https://github.com/quatrope/astroalign/blob/master/docs/examples.md To avoid considering hot pixels or other CCD artifacts as legitimate sources, increase the `min_area` from the default value of 5. ```python >>> import astroalign as aa >>> registered_image, footprint = aa.register(source, target, min_area=9) ``` -------------------------------- ### Initialize NDData Object Source: https://github.com/quatrope/astroalign/blob/master/docs/tutorial.md Create an NDData object from Astropy, which can hold both data and a mask. This is useful for working with images that have masked regions. ```python >>> from astropy.nddata import NDData >>> nd = NDData([[0, 1], [2, 3]], [[True, False], [False, False]]) ``` -------------------------------- ### Register with Lower Detection Sigma Source: https://github.com/quatrope/astroalign/blob/master/docs/examples.md If stars are faint and may not pass the default $5 σ$ threshold, lower the detection $σ$ using the `detection_sigma` argument. ```python >>> import astroalign as aa >>> registered_image, footprint = aa.register(source, target, detection_sigma=2) ``` -------------------------------- ### apply_transform Source: https://github.com/quatrope/astroalign/blob/master/docs/api.md Applies a given transformation to a source image, producing an aligned image and a footprint mask. ```APIDOC ## apply_transform(transform, source, target, fill_value=None, propagate_mask=False) ### Description Apply the transformation `transform` to `source`. The output image will have the same shape as `target`. ### Parameters #### Parameters - **transform** – A scikit-image `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 ``` -------------------------------- ### Register with Limited Control Points Source: https://github.com/quatrope/astroalign/blob/master/docs/examples.md When the field has few stars (3-6), restrict the number of control points to avoid matching noisy structures. Use the `max_control_points` argument. ```python >>> import astroalign as aa >>> registered_image, footprint = aa.register(source, target, max_control_points=3) ``` -------------------------------- ### Find Transformation Between Images Source: https://github.com/quatrope/astroalign/blob/master/README.md Determines the transformation and corresponding star lists between two astronomical images. Useful when only the transformation parameters are needed. ```python transf, (s_list, t_list) = aa.find_transform(source, target) ``` -------------------------------- ### Align Astronomical Images Source: https://github.com/quatrope/astroalign/blob/master/README.md Aligns a source image to a target image using astroalign. The source image is transformed to match the target's pixel grid. ```python import astroalign as aa aligned_image, footprint = aa.register(source_image, target_image) ``` -------------------------------- ### Overwriting target image pixels with registered source Source: https://github.com/quatrope/astroalign/blob/master/docs/mask.md After registration, this code snippet overwrites pixels in the target image with the corresponding pixels from the registered source image, but only within the calculated footprint. This is a common application after performing masked registration. ```python >>> target[~footprint] = registered[~footprint] ``` -------------------------------- ### astroalign.register Source: https://github.com/quatrope/astroalign/blob/master/docs/api.md Transforms a source image to align with a target image, returning the transformed image and a footprint mask. ```APIDOC ## astroalign.register ### Description Transform `source` to coincide pixel to pixel with `target`. ### Method `register(source, target, fill_value=None, propagate_mask=False, max_control_points=50, detection_sigma=5, min_area=5)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **source** (NumPy, CCData, or NDData array) - A 2D array of the source image to be transformed. * **target** (NumPy, CCData, or NDData array) - A 2D array of the target image. Used to set the output image shape. * **fill_value** (any) - Optional. A value to fill in areas of the aligned image where the footprint is True. * **propagate_mask** (bool) - Optional. Whether to propagate the mask in source.mask onto the footprint. * **max_control_points** (int) - Optional. The maximum number of control point-sources to find the transformation. Defaults to 50. * **detection_sigma** (int) - Optional. Factor of background std-dev above which is considered a detection. Defaults to 5. * **min_area** (int) - Optional. Minimum number of connected pixels to be considered a source. Defaults to 5. ### Returns * **aligned_image** (numpy 2D array) - The transformed source image. * **footprint** (numpy 2D array) - A mask with True on regions with no pixel information. ### Return Type `aligned_image`, `footprint` ### Raises * **TypeError** - If the input type of `source` or `target` is not supported. * **ValueError** - If more than 3 stars cannot be found on any input. * **MaxIterError** - If no transformation is found. ``` -------------------------------- ### find_transform Source: https://github.com/quatrope/astroalign/blob/master/docs/api.md Estimates the affine transformation between two images by finding matching asterisms. ```APIDOC ## find_transform(source, target, max_control_points=50, detection_sigma=5, min_area=5) ### Description 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 #### 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 point-sources to find the transformation. - **detection_sigma** (*int*) – Factor of background std-dev 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 of `source` or `target` is not supported. - **ValueError** – If it cannot find more than 3 stars on any input. - [**MaxIterError**](#astroalign.MaxIterError) – If no transformation is found. ``` -------------------------------- ### estimate_transform Source: https://github.com/quatrope/astroalign/blob/master/docs/api.md Lazy-loader function for skimage.transform.estimate_transform. Provides full documentation via scikit-image. ```APIDOC ## estimate_transform(*args, **kwargs) ### Description Lazy-loader function for skimage.transform.estimate_transform. Full documentation: [https://scikit-image.org/docs/stable/api/skimage.transform.html#skimage.transform.estimate_transform](https://scikit-image.org/docs/stable/api/skimage.transform.html#skimage.transform.estimate_transform) ``` -------------------------------- ### Masking regions of interest in target image Source: https://github.com/quatrope/astroalign/blob/master/docs/mask.md Create a boolean mask to exclude regions from the target image before registration. This is useful when the images have significantly different fields of view or when you want to focus the search on a specific area. ```python >>> mask = np.ones_like(target, dtype="bool") >>> mask[300:900,1000:1700,:] = False # ROI >>> target_masked = np.ma.array(target, mask=mask) >>> registered, footprint = aa.register(source, target_masked) ``` -------------------------------- ### matrix_transform Source: https://github.com/quatrope/astroalign/blob/master/docs/api.md Lazy-loader function for skimage.transform.matrix_transform. Provides full documentation via scikit-image. ```APIDOC ## matrix_transform(*args, **kwargs) ### Description Lazy-loader function for skimage.transform.matrix_transform. Full documentation: [https://scikit-image.org/docs/stable/api/skimage.transform.html#skimage.transform.matrix_transform](https://scikit-image.org/docs/stable/api/skimage.transform.html#skimage.transform.matrix_transform) ``` -------------------------------- ### Apply Transform with Mask Propagation Source: https://github.com/quatrope/astroalign/blob/master/docs/tutorial.md Apply a transformation to an NDData object, propagating the mask along with the data. Set `propagate_mask=True` to include mask transformation and overlay the footprint mask. ```python >>> aligned_image, footprint = aa.apply_transform(transf, nd, nd, propagate_mask=True) ``` -------------------------------- ### Create New NDData Object Source: https://github.com/quatrope/astroalign/blob/master/docs/tutorial.md Construct a new NDData object using the transformed data and the calculated footprint mask. This is a convenient way to store the result of an alignment operation. ```python >>> new_nd = NDData(aligned_image, mask=footprint) ``` -------------------------------- ### Mask Aligned Image with Special Value Source: https://github.com/quatrope/astroalign/blob/master/docs/tutorial.md Use the footprint mask to fill the aligned image with a special value where transformation had no pixel information. This can be done by direct indexing or using the fill_value argument. ```python registered_image, footprint = aa.register(source, target) registered_image[footprint] = -99999.99 ``` ```python registered_image, footprint = aa.register(source, target, fill_value=-99999.99) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.