I2 Lensdistort (I, K, Varargin) : Function
I2 Lensdistort (I, K, Varargin) : Function
I2 Lensdistort (I, K, Varargin) : Function
s2 = s2 * brcor;
u = reshape(ut,size(xi)) + center(1);
v = reshape(vt,size(yi)) + center(2);
tmap_B = cat(3,u,v);
resamp = makeresampler(p.Results.interpolation, p.Results.padmethod);
I3 = tformarray(I,[],resamp,[2 1],[1 2],[],tmap_B,255);
end
%-------------------------------------------------------------------------
% Nested function that creates a scaling parameter based on the
% 'bordertype' selected
function x = bordercorrect(r,s,k,center, R)
if k < 0
if strcmp(p.Results.bordertype, 'fit')
x = r(1)/s(1);
end
if strcmp(p.Results.bordertype,'crop')
x = 1/(1 + k*(min(center)/R)^2);
end
elseif k > 0
if strcmp(p.Results.bordertype, 'fit')
x = 1/(1 + k*(min(center)/R)^2);
end
if strcmp(p.Results.bordertype, 'crop')
x = r(1)/s(1);
end
end
end
%-------------------------------------------------------------------------
% Nested function that pics the model type to be used
function s = distortfun(r,k,fcnum)
switch fcnum
case(1)
s = r.*(1./(1+k.*r));
case(2)
s = r.*(1./(1+k.*(r.^2)));
case(3)
s = r.*(1+k.*r);
case(4)
s = r.*(1+k.*(r.^2));
end
end
end