-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathturbidityEst.m
91 lines (59 loc) · 1.41 KB
/
turbidityEst.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
function turb=turbidityEst(J,I,r,c)
%[A,I] = double(max(max(I)))./255;
%gauss = fspecial('gaussian',12);
%J = imfilter(J,gauss);
%I = imfilter(I,gauss);
% [posx posy] = Aest(I,15);
[H S I ] = rgb2hsv(I);
[H S J ] = rgb2hsv(J);
%J = double(J)./255;
%I = double(I)./255;
% A = I(posx(1),posy(1));
A = max(max(I));
%A = I(posx,posy);
%B = I - A;
%figure;
%imshow(B);
%C = J - A;
%figure;
%imshow(C)
for i=1:size(I,1)
for j=1:size(J,2)
B(i,j) = I(i,j) - A;
C(i,j) = J(i,j) - A;
tmap(i,j) = B(i,j)/C(i,j);
end
end
% tmap = (B./C);
%tmap = B./C;
%figure;
%imshow(tmap);
%tmap = 1- tmap;
%max(max(tmap))
%tmap = tmap./max(max(tmap));
%c = tmap(posx,posy);
%figure
%imshow(tmap);
%tmap
tmap = - log(tmap);
%figure
%imshow(tmap);
%dmax = max(max(tmap));
turb = 0;
% vectorize tmap
for i=1:length(r)
turb = turb + tmap(r(i),c(i));
end
turb
turb = turb/length(r);
%daltMap = tmap./dmax;
%c =
%cmap = tmap./distance;
%imshow(daltMap);
%figure
%imshow(cmap);
%t = sum(sum(cmap))/(size(cmap,1)*size(cmap,2));
%c = max(max(cmap));
%figure
%imshow(tmap);
end