-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathestimateC.m
130 lines (107 loc) · 2.59 KB
/
estimateC.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
function c =estimateC(J,I,dmap,Binf)
% TODO: add the forward scattering to this equation
%4 pixels por mm 4000 per meter. It goes to the exponential as ln of
%4000
size(I)
size(J)
%size(Binf)
% Operate the equation
%Ed = J.*exp(-distance*c_mat);
%Jf = conv2(Ed,psf(10,averageCossine,c),'same');
%xi = 1203;
%xf = xi+50;
xi= 1;
xf = size(I,1);
% yi=1;
% yf = size(I,2);
% yi= 1500;
% yf = yi+50;
% tmap = zeros(size(I));
% for i=1:size(I,1)
% for j=1:size(J,2)
% B = I(i,j) - Binf(i,j);
%
% C = J(i,j) - Binf(i,j);
%
% if C == 0
% C = 0.0000001;
% end
%
% if B/C < 0.000000001
% tmap(i,j) = 0.00001;
% elseif B/C > 500
% tmap(i,j) = 500;
%
% else
% tmap(i,j) = B/C;
% end
%
%
% end
% end
tmap = zeros(xf-xi +1,1);
for i=xi:xf
B = I(i) - Binf;
C = J(i) - Binf;
tmap(i-xi+1) = B/C;
% tmap(i-xi+1,j-yi+1) = -log(tmap(i-xi+1,j-yi+1));
% tmap(i-xi+1,j-yi+1) = real(tmap(i-xi+1,j-yi+1) );
% tmap(i-xi+1,j-yi+1) = tmap(i-xi+1,j-yi+1)*8.2940496401;
% tmap(i-xi+1,j-yi+1) = tmap(i-xi+1,j-yi+1)*dmap(i,j);
end
%figure;
%imwrite(tmap
%imshowdepth(tmap);
% tmap = (B./C);
%tmap = B./C;
% Multiply by the distance.
%tmap = 1- tmap;
%max(max(tmap))
%tmap = tmap./max(max(tmap));
%c = tmap(posx,posy);
%figure
%imshow(tmap);
%
dmap = dmap(xi:xf);
tmap = log(tmap);
tmap = real(tmap);
% Considering the resolution of 4 pixel by millimiters and the distance
% being considered in
tmap= tmap*8.2940496401;
tmap = tmap./dmap;
% %figure
% %imshow(tmap);
% %dmax = max(max(tmap));
% z = tmap(:);
% x = [1:length(z)]';
% y = [1:length(z)]';
%
% % sf = fit( [ y x], z, 'poly11');
%
%
% %daltMap = tmap./dmax;
% %c =
% %cmap = tmap./distance;
%
% %imshow(daltMap);
%
%
%
% %figure
% %imshow(cmap);
%
%
% %t = sum(sum(cmap))/(size(cmap,1)*size(cmap,2));
%
%
% % vectorize tmap
% turb=0;
% for i=1:length(r)
% turb
% turb = turb + tmap(r(i),c(i));
%
% end
c = sum(tmap)/size(tmap,1);
%c = sum(sum(tmap))/(size(tmap,1)*size(tmap,2));
% c = turb/length(r);
end