# Help with Image Stitching using Phase Correlation

6 messages
Open this post in threaded view
|

## Help with Image Stitching using Phase Correlation

 I am trying to learn about image stitching using cross correlation. Let say that I have two images A and B that I am trying to stitch. (you may need to switch to fixed width font to make these little text pictures work for you) -------      ------- |     |      |     | |  A  | and  |  B  | |     |      |     | -------      ------- Considering a shift just in the X dimension, the maximum shift which would still have a smallest overlap would be if B is shifted (slightly less than) the width of A to the right of A, or if B is shifted (slightly less than) the width of B to the left of A.            --------------            |     ||     |            |  A  ||  B  |            |     ||     |            --------------     --------------     |     ||     |     |  B  ||  A  |     |     ||     |     -------------- Let A and B both be exactly 512 by 512 pixels, that is of equal size and a power of 2 in both X and Y, so the images will need no padding when their FHT transform is created. This means that the FFT(A) and FFT(B) are also exactly 512x512. Further, using the FFDMath to calculate the inverse transform of the Correlation between FFT(A) and FFT(B) results in an image also of 512x512. But, since in our case the shift could be anywhere in the range from -511 to + 511, how can this be represented by the location of maxima drawn from an image with an X and Y size of 512? I have tried padding both my images to a size which is the next larger power of two, and  for my test data this does resolve the larger shifts, however this hits performance dramatically and I suspect is not the best way to handle this. Anyone able to point me in the right direction? I understand enough of the mathematics to know that my grasp on the underlying maths of Fourier transforms is very rudimentary and shaky, so I am looking for practical advice on how to utilise the plugins in core ImageJ.jar to best solve the problem of aligning two images. Many thanks — Michael Ellis -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Open this post in threaded view
|

## Re: Help with Image Stitching using Phase Correlation

 Good day Michael! "This means that the FFT(A) and FFT(B) are also exactly 512x512. Further, using the FFDMath to calculate the inverse transform of the Correlation between FFT(A) and FFT(B) results in an image also of 512x512." That's to the point and a problem with this implementation of the correlation function. "I have tried padding both my images to a size which is the next larger power of two, and  for my test data this does resolve the larger shifts, however this hits performance dramatically and I suspect is not the best way to handle this." That's the way to go but could please tell us what "hits performance dramatically" exactly means for you. Of course, a factor 4 in area is a lot but CPUs are fast these days... Computation here of the correlation function of two 1024x1024 images is performed in the blink of an eye. Padding is done by         "Image >> Adjust >> Canvas Size..." run("Canvas Size...", "width=1024 height=1024 position=Center zero"); Regards Herbie ::::::::::::::::::::::::::::::::::::::::::: Am 26.08.17 um 12:53 schrieb Michael Ellis: > I am trying to learn about image stitching using cross correlation. > > Let say that I have two images A and B that I am trying to stitch. > > (you may need to switch to fixed width font to make these little text pictures work for you) > > -------      ------- > |     |      |     | > |  A  | and  |  B  | > |     |      |     | > -------      ------- > > Considering a shift just in the X dimension, the maximum shift which would still have a smallest overlap would be if B is shifted (slightly less than) the width of A to the right of A, > or if B is shifted (slightly less than) the width of B to the left of A. > >             -------------- >             |     ||     | >             |  A  ||  B  | >             |     ||     | >             -------------- >      -------------- >      |     ||     | >      |  B  ||  A  | >      |     ||     | >      -------------- > > Let A and B both be exactly 512 by 512 pixels, that is of equal size and a power of 2 in both X and Y, so the images will need no padding when their FHT transform is created. > > This means that the FFT(A) and FFT(B) are also exactly 512x512. Further, using the FFDMath to calculate the inverse transform of the Correlation between FFT(A) and FFT(B) results in an image also of 512x512. > > But, since in our case the shift could be anywhere in the range from -511 to + 511, how can this be represented by the location of maxima drawn from an image with an X and Y size of 512? > > I have tried padding both my images to a size which is the next larger power of two, and  for my test data this does resolve the larger shifts, however this hits performance dramatically and I suspect is not the best way to handle this. > > Anyone able to point me in the right direction? I understand enough of the mathematics to know that my grasp on the underlying maths of Fourier transforms is very rudimentary and shaky, so I am looking for practical advice on how to utilise the plugins in core ImageJ.jar to best solve the problem of aligning two images. > > Many thanks — Michael Ellis > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Open this post in threaded view
|

## Re: Help with Image Stitching using Phase Correlation

Open this post in threaded view
|