quatrope / astroalign

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

Add support for color images #57

Closed martinberoiz closed 3 years ago

martinberoiz commented 3 years ago

For registration is probably better to use Y channel in YUV colorspace, or average of RGB.

Quick and dirty gist here https://gist.github.com/martinberoiz/1ab5f6ec4a81680517ad2d9bd2ab9f32

leliel12 commented 3 years ago

The forloop can be inside a joblib parallel environment. Also another aproach is to add a color=True or cchek the output of the ndim function.

El jue., 22 de oct. de 2020 14:25, Martin Beroiz notifications@github.com escribió:

For registration is probably better to use Y channel in YUV colorspace, or average of RGB.

Quick and dirty gist here https://gist.github.com/martinberoiz/1ab5f6ec4a81680517ad2d9bd2ab9f32

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/toros-astro/astroalign/issues/57, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACJAASJGDRJSMOK2RN5DR3SMBTHVANCNFSM4S3P7BMA .

martinberoiz commented 3 years ago

I like checking for ndim but it assumes it's a numpy array. I think this should be added to find_transform which already accepts either an iterable of (x,y) pairs or a numpy array.

The input is getting more complicated to parse, but I think it's still manageable.

This also relates to #55 but if batch_register eventually calls find_transform then we only have to modify it there once.

Regarding the joblib parallel it may be an overkill, since the loop is 3 items long.

martinberoiz commented 3 years ago

Following @leliel12 suggestion, I think we should follow scikit-image's convention on which axis contains color channel info.

The convention seems to be that the trailing axis is the one for channel. Images loaded with pillow (PIL) also behave this way.

The only concern is for data cubes, or collection of images in different filters, that may be created this way:

>>> data_cube = np.array([data_g, data_r, data_i, data_z])
>>> data_cube.shape
(4, 256, 256)

Then the "channel" is the leading axis. Also astropy FITS data cube seem to put the spectral index at the front as well.

A compromise could be adding an argument channel_axis=-1 that user can change to 0. I'm reluctant because of the argument pollution but I don't see a better option.