我正在尝试在Matlab中实现这种图像配准算法:使用转角响应进行基于FFT的图像配准,我对如何获得正确的旋转角度存在一些问题。
这是我要实现的算法:
1)确定源图像和目标图像的转角响应,然后将其零填充,以使图像尺寸为×,其中= 2,从而≥max((),())。
2)对源图像和目标图像的角响应计算正向快速傅立叶变换,并拍摄快速傅立叶变换的幅值图像。
3)将高通滤波器乘以快速傅立叶变换的幅度图像。
4)将笛卡尔坐标中的傅立叶幅度谱映射到极坐标。
这里是我的问题 5)将相位相关技术应用于两幅图像的对数极谱,以确定比例因子和旋转角度。 / p>
6)将计算出的比例因子和旋转角度应用于目标图像,并再次执行相位相关以检测平移
我已经实现了算法的第4步,而我遇到的问题在第5步。
我使用xcorr2()对两个矩阵进行互相关,然后找到最大值,该值将成为我的旋转角度,但是我没有获得正确的旋转角度,而我认为是造成此问题的另一件事是数据的类型是复数而不是double(fft()函数返回复数double)
%LOAD images
ref = imread('reference_image.jpg');
rec = imread('image_to_be_registred.jpg');
%Cast the images to double
i1 = double(ref);
i2 = double(rec);
%Zero Pad the source image
i2 = padarray(i2,[1 1],0,'both');
%Apply Fast Fourrier Transform to both of the two images
i1 = fft(i1);
i2 = fft(i2);
%Apply High pass filter to the two images
i1 = HighPassFilter(i1);
i2 = HighPassFilter(i2);
%Calculate polar-coordinates of the two images
polar_i1 = calculate_polar_coord(i1);
polar_i2 = calculate_polar_coord(i2);
%Cross-correlate the two matrices
theta_correlation = xcorr2(polar_i1(:,:,1),polar_i2(:,:,1));
%Get the max value of the cross-correlation result
max_theta = max(max(angle(theta_correlation)));
%Rotate the image to image to be registred using the max value
img_rotated = imrotate(rec, max_theta*180);
%Show the rotated image
imshow(img_rotated);
期望角度接近3.8,但是我得到的值为0.3681。