From f618466c25d43f3bae9e40920273bf77de1e1149 Mon Sep 17 00:00:00 2001 From: leochanj105 Date: Mon, 19 Oct 2020 23:09:30 -0400 Subject: initial sd-vbs initial sd-vbs add sd-vbs sd-vbs --- .../toolbox/toolbox_basic/affine/m_interp4.m | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 SD-VBS/common/toolbox/toolbox_basic/affine/m_interp4.m (limited to 'SD-VBS/common/toolbox/toolbox_basic/affine/m_interp4.m') diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/m_interp4.m b/SD-VBS/common/toolbox/toolbox_basic/affine/m_interp4.m new file mode 100755 index 0000000..314f140 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/m_interp4.m @@ -0,0 +1,49 @@ +function [F,mask] = m_interp4(z,s,t) +%INTERP4 2-D bilinear data interpolation. +% ZI = INTERP4(Z,XI,YI) assumes X = 1:N and Y = 1:M, where +% [M,N] = SIZE(Z). +% +% Copyright (c) 1984-93 by The MathWorks, Inc. +% Clay M. Thompson 4-26-91, revised 7-3-91, 3-22-93 by CMT. +% +% modified to + + +[nrows,ncols] = size(z); + + +if any(size(z)<[3 3]), error('Z must be at least 3-by-3.'); end +if size(s)~=size(t), error('XI and YI must be the same size.'); end + +% Check for out of range values of s and set to 1 +sout = find((s<1)|(s>ncols)); +if length(sout)>0, s(sout) = ones(size(sout)); end + +% Check for out of range values of t and set to 1 +tout = find((t<1)|(t>nrows)); +if length(tout)>0, t(tout) = ones(size(tout)); end + +% Matrix element indexing +ndx = floor(t)+floor(s-1)*nrows; + +% Compute intepolation parameters, check for boundary value. +d = find(s==ncols); +s(:) = (s - floor(s)); +if length(d)>0, s(d) = s(d)+1; ndx(d) = ndx(d)-nrows; end + +% Compute intepolation parameters, check for boundary value. +d = find(t==nrows); +t(:) = (t - floor(t)); +if length(d)>0, t(d) = t(d)+1; ndx(d) = ndx(d)-1; end +d = []; + +% Now interpolate, reuse u and v to save memory. +F = ( z(ndx).*(1-t) + z(ndx+1).*t ).*(1-s) + ... + ( z(ndx+nrows).*(1-t) + z(ndx+(nrows+1)).*t ).*s; + +mask = ones(size(z)); + +% Now set out of range values to zeros. +if length(sout)>0, F(sout) = zeros(size(sout));mask(sout)=zeros(size(sout));end +if length(tout)>0, F(tout) = zeros(size(tout));mask(tout)=zeros(size(tout));end + -- cgit v1.2.2