-
Notifications
You must be signed in to change notification settings - Fork 2
/
2D-Image-Coordinates-Before.m
102 lines (102 loc) · 5.79 KB
/
2D-Image-Coordinates-Before.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
format short g
clc; clear all; close all;
% GIVEN DATA FOR LEFT AND RIGHT IMAGES
line_offL=+002946.00;sample_offL=+002675.00;lat_offL=+15.78280000;long_offL=+032.50710000;H_offL=+0394.000;
line_scaL=+002947.00;sample_scaL=+002676.00;lat_scaL=+00.02680000;long_scaL=+000.02510000;H_scaL=+0064.000;
line_offR=+003002.00;sample_offR=+002678.00;lat_offR=+15.78230000;long_offR=+032.50710000;H_offR=+0394.000;
line_scaR=+003002.00;sample_scaR=+002679.00;lat_scaR=+00.02730000;long_scaR=+000.02510000;H_scaR=+0064.000;
% LOAD GROUND CONTROL POINTS, IMAGE COORDINATES, AND RPCS
Obs = load('I:\Tamer\IKONOS\WGS84_Obse.txt'); % Observed Ground Coordinates.
MIC_L = load('I:\Tamer\IKONOS\MIC_L.txt'); % Measured Image Coordinates (Left).
MIC_R = load('I:\Tamer\IKONOS\MIC_R.txt'); % Measured Image Coordinates (Right).
C = load('I:\Tamer\IKONOS\Coeff.txt'); % Polynomial Coefficients.
N = length(Obs);
% NORMALIZATION FOR CONTROL POINTS
for i = 1 : N;
XL(i)=(Obs(i,2)-long_offL)/long_scaL;
YL(i)=(Obs(i,3)-lat_offL)/lat_scaL;
ZL(i)=(Obs(i,4)-H_offL)/H_scaL;
XR(i)=(Obs(i,2)-long_offR)/long_scaR;
YR(i)=(Obs(i,3)-lat_offR)/lat_scaR;
ZR(i)=(Obs(i,4)-H_offR)/H_scaR;
end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i)*YR(i)*ZR(i)+C(20,7)*ZR(i)*ZR(i)*ZR(i);
P4R(i)= C(1,8)+C(2,8)*XR(i)+C(3,8)*YR(i)+C(4,8)*ZR(i)+C(5,8)*XR(i)*YR(i)+...
C(6,8)*XR(i)*ZR(i)+C(7,8)*YR(i)*ZR(i)+C(8,8)*XR(i)*XR(i)+C(9,8)*YR(i)*YR(i)+...
C(10,8)*ZR(i)*ZR(i)+C(11,8)*XR(i)*YR(i)*ZR(i)+C(12,8)*XR(i)*XR(i)*XR(i)+C(13,8)*XR(i)*YR(i)*YR(i)+...
C(14,8)*XR(i)*ZR(i)*ZR(i)+C(15,8)*YR(i)*XR(i)*XR(i)+C(16,8)*YR(i)*YR(i)*YR(i)+C(17,8)*YR(i)*ZR(i)*ZR(i)+...
C(18,8)*XR(i)*XR(i)*ZR(i)+C(19,8)*YR(i)*YR(i)*ZR(i)+C(20,8)*ZR(i)*ZR(i)*ZR(i);
ln_L(i)=P1L(i)/P2L(i);
sn_L(i)=P3L(i)/P4L(i);
ln_R(i)=P1R(i)/P2R(i);
sn_R(i)=P3R(i)/P4R(i);
lDL(i)=(ln_L(i)*line_scaL)+line_offL;
sDL(i)=(sn_L(i)*sample_scaL)+sample_offL;
lDR(i)=(ln_R(i)*line_scaR)+line_offR;
sDR(i)=(sn_R(i)*sample_scaR)+sample_offR;
xDL(i)= MIC_L(i,2);
yDL(i)= MIC_L(i,3);
xDR(i)= MIC_R(i,2);
yDR(i)= MIC_R(i,3);
residual_yL(i) = (lDL(i) - yDL(i));
residual_xL(i) = (sDL(i) - xDL(i));
residual_yR(i) = (lDR(i) - yDR(i));
residual_xR(i) = (sDR(i) - xDR(i));
end
rxL = residual_xL';
ryL = residual_yL';
rxR = residual_xR';
ryR = residual_yR';
Resid = [rxL ryL rxR ryR];
RMSE_xL = (sqrt(sum(rxL'*rxL)/N));
RMSE_yL = (sqrt(sum(ryL'*ryL)/N));
RMSE_xR = (sqrt(sum(rxR'*rxR)/N));
RMSE_yR = (sqrt(sum(ryR'*ryR)/N));
RMSE = [RMSE_xL RMSE_yL RMSE_xR RMSE_yR]
figure;
quiver(MIC_R(:,2),MIC_R(:,3),rxR,ryR,'b','AutoScaleFactor',1);
hold on;
plot(MIC_R(:,2),MIC_R(:,3),'rx')
xlabel 'Sample (Pixel)', ylabel 'Line (Pixel)';
legend('Bias','ICs');
sxL = std(rxL);
syL = std(ryL);
sxR = std(rxR);
syR = std(ryR);
stan_de = [sxL syL sxR syR];