Warning
This page is located in archive. Go to the latest version of this course pages. Go the latest version of this page.

Image Registration 2

In this task, we will learn how to register two images which differ by translation and rotation. The registration can be split to two parts:

  1. Estimating the transformation between the two images, and
  2. transforming one image such that it becomes close to (“looks like”) the other image.

For estimating the transformation between the two images, we will employ phase correlation [1] and polar transform [2] of the Fourier amplitude, as will be further described. For transforming an image, we will implement bilinear interpolation [3].

Part 2

ZIP package for 2nd week: zip

In the second week, we will be dealing with estimating transformation between two images. We will learn how register two images which differ by translation and rotation. Below you can see an example. The two images were obtained by taking two photos of a scene by a mobile phone camera at two different times and using different orientation of the camera.

image 1 image 2 image 2, registered difference between im1 and registered im2

1 Learn how to use the provided function phase_corr.m. This function estimates translation between two images by a method described in [1]. The method is very similar to deconvolution which you have used before.

image 1 image 2 image 2, registered

Take image1 (A.png) and image2 (A_t_40_30.png) and use the function [sx, sy] = phase_corr(image1, image2) to estimate translation needed for image2 to look the same as image1. In this case the function should output 'sx=-30, sy=-40'. Use your methods (including your implemeted function bilinear.m to transform image2 such that it gets registered to image1, as in above example. Note we do not display the difference between image1 and the transformed image2 as this results in a blank image (the registration is perfect in this case.)

Now we will learn how to estimate rotation between two images.

2a To estimate rotation between two images, we will employ the fact that magnitude spectra of images differing by translation and rotation differ only by rotation around the spectrum center:

image 1 image 2
spectrum of image1 spectrum of image2

We can see that the spectrum of image2 is rotated the same amount as the image itself is rotated with respect to image1. Note that the spectra are displayed as log(10+abs(FFTIM)) where FFTIM is the FFT of an image. This monadic transformation is also further used for comparing the two spectra and for estimating the rotation between them (you may experiment with other monadic transformations of the FFT magnitudes.) Also note that the provided function ffcenter may be used for getting the center of the spectrum after applying fftshift to it.

2b Implement the function polar_transform.m which converts and image to polar coordinates as it is described in [2]. This will enable us to estimate rotation between spectra as the translation in polar coordinates. An example of polar transform for an ordinary image:

im1_polar.jpg
image1 image1 transformed to polar coordinates, cx = cy = 257, H = 255. To see the image, click the link.

But we will use the polar transform not on images themselves but on their magnitude spectra:

2c Use the function phase_corr.m to estimate translation between the two spectra. From the translation in y-coordinate, compute the correspoding rotation and for image2 and rotate it so that it matches im1 in rotation:

image2 image2, rotated by estimated angle

Note that the estimation of rotation angle will be ambiguous - both value X and value X+pi (180deg) will be equally good. Use the one which is closer to 0 degrees (e.g. the one for which the rotation of image is smaller.)

2d Use the function phase_corr.m again, to estimate translation between the image just obtained and image1. This will provide you with the solution for registering image2 to image1 from the very first image on this page.

When you are done, upload a zip file to brute which will contain:
  • bilinear.m,
  • polar_transform.m,
  • register.m

Function im2_registered = register(im1, im2) should transform im2 such that it becomes 'close' to im1; when subtracted from im1 there should be little difference. Automatic results visualization in the submission system is set up. You may compare your results to ours.

[1] slide 7 https://dcgi.fel.cvut.cz/home/sykorad/dzo/slides/dzo-l08.pdf

[2] slide 2 https://dcgi.fel.cvut.cz/home/sykorad/dzo/slides/dzo-l09.pdf

[3] slides 10, 11 https://dcgi.fel.cvut.cz/home/sykorad/dzo/slides/dzo-l07.pdf

courses/b4m33dzo/labs/6_reg1.txt · Last modified: 2023/05/14 19:24 by drbohlav