Contents

phase_corr

im1 = mean(double(imread('A.png'))/255.0, 3);
im2 = mean(double(imread('A_t_40_30.png'))/255.0, 3);

[dx, dy] = phase_corr(im1, im2)
dx =

   -40


dy =

   -30

log_polar

im = mean(double(imread('ph.jpg'))/255.0, 3);
cx = 257; cy = 257; H = 250;
[im_transformed, t, phi, delta_t, delta_phi] = log_polar(im, cx, cy, H);
figure;
imagesc(im_transformed); colormap gray; axis equal
disp([min(t(:)), max(t(:)), min(phi(:)), max(phi(:))])
delta_t, delta_phi
         0    5.5215    0.0040    6.2832


delta_t =

    0.0040


delta_phi =

    0.0040

fourier_mellin

[M, N] = size(im);
tx = 50; ty = -15;
s = 1.25;
phi_rot = 45/180*pi;
% scale, rotate, translate:
[x, y] = meshgrid(1:N, 1:M);
[x_, y_] = translation(x, y, -tx, -ty);
[x_, y_] = scaling(x_, y_, 1/s, cx, cy);
[x_, y_] = rotation(x_, y_, -phi_rot, cx, cy);
im_rst = interp2(im, x_, y_, 'linear', 0);

figure();
imagesc(im); colormap gray; axis equal; title('im1')
figure();
imagesc(im_rst); colormap gray; axis equal; title('im2')

[cx, cy] = ffcenter(im);
H = size(im, 2) - cx - 3;

[s_estimated, phi_estimated] = fourier_mellin(im, im_rst, H)

% undo rotation and scale:
[x, y] = meshgrid(1:N, 1:M);
[x_, y_] = rotation(x, y, -phi_estimated, cx, cy);
[x_, y_] = scaling(x_, y_, s_estimated, cx, cy);
scale_rot_undone = interp2(im_rst, x_, y_, 'linear', 0);
figure();
imagesc(scale_rot_undone); colormap gray; axis equal;
title('im2 / scale, rotation undone')

% also estimate translation:
[sx, sy] = phase_corr(im, scale_rot_undone);
[x_, y_] = translation(x, y, -sx, -sy);
all_undone = interp2(scale_rot_undone, x_, y_, 'linear', 0);

figure();
imagesc(all_undone); colormap gray; axis equal;
title('im2 / scale, rotation, translation undone')
figure();
imagesc(im - all_undone); axis equal
title('difference w.r.t. im1')
s_estimated =

    1.2488


phi_estimated =

   -0.7859