资源简介
图像有效地亚像素配准方法,利用相位相关法求取像素级位移,再用矩阵傅里叶变换求取亚像素位移,用matlab编写的代码。
代码片段和文件信息
function [output Greg] = dftregistration(buf1ftbuf2ftusfac)
% function [output Greg] = dftregistration(buf1ftbuf2ftusfac);
% Efficient subpixel image registration by crosscorrelation. This code
% gives the same precision as the FFT upsampled cross correlation in a
% small fraction of the computation time and with reduced memory
% requirements. It obtains an initial estimate of the crosscorrelation peak
% by an FFT and then refines the shift estimation by upsampling the DFT
% only in a small neighborhood of that estimate by means of a
% matrix-multiply DFT. With this procedure all the image points are used to
% compute the upsampled crosscorrelation.
% Manuel Guizar - Dec 13 2007
% Portions of this code were taken from code written by Ann M. Kowalczyk
% and James R. Fienup.
% J.R. Fienup and A.M. Kowalczyk “Phase retrieval for a complex-valued
% object by using a low-resolution image“ J. Opt. Soc. Am. A 7 450-458
% (1990).
% Citation for this algorithm:
% Manuel Guizar-Sicairos Samuel T. Thurman and James R. Fienup
% “Efficient subpixel image registration algorithms“ Opt. Lett. 33
% 156-158 (2008).
% Inputs
% buf1ft Fourier transform of reference image
% DC in (11) [DO NOT FFTSHIFT]
% buf2ft Fourier transform of image to register
% DC in (11) [DO NOT FFTSHIFT]
% usfac Upsampling factor (integer). Images will be registered to
% within 1/usfac of a pixel. For example usfac = 20 means the
% images will be registered within 1/20 of a pixel. (default = 1)
% Outputs
% output = [errordiffphasenet_row_shiftnet_col_shift]
% error Translation invariant normalized RMS error between f and g
% diffphase Global phase difference between the two images (should be
% zero if images are non-negative).
% net_row_shift net_col_shift Pixel shifts between images
% Greg (Optional) Fourier transform of registered version of buf2ft
% the global phase difference is compensated for.
% Default usfac to 1
if exist(‘usfac‘)~=1 usfac=1; end
% Compute error for no pixel shift
if usfac == 0
CCmax = sum(sum(buf1ft.*conj(buf2ft)));
rfzero = sum(abs(buf1ft(:)).^2);
rgzero = sum(abs(buf2ft(:)).^2);
error = 1.0 - CCmax.*conj(CCmax)/(rgzero*rfzero);
error = sqrt(abs(error));
diffphase=atan2(imag(CCmax)real(CCmax));
output=[errordiffphase];
% Whole-pixel shift - Compute crosscorrelation by an IFFT and locate the
% peak
elseif usfac == 1
[mn]=size(buf1ft);
CC = ifft2(buf1ft.*conj(buf2ft));
[max1loc1] = max(CC);
[max2loc2] = max(max1);
rloc=loc1(loc2);
cloc=loc2;
CCmax=CC(rloccloc);
rfzero = sum(abs(buf1ft(:)).^2)/(m*n);
rgzero = sum(abs(buf2ft(:)).^2)/(m*n);
error = 1.0 - CCmax.*conj(CCmax)/(rgzero(11)*rfzero(11));
error = sqrt(abs(error));
diffphase=atan2(imag(CCmax)real(CCmax));
md
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 520978 2008-06-17 12:52 12.pdf
文件 253267 2008-06-17 12:51 9.pdf
文件 225070 2008-06-17 09:58 943D5A95-BDB9-137E-CC1957D25CE710E6_148843.pdf
文件 8234 2008-01-18 10:13 dftregistration.m
文件 4859 2008-01-18 10:02 efficient_subpixel_registration.m
文件 239 2008-06-16 23:12 efficient_subpixel_registration.txt
文件 12737 2008-01-18 10:10 html\efficient_subpixel_registration.html
文件 2956 2008-01-18 10:10 html\efficient_subpixel_registration.png
文件 140383 2008-01-18 10:10 html\efficient_subpixel_registration_01.png
文件 84395 2008-01-18 10:10 html\efficient_subpixel_registration_02.png
文件 9216 2008-01-18 10:11 html\Thumbs.db
文件 1407 2008-06-17 10:01 translate.htm
- 上一篇:jpegtbx1.4
- 下一篇:PSCAD与MATLAB的交互
评论
共有 条评论