shiftImage.m 2.59 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function imTransformed = shiftImage(im, shifts, settings)
% SHIFTIMAGE applies geometrical shifts to a given image.
%
%    ``imTransformed = shiftImage(im, shifts, settings)``
%
% Other than the MATLAB-function circshift (or subpixel-accuracy versions of it), this function
% does not assume periodic boundary conditions but applies a suitable padding before shifting.
%
% Parameters
% ----------
% im : numerical 2d-array
%     image to be shifted
% shifts : 2-tuple of floats
%     shifts to be applied to the image (in units of pixel-lengths) 
%
% Other Parameters 
% ---------------- 
% padVal : Default = 'replicate'
%     Determines the type of the padding that is applied to the input image prior to
%     shifting and rotating. Admissible choices are the same as in the
%     MATLAB-function padarray.
% interpMethod : Default = 'linear'
%     Interpolation-method used in the image-transformation. Admissible choices are
%     the same as in the MATLAB-function interp2.
%
% Returns 
% ------- 
% imTransformed : numerical 2d-array
%    the shifted image
%
% See also 
% ------- 
% functions.imageProcessing.alignment.shiftRotateMagnifyImage
% functions.imageProcessing.alignment.shiftRotateImage
% functions.imageProcessing.alignment.rotateImage
% functions.imageProcessing.alignment.magnifyImage
%
% Example
% -------
%
% .. code-block:: matlab
%
%     im = rand(100);
%     shifts = [14.7,-19.3];
%     imShifted = shiftImage(im, shifts);     
%
%     figure('name', 'Original image'); showImage(im);
%     figure('name', 'Shifted image'); showImage(imShifted);
%
%
% See also SHIFTROTATEMAGNIFYIMAGE, SHIFTROTATEIMAGE, ROTATEIMAGE, MAGNIFYIMAGE
    
% HoloTomoToolbox
% Copyright (C) 2019  Institut fuer Roentgenphysik, Universitaet Goettingen
%
% This program 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.
%
% This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.

69
70
71
72
if nargin == 0
    imTransformed = rmfield(shiftRotateMagnifyImage, 'invertTransform');
    return
end
73
if nargin < 3
74
    settings = struct;
75
76
77
78
79
80
end
settings.invertTransform = false;
imTransformed = shiftRotateMagnifyImage(im, shifts, [], [], settings);

end