quatrope / astroalign

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

ValueError and TypeError #56

Closed kacperbudny closed 3 years ago

kacperbudny commented 3 years ago

Hi. This library seems like just what I needed, but I can't get it to work on the photos I have.

Here's the issue: I load my images using cv2 (imread), so they are numpy arrays, as the documentation requests. But whenever I try to register these photos, I get this:

Traceback (most recent call last): File "...\astroalign.py", line 243, in find_transform source_controlp = _find_sources( File "...\astroalign.py", line 465, in _find_sources bkg = sep.Background(image) File "sep.pyx", line 396, in sep.Background.cinit File "sep.pyx", line 304, in sep._parse_arrays File "sep.pyx", line 232, in sep._check_array_get_dims ValueError: array must be 2-d

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 13, in transf, (source_list, target_list) = aa.find_transform(source, target) File "...\astroalign.py", line 247, in find_transform raise TypeError("Input type for source not supported.") TypeError: Input type for source not supported.

Am I doing something wrong?

leliel12 commented 3 years ago

Can you provide the image, or the numpy.array of the image, or at least you can provide the numpy.ndim(arr) output

martinberoiz commented 3 years ago

Hi @kacperbudny,

Beautiful image. It seems that the problem comes because it's a color image with 3 channels RGB. Currently astroalign only works with grayscale images (1 channel). I suggest picking one channel to find the transformation and then apply it to all the color channels.

This situation is common enough that we should probably include it in the next release. I will create an issue for the feature addition. In the meantime, let me create a gist with a recipe to deal with color images.

martinberoiz commented 3 years ago

something like this (not fully tested)

https://gist.github.com/martinberoiz/1ab5f6ec4a81680517ad2d9bd2ab9f32

I hope it helps.

martinberoiz commented 3 years ago

Hello,

I just released version 2.3.1 that adds support for color images. Please try again with new version and if you find any problem, you can open a new issue.

In the meantime I'll go ahead and close this issue.