dh2 (directed homography)
clear
close all
filename = 'script5c.jpg';
rgb = imread(filename);
imshow(rgb);
thetad = atan(23/3)*180/pi
vi = [1 0 0];
theta = thetad*pi/180;
vk = [0 sin(theta) cos(theta)];
vj = cross(vk,vi);
R = [vi; vj; vk];
f = 879.2;
pt = [320 320+ 300*sin(theta)];
KK = [ f 0 320; 0 f 320; 0 0 1];
T1 = R/KK;
newcp = h2e(T1*e2h(pt'));
M = [300 0 0; 0 300 0; 0 0 1]*[eye(2,2) -newcp ; 0 0 1];
T = M*T1;
tf = projective2d(T');
NW = 400;
imageSize = [800 800];
xWorldLimits = [-NW NW];
yWorldLimits = [-NW NW];
RA = imref2d(imageSize,xWorldLimits,yWorldLimits);
[out, RB] = imwarp(rgb,tf,'OutputView',RA);
imshow(out);
thetad =
82.5686
Warning: Image is too big to fit on screen;
displaying at 67%
N = 800;
set(gcf,'Position',[100 100 N N]);
set(gca,'Position',[0 0 1 1]);
f = getframe(gcf);
filename = 'dh2.jpg';
imwrite(f.cdata,filename);