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

In this task, we will learn how to register two images that differ by translation and rotation. The registration can be split into 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.

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

Part 2

In the second part, we will estimate the transformation between two images. We will learn how to 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 with a mobile phone camera at two different times and using different camera orientations.

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

1 First, 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. Look into the source file and try to understand the principle of the method (compare code with the lecture slides).

image 1 image 2 image 2, registered

You should implement the function register_translation.m. First, use the phase correlation to estimate the relative shift and then translate the second image to look the same as the first image. You should have the implementation of translation ready from the previous part of this homework so you can reuse it. You can test your implementation of register_translation in hw_img_reg_2.m on different inputs.

Our implementation of phase correlation just returns the index of the maximum pixel in the correlation map, so it is able to precisely estimate only translations by integer pixel values. You would have to implement more complex method for estimation with sub-pixel precision.

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

2a To estimate rotation between two images, we will employ the fact that the 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 by the same angle as the image itself is rotated relative 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 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 the image to polar coordinates as 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:

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 Implement function register_rotation.m. Use the function phase_corr.m to estimate translation between the two spectra. From the translation in y-coordinate, compute the corresponding angle for image2 and rotate it so that it matches the orientation of image1:

image2 image2, rotated by estimated angle

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

The phase correlation on the spectra in polar coordinates also returns a shift along the X-axis (radius), which can be used for relative image scale estimation. We omit scale in this homework for simplicity (all the testing image pairs have identical scales).

If the rotation registration is working for A and A_rt image pair, but not for more complex images, you can:

  1. Check the error reported by BRUTE on your bilinear.m implementation. The mistake is usually in indexing of the image (image(y,x)).
  2. Try to change the radius and angle sampling in polar_transform.m to r = linspace(0, H, M) and phi = linspace(0, 2*pi, N).

2d Implement register_full.m by using your implementations of register_rotation.m and register_translation.m. This will provide you with the solution for registering image2 to image1 from the first image on this page.

When you are done, upload a zip file to BRUTE with all your implemented functions from both parts:
  • bilinear.m
  • rotation.m
  • polar_transform.m
  • register_translation.m
  • register_rotation.m
  • register_full.m

[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/12/05 14:57 by panekvo1