quatrope / astroalign

A tool to align astronomical images based on asterism matching
MIT License
140 stars 44 forks source link

Utilise masking provided by sep #90

Closed DavidH2001 closed 11 months ago

DavidH2001 commented 1 year ago

I found that automatically registering images such as the following of M43 OIII was very touch and go even if image set was cleaned/dark subtracted.
image Rather than manually defining the aligning source and target location I thought I'd look to see if masking would work to identify a specific region to auto align on. E.g., right side of above image. Astroalign does not allow you to do this as it does not pass a masked array to sep. Sep does allow you to work with masked image regions and it aslo appears to work if you pass in the mask array separately via mask= argument. This works as I have used it to extract only from specific regions of an image.

Looking at astroalign, I see _find_sources() will do something with a masked image if it is allowed to pass through. By making the following change to source and target processing in find_transform():

_source_controlp = _find_sources(

_bw(_data(source)), DSH FIX

            source,
            detection_sigma=detection_sigma,
            min_area=min_area,
        )[:max_control_points]_

I was able to align on a selected region such as shown below:

image

The circled objects are the aligned points which were defined by masking. Example code:

_ref_data = ma.masked_array(ref_data, mask=mask) data_in = ma.masked_array(data[i, :, :], mask=mask) . transform, (s_list, t_list) = astroalign.find_transform(data_in, ref_data, max_control_points=control_points, detection_sigma=det_sigma, min_area=minarea)

Will it be possible or feasible to allow the use of masking to specify target/source regions in a future release of astroalign?

martinberoiz commented 11 months ago

Version 2.5.x now passes the mask over to sep.