Home > SuperSegger > Internal > intShiftIm.m

intShiftIm

PURPOSE ^

intShiftIm: shifts image 'imIn' by the parameters in 'out'

SYNOPSIS ^

function imOut = intShiftIm( imIn, out )

DESCRIPTION ^

 intShiftIm: shifts image 'imIn' by the parameters in 'out'
 out is produced by intAlignIm( imA, imB, precision ).

 INPUT :
   imIn : input image
   out : output of intAlignIm,
       where the 3rd element is the row_shift and 4th and col_shift

 OUTPUT :
   imOut : shifted image

 Copyright (C) 2016 Wiggins Lab 
 Written by Paul Wiggins.
 University of Washington, 2016
 This file is part of SuperSegger.
 
 SuperSegger is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 SuperSegger is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function imOut = intShiftIm( imIn, out )
0002 % intShiftIm: shifts image 'imIn' by the parameters in 'out'
0003 % out is produced by intAlignIm( imA, imB, precision ).
0004 %
0005 % INPUT :
0006 %   imIn : input image
0007 %   out : output of intAlignIm,
0008 %       where the 3rd element is the row_shift and 4th and col_shift
0009 %
0010 % OUTPUT :
0011 %   imOut : shifted image
0012 %
0013 % Copyright (C) 2016 Wiggins Lab
0014 % Written by Paul Wiggins.
0015 % University of Washington, 2016
0016 % This file is part of SuperSegger.
0017 %
0018 % SuperSegger is free software: you can redistribute it and/or modify
0019 % it under the terms of the GNU General Public License as published by
0020 % the Free Software Foundation, either version 3 of the License, or
0021 % (at your option) any later version.
0022 %
0023 % SuperSegger is distributed in the hope that it will be useful,
0024 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0025 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0026 % GNU General Public License for more details.
0027 %
0028 % You should have received a copy of the GNU General Public License
0029 % along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.
0030 
0031 
0032 fftB = fft2(imIn); % fourier transform
0033 
0034 deltar = out(3); % net_row_shift in subpixel
0035 deltac = out(4); % net_col_shift in subpixel
0036 
0037 phase = 0;
0038 [nr,nc] = size(imIn); % nr : num of rows, nc : num of columns
0039 Nr = ifftshift(-fix(nr/2):ceil(nr/2)-1); % swaps the left and right halves
0040 Nc = ifftshift(-fix(nc/2):ceil(nc/2)-1);
0041 [Nc,Nr] = meshgrid(Nc,Nr);
0042 
0043 fftB = fftB.*exp(1i*2*pi*(deltar*Nr/nr+deltac*Nc/nc));
0044 
0045 imOut  = (real(ifft2(fftB).*exp(-1i*phase)));
0046 
0047 end

Generated on Thu 19-Jan-2017 13:55:21 by m2html © 2005