Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indexing issue in register_image #24

Open
bcaplins opened this issue Sep 13, 2019 · 1 comment
Open

indexing issue in register_image #24

bcaplins opened this issue Sep 13, 2019 · 1 comment

Comments

@bcaplins
Copy link

I've gotten a lot of mileage from the matlab code, and I was delighted to see it was ported to python. Thanks!

I'm a bit new to python still and I'm not up for a fork/pull request (or whatever the right term is) at this moment. But I thought I'd share what I believe to be a bug in register_images

im1 and im2 are both arrays of shape (1, 26021)
if I execute
dx,dy = image_registration.register_images(im1,im2,usfac=4,maxoff=150)
then I get an error:

CClarge[round(mlarge/4.):round(mlarge/4.*3),round(nlarge/4.):round(nlarge/4.*3)] = fftshift(buf1ft) * conj(fftshift(buf2ft));

ValueError: could not broadcast input array from shape (1,26021) into shape (2,26022)

If I use input arrays of size (1, 26022) (i.e. even number) instead then it works beautifully.

I am guessing that the change from matlab's fix to pythons round is the issue.

I changed that line to:
CClarge[int(m-np.fix(m/2)):int(m+np.fix((m-1)/2)+1),int(n-np.fix(n/2)):int(n+np.fix((n-1)/2)+1)] = fftshift(buf1ft) * conj(fftshift(buf2ft));

And it worked without error. Though I have not assessed if that change introduces any errors in the algorithm.

@keflavich
Copy link
Owner

You're probably right about the source of the error. Thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants