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

Discrete Fourier transform registration (subpixel translation correction) #231

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

romainFr
Copy link
Contributor

@romainFr romainFr commented Dec 4, 2014

Something I needed at some point that might be useful to more people. It's taken from Guizar & al (Manuel Guizar-Sicairos, Samuel T. Thurman, and James R. Fienup, "Efficient subpixel image registration algorithms," Opt. Lett. 33, 156-158 (2008)) and (very) inspired by the matlab code provided by the authors.

Function subpixelshift(img,rowShift,colShift) translates an image by the given amount. dftReg(imgser,[ref,ufac,align]) performs the registration of imgser to a reference ref (by default the first frame of imgser). Either returns an array of registration parameters (by default), or the registered image (if align==true). usfac is the upsampling factor (10 by default). Finally alignFromDft performs the registration given an array of registration parameters.

This doesn't work with color images for now.

As a side-note, this would also work for rotations by transforming the image to polar coordinates beforehand.

> using Images, TestImages
> img = testimage("mandril_gray");
> img2 = subpixelshift(img,40.3,30.7);
> dftReg(img2,ref=img,ufac=10)
       1x3 Array{Float64,2}:
       0.332617  -40.3  -30.7

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 8226447 on romainFr:master into 480bca3 on timholy:master.

@timholy
Copy link
Member

timholy commented Dec 5, 2014

Potentially quite cool. But I deliberately haven't read through the code yet, because of license concerns: the Matlab code you linked to doesn't seem to come with a license. Unless you can get the authors to apply an MIT or BSD license to their work, I don't think I can accept this in Images.

@romainFr
Copy link
Contributor Author

romainFr commented Dec 8, 2014

On hold. I contacted the authors, and adding a license -- after some code modifications -- is part of their plans in a not too far future.

@jianghaizhu
Copy link

Has the license issue been solved yet?

@romainFr
Copy link
Contributor Author

romainFr commented Dec 4, 2015

No, the matlab code is still without license... The alternative would be to recode from the description in the paper (not translating their code). As a first step we can add simple phase correlation (without the subpixel part). I'll try to do it when I get a chance.

@rsrock
Copy link
Collaborator

rsrock commented Dec 4, 2015

I don't think you can do it. By looking at the Matlab code, you're effectively "tainted". Someone else will have to pick it up.

@jianghaizhu
Copy link

I sent an email to the senior author of the paper and asked for the clarification of the license for the Matlab code. He told me that he doesn't know anything about Matlab licensing, but pointed me to a Python version, which has a modified BSD license. I guess this can be merged to master now?

@timholy
Copy link
Member

timholy commented Dec 9, 2015

Is the author of the python code the same as the author of the matlab code? From a legal perspective, it doesn't really matter if there is other code out there based on the same paper; what matters is the license of whatever code was used as the foundation for this work.

Someone could start from scratch and implement something based on the python code, if the matlab license situation does not resolve.

@jianghaizhu
Copy link

Just looked at the python code. It stated that it was ported from the Matlab code. I don't know who the author of the python code is. But the senior author of the original paper believes the license for the python code is fine.

@bjarthur
Copy link
Collaborator

upon my urging, the original matlab code is now BSD licensed by the author of the manuscript describing the algorithm:

http://ch.mathworks.com/matlabcentral/fileexchange/18401-efficient-subpixel-image-registration-by-cross-correlation

so i think we can go ahead and merge this.

@romainFr
Copy link
Contributor Author

As my understanding is that Images.jl is really more for primitives I reorganized the code and put it together as a small package here :

https://github.com/romainFr/subpixelRegistration.jl

The changes -- compared to the original version -- allow to run the registration on arrays of arbitrary size (for example if one wants to register image volumes over time). As far as my testing goes, it works with Images or Arrays.

@timholy
Copy link
Member

timholy commented Feb 4, 2017

Image registration is a big topic, and I confess I'm sort of inclined to make it a separate package. I see that's what @romainFr has done. Seem OK to others? Perhaps we could host it on JuliaImages, just so it's easier to find?

@bjarthur
Copy link
Collaborator

bjarthur commented Feb 6, 2017

+1 for making subPixelRegistration easier to find by hosting on JuliaImages

@ashwani-rathee
Copy link
Member

I doubt we are ever going to merge this, can we close this PR?

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

Successfully merging this pull request may close these issues.

None yet

7 participants