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.

To estimate 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. To transform an image, we will implement bilinear interpolation [3].

Part 1

In the first part, we will be dealing with geometric image transformations. You can start by downloading the homework template.

Let us take two images, A.png and A_t_40_30.png:

The second image differs from the first one in that it is shifted. The translation is (tx = 30 pixels, ty = 40 pixels). The horizontal axis, x, goes to the right, and the vertical axis, y, goes down.

How can we transform the first image to look the same as the second image? A simple example is provided in the script hw_img_reg_1.m in the “Translation by integer pixel values” section:

im = imread('A.png'); 
[M, N] = size(im);
 
blank_val = 128; 
 
tx = 30; 
ty = 40; 
 
im_trans = zeros(M, N); 
 
in_range = @(x, y) x>=1 && x<=N && y>=1 && y<=M;
 
for x = 1:N 
    for y = 1:M 
        [xs, ys] = translation(x, y, -tx, -ty);
        if in_range(xs, ys)
            im_trans(y, x) = im(ys, xs); 
        else
            im_trans(y, x) = blank_val;
        end
    end
end

For more interesting geometric transformations, we will need an interpolation that can extract values for points that lie between pixels. Your first task is to implement the bilinear interpolation in bilinear.m and use it for image translation in the “Translation with bilinear interpolation” section.

Remember the image indexing convention - the pixel with coordinates (x, y) means x-th pixel from left, y-th pixel from top. The image matrix is then indexed as image(y, x) (first indexing the row, then the column). On the other hand the bilinear.m function accepts the coordinates in the original order bilinear(im, x, y, blank_val).

The ideal way of interpolation would be reconstruction of the image (as continuous function) from the pixels (samples) using sinc function. The bilinear kernel used in this homework is basically a very efficient approximation of sinc.

The second task is implementing rotation around a center (cx, cy) by angle phi in rotation.m. You can test the rotation in combination with bilinear interpolation in the hw_img_reg_1.m script.

Rotation of a point (x, y) around a center (cx, cy) by angle Φ can be written as:

Finally, you can combine both the translation and rotation. The coordinates of the first image were first rotated and then translated using the same parameters as above. Observe the order of transformations. The result looks as follows (image A_rt.png):

In the first part, you should implement functions:
  • bilinear.m
  • rotation.m

and learn how to combine the transformations with interpolation in hw_img_reg_1.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_reg.txt · Last modified: 2023/12/05 18:13 by panekvo1