No BSD License  

Highlights from
Efficient subpixel image registration by cross-correlation


4.9 | 28 ratings Rate this file 217 Downloads (last 30 days) File Size: 232 KB File ID: #18401

Efficient subpixel image registration by cross-correlation



21 Jan 2008 (Updated )

Registers two images (2-D rigid translation) within a fraction of a pixel specified by the user.

| Watch this File

File Information

Registers two images (2-D rigid translation) within a fraction of a pixel specified by the user. Instead of computing a zero-padded FFT (fast Fourier transform), this code uses selective upsampling by a matrix-multiply DFT (discrete FT) to dramatically reduce computation time and memory without sacrificing accuracy. With this procedure all the image points are used to compute the upsampled cross-correlation in a very small neighborhood around its peak. This algorithm is referred to as the single-step DFT algorithm in [1].

[1] Manuel Guizar-Sicairos, Samuel T. Thurman, and James R. Fienup, "Efficient subpixel image registration algorithms," Opt. Lett. 33, 156-158 (2008).

Please refer to the attached HTML for more details and a sample implementation.


This file inspired Stxm Data Analysis Script Collection Stack Lab, Stxm Spectromicroscopy Particle Analysis Routines, and Automatic 2d Rigid Body Image Registration.

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (48)
15 Jun 2014 Song Ming


20 Mar 2014 Sung Soo Kim


15 Jan 2014 Jonathan  
23 May 2013 Tom Wright

This is great. I made a few minor modifications to limit translation to only the x or y axis. Do you have this under version control anywhere?

20 Feb 2013 chen


20 Feb 2013 chen  
10 Feb 2013 Tom

Simply fantastic. So much more efficient and accurate for 2D translation than everything else I tried. The subpixel resolution is a bonus as well.

02 Aug 2012 Rob Campbell

It would be really useful if the code could do rotation as well.

26 Jun 2012 Denis

Is this only for shifts? can we register rotation as well?

16 May 2012 Ahmed Fasih  
20 Mar 2012 Jony  
24 Nov 2011 Daniel

wow, that one is really fast and seems to be robust. thanks a lot!

24 Jun 2011 Greg

Great algorithm, it has helped so much with my image stabilization project

24 Jun 2011 Greg  
15 Jun 2011 Rui

works very well. i'm amazed with the speed and accuracy of the algorithm.

thanks manuel!

15 Jun 2011 Rui  
28 Jan 2011 Michael

do images need to be square - as in 2^n for the fft shift to work properly?

16 Nov 2010 Aron Sceidt

can this be applied to colour images in some way?

08 Sep 2010 Yan G  
01 Sep 2010 Nafise b

ThX, I did it, hopefully some one answer me.

01 Sep 2010 Sean de

Nafise, post your situation/goals, your images, and what you've tried to the newsgroup ( From there people can help you.

01 Sep 2010 Nafise b

ThX sean,
I did it, but it is not true, because my image has black regions, and it determines that part with zero pad part.

01 Sep 2010 Sean de

Nafise b, pad your smaller image with zeros so that it is the same size.

01 Sep 2010 Nafise b

Thanks for your code.
I want to work with your code, but I have a problem with it.
In fact, my images are 2 blocks which don't have the same size, and I want to find the best place for small block in the big block.
Something that I got from your code is for your code 2 images have same size.
What should I do now, if I want to use your code for subpixel image registration?

Best regards,

03 Aug 2010 Yu Yinghuai

Great work! Question about the codes " kernr=exp((-i*2*pi/(nr*usfac))*( [0:nor-1].' - roff )*( ifftshift([0:nr-1]) - floor(nr/2) )) " :
Why does the vector [0:nr-1] need be ifftshift ?

26 Jul 2010 Alex

Re: my comment on 14 Jul 2010:
I owe an apology. It seems at the point when I wrote my comment I was feeding an accidentally reshaped array into the code. Because of the artifacts in my data, it caused a wrap around artifact in the output (and the registration worked in one axis only, but I didn't notice because that happened to be the axis containing almost all of the shifts).

Great code - no resrvations! Thanks much.


18 Jul 2010 Phillip

Great code. Any plans to extend to cover angular rotations and scale shifts as well? (e.g. Fourier Mellin transform)

14 Jul 2010 Alex

Code registers images very well. Question about the supplementary output:
output = [error,diffphase,net_row_shift,net_col_shift]

On my data it seems that some times the row_shift variable seems to 'wrap around' in away that is not intuitive. For example though the data is only 512 pixels wide, I get row shifts of -512.3, 1024.3 etc which I assume are actually very small pixel shifts that have a somewhat random multiple of the image size thown on for fun.

02 Mar 2010 Rob Campbell

Wonderful. Fast and accurate.

15 Dec 2009 Sean

Is there a way to extend this to 3D CT images?

Thank you!

16 Oct 2009 Raymond Cheng

Thanks for your sharing.

12 Oct 2009 su su

I want to register the pair of visible and theraml images with this one, but I don't get the required resutl.

28 Jul 2009 Eric

Tremendously useful! Thanks very much.

27 Jul 2009 Lucas Koorneef

Works right out of the box. Thanks for sharing !

05 May 2009 Tobias Henn

Great Work - fast and accurate!!!

20 Apr 2009 Manuel Guizar

This method is equally robust to noise as the standard FFT upsampling, but much faster. It computes the same upsampled cross correlation but only in a small neighborhood around the peak.

20 Apr 2009 Manuel Guizar

Thanks to everyone for the positive comments! The published M-file is intended to get the user started with the syntax and explain what the code does. For technical documentation please refer to the reference above [1] and references within.

26 Feb 2009 Chaos

forgot to rate. wow this code is brutally fast and accurate, if you define a ROI even faster. this code needs some kind of award. how much faster would it be if it was compiled in to a mex?

26 Feb 2009 Chaos

works but i had to re=write code for UINT16 images, very fast and accurate. why are you using double? do you really need that accuracy in the dft?

26 Feb 2009 Chaos

works but i had to re=write code for UINT16 images, very fast and accurate.

23 Feb 2009 Robert Reed

Is this method less robust to noise than standard upsampling?

23 Feb 2009 Petter

Always nice to see a published .m, but the images tell us nothing. A zoomed in display, abs error or something would be more relevant than two identially looking images.

23 Feb 2009 Robert Reed

Elegant solution in simple understandable code + sound documentation.

27 Apr 2008 Zhi Zhang

Excellent Work!

03 Mar 2008 Jiang Jun

Thank you for you job, I will enjoy it.

12 Feb 2008 Matt Sochor

Very good and excellent documentation to get you started with the syntax. Great job and thanks for including the paper reference.

28 Jan 2008 Chris Cookson

did i mention it was easy to use?

28 Jan 2008 Chris Cookson

easy to use, extremely fast, and easy to use. amazing work.

Contact us