script1
clear
close all
load tform
load filelist
k1 = 1;
file1 = files{k1};
rgb1 = imread(file1);
imshow(rgb1);
zoom on
Warning: Image is too big to fit on screen; displaying at 25%
in1 = false;
if in1
tpts1 = ginput(2);
end
if in1
tpts2 = ginput(2)
tpts1 = [tpts1; tpts2];
save tpts1 k1 tpts1
else
load tpts1
end
imshow(rgb1);
x = tpts1(:,1);
y = tpts1(:,2);
kv1 = [x(2)-x(1),y(2)-y(1)];
kv1 = kv1/norm(kv1);
kv2 = [x(4)-x(3),y(4)-y(3)];
kv2 = kv2/norm(kv2);
q = [0 3000];
hold on
plot(x(1)+kv1(1)*q,y(1)+kv1(2)*q,'b');
plot(x(3)+kv2(1)*q,y(3)+kv2(2)*q,'g');
plot(x(1:2),y(1:2),'b','LineWidth',2);
plot(x(3:4),y(3:4),'g','LineWidth',2);
hold off
Warning: Image is too big to fit on screen; displaying at 25%
[x, y] = transformPointsForward(tf, tpts1(:,1),tpts1(:,2));
x = x/20/12;
y = y/20/12;
[x y]
plot(x(1:4),y(1:4),'yo');
axis ij
axis equal
grid
hold on
plot(x(1:2),y(1:2),'b','LineWidth',2);
plot(x(3:4),y(3:4),'g','LineWidth',2);
hold off
kv1 = [x(2)-x(1) y(2)-y(1)];
kv2 = [x(4)-x(3) y(4)-y(3)];
kv1 = kv1/norm(kv1);
kv2 = kv2/norm(kv2);
phi1 = atan2(kv1(2),kv1(1))*180/pi
phi2 = atan2(kv2(2),kv2(1))*180/pi
theta = phi2 - phi1
D = det([kv1; kv2]);
theta = asin(D)*180/pi;
fprintf('theta %g deg\n',theta);
ans =
-4.0855 -2.0873
-4.0731 -10.943
1.8436 2.0409
1.8393 -3.6267
phi1 =
-89.919
phi2 =
-90.044
theta =
-0.1243
theta -0.124299 deg
rgbw1 = imwarp(rgb1,tf,'OutputView',ref);
imshow(rgbw1);
[x, y] = transform_to_warp(tf,ref,tpts1(:,1),tpts1(:,2));
hold on
plot(x(1:2),y(1:2),'b','LineWidth',2);
plot(x(3:4),y(3:4),'g','LineWidth',2);
plot(x,y,'yo');
hold off
k2 = 4;
file2 = files{k2};
rgb2 = imread(file2);
rgbw2 = imwarp(rgb2,tf,'OutputView',ref);
imshow(rgb2);
in2 = false;
if in2
tpts1 = ginput(2);
end
if in2
tpts2 = ginput(2)
tpts2 = [tpts1; tpts2];
save tpts2 k2 tpts2
end
if in2
tpts3 = ginput(2)
tpts2 = [tpts2; tpts3];
save tpts2 k2 tpts2
else
load tpts2
end
imshow(rgb2);
hold on
plot(tpts2(1:2,1),tpts2(1:2,2),'b','LineWidth',2);
plot(tpts2(3:4,1),tpts2(3:4,2),'g','LineWidth',2);
plot(tpts2(5:6,1),tpts2(5:6,2),'m','LineWidth',2);
plot(tpts2(:,1),tpts2(:,2),'yo');
hold off
[x, y] = transformPointsForward(tf, tpts2(:,1),tpts2(:,2));
x = x/20/12;
y = y/20/12;
[x y]
plot(x(1:4),y(1:4),'yo');
axis ij
axis equal
grid
hold on
plot(x(1:2),y(1:2),'b','LineWidth',2);
plot(x(3:4),y(3:4),'g','LineWidth',2);
hold off
kv1 = [x(2)-x(1) y(2)-y(1)];
kv2 = [x(4)-x(3) y(4)-y(3)];
kv1 = kv1/norm(kv1);
kv2 = kv2/norm(kv2);
phi1 = atan2(kv1(2),kv1(1))*180/pi
phi2 = atan2(kv2(2),kv2(1))*180/pi
theta = phi2 - phi1
D = det([kv1; kv2]);
theta = asin(D)*180/pi;
fprintf('theta %g deg\n',theta);
ans =
-4.64 -2.8807
-5.1954 -15.392
1.9517 3.1018
1.9527 1.9133
687.06 16680
70.762 7879.9
phi1 =
-92.542
phi2 =
-89.949
theta =
2.5927
theta 2.59271 deg
close all
imshow(rgbw2);
[x, y] = transform_to_warp(tf,ref,tpts2(:,1),tpts2(:,2));
hold on
plot(x(1:2),y(1:2),'b','LineWidth',2);
plot(x(3:4),y(3:4),'g','LineWidth',2);
plot(x(5:6),y(5:6),'m','LineWidth',2);
plot(x,y,'yo');
hold off
Warning: Image is too big to fit on screen; displaying at 50%
imageSize = [1600 800];
xWorldLimits = [-10400 10400];
yWorldLimits = [-20000 600];
ref2 = imref2d(imageSize,xWorldLimits,yWorldLimits);
ref2
rgbx = imwarp(rgb2,tf,'OutputView',ref2);
imshow(rgbx)
[x, y] = transform_to_warp(tf,ref2,tpts2(:,1),tpts2(:,2))
hold on
plot(x(1:2),y(1:2),'b','LineWidth',2);
plot(x(3:4),y(3:4),'g','LineWidth',2);
plot(x(5:6),y(5:6),'m','LineWidth',2);
plot(x,y,'yo');
hold off
ref2 =
imref2d with properties:
XWorldLimits: [-10400 10400]
YWorldLimits: [-20000 600]
ImageSize: [1600 800]
PixelExtentInWorldX: 26
PixelExtentInWorldY: 12.875
ImageExtentInWorldX: 20800
ImageExtentInWorldY: 20600
XIntrinsicLimits: [0.5 800.5]
YIntrinsicLimits: [0.5 1600.5]
x =
357.67
352.54
418.52
418.53
6742.6
1053.7
y =
1500.2
1267
1611.7
1589.6
3.1249e+05
1.4844e+05