1 | function wI = imwbackward(varargin) |
---|
2 | % IMWBACKWARD Image backward warping |
---|
3 | % J = IMWBACKWARD(I, X, Y) returns the values of image I at |
---|
4 | % locations X,Y. X and Y are real matrices of arbitrary but |
---|
5 | % identical dimensions. I is bilinearly interpolated between |
---|
6 | % samples and extended with NaNs to the whole real plane. |
---|
7 | % |
---|
8 | % By default, IMWBACKWARD assumes that the image I uses the standard |
---|
9 | % coordinate system (see WARP_OVERVIEW). IMWBACKWARD(XR,YR,I,X,Y) |
---|
10 | % assumes instead that I is defined on a rectangular grid |
---|
11 | % specified by the vectors XR and YR. |
---|
12 | % |
---|
13 | % ALGORITHM. What IMWBACKWARD is less general than the MATLAB native |
---|
14 | % function INTERP2, but significantly faster. |
---|
15 | % |
---|
16 | % See also WARP_OVERVIEW, IMWFORWARD, INTERP2. |
---|
17 | |
---|
18 | if nargin < 5 |
---|
19 | I = varargin{1} ; |
---|
20 | [M,N,K] = size(I) ; |
---|
21 | xr = 1:N ; |
---|
22 | yr = 1:M ; |
---|
23 | varargin = { varargin{2:end} } ; |
---|
24 | else |
---|
25 | xr = varargin{1} ; |
---|
26 | yr = varargin{2} ; |
---|
27 | I = varargin{3} ; |
---|
28 | [M,N,K] = size(I) ; |
---|
29 | varargin = { varargin{4:end} } ; |
---|
30 | end |
---|
31 | |
---|
32 | if K == 1 |
---|
33 | wI = imwbackwardmx(xr, yr, I, varargin{:}) ; |
---|
34 | else |
---|
35 | [M,N] = size(varargin{1}) ; |
---|
36 | wI = zeros(M,N,K) ; |
---|
37 | for k=1:K |
---|
38 | wI(:,:,k) = imwbackwardmx(xr, yr, squeeze(I(:,:,k)), varargin{:}) ; |
---|
39 | end |
---|
40 | end |
---|