function [ row_offset, col_offset ] = mComputeGlobalOffset( reference_image, offset_image ) fx = fft2( reference_image ); fy = fft2( offset_image ); correlation = real( ifft2( conj( fx ).*fy ) ); [ row_offset, col_offset ] = find( correlation == max( max( correlation ) ) ); row_offset = mod( row_offset - 1, size( reference_image, 1 ) ); col_offset = mod( col_offset - 1, size( reference_image, 2 ) );