Skip to content

Commit e708c2b

Browse files
NautecNautec
Nautec
authored and
Nautec
committed
Added entropy code.
1 parent ade2a74 commit e708c2b

File tree

11 files changed

+409
-34
lines changed

11 files changed

+409
-34
lines changed

EvaluateTurbidity/estimateC.m

+5-2
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,12 @@
8686
dmap = dmap(xi:xf);
8787
tmap = log(tmap);
8888
tmap = real(tmap);
89-
% tmap= tmap*8.2940496401;
89+
% Considering the resolution of 4 pixel by millimiters and the distance
90+
% being considered in
91+
92+
tmap= tmap*8.2940496401;
9093

91-
tmap = tmap.*dmap;
94+
tmap = tmap./dmap;
9295
% %figure
9396
% %imshow(tmap);
9497
% %dmax = max(max(tmap));

Features/CenSurE/SubFunctions/CenSur_buildResponseLayer.m

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545

4646
%CenResp = IntegralImage_HexaIntegral(r - l + 1, c - b, 2 * l - 1, w,img) - IntegralImage_HexaIntegral(r - l + 1, c - fix(l / 2), 2 * l - 1, l, img);
4747

48+
figure;
49+
imshow(mat2gray(CenResp));
50+
4851
% Normalise the filter responses with respect to their size
4952

5053
% Take also the harris responses for each pixel. This will be tested

Features/Hessian/Hessian.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
%
66
sigma = 1.8;
77
k=7;
8-
borderless= k*sigma;
8+
borderless= 2*k*sigma;
99
%
1010
% derivative masks
1111
% s_D = 0.7*sigma;

Features/Laplacian/laplacian.m

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
%
55
sigma = 1.2;
66
k=7;
7-
%
7+
borderless= 2*k*sigma;
88
% derivative masks
99
% s_D = 0.7*sigma;
1010
% x = -round(3*s_D):round(3*s_D);
@@ -50,11 +50,11 @@
5050
% imshow(Ixy);
5151
H = abs(Ixx + Iyy);
5252

53-
C = 3*k;
54-
H((size(im,1)-C):size(im,1),:) = 0;
55-
H(:,(size(im,2)-C):size(im,2)) = 0;
56-
H(1:C,:) = 0;
57-
H(:,1:C) = 0;
53+
%C = 3*k;
54+
H((size(im,1)-borderless):size(im,1),:) = 0;
55+
H(:,(size(im,2)-borderless):size(im,2)) = 0;
56+
H(1:borderless,:) = 0;
57+
H(:,1:borderless) = 0;
5858
% figure
5959
% title('Hessian');
6060
% imshow(H);

Misc/geraPlotF1.m

+8-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@
1919
x = x./max(x);
2020
x= round(x.*100)/100;
2121

22+
e=1;
23+
N=100;
24+
25+
26+
eval(sprintf('harris%de%dp1',N))
27+
2228
figure;
2329
%pt = plot(x,harvec,'b-d',x,hesvec,'r-*',x,lapvec,'y-o',x,harcolor,'g-s',x,harcolorb,'g-.x',x,harlapvec,'k-s',x,heslapvec,'c-o',x,siftvec,'m-x',x,surfvec,'c-.*');
24-
pt = plot(x,harvec,'b-d',x,hesvec,'b-*',x,lapvec,'b-o',x,siftvec,'m--x',x,surfvec,'m--*',x,cenpoly,'g-d',x,censtar,'g-s',x,kazeg1,'r-.d',x,kazeg2,'r-.o',x,kazeg3,'r-.*');
30+
pt = plot(x,harvec,'b-d',x,hesvec,'b-*',x,lapvec,'b-o',x,siftvec,'m--x',x,surfvec,'m--*',x,harlap,'m--*',x,heslap,'m--*',x,cenpoly,'g-d',x,censtar,'g-s',x,kazeg1,'r-.d',x,kazeg2,'r-.o',x,kazeg3,'r-.*');
2531
%set(gca,'XScale','log');
2632
set(gca, 'XGrid','on');
2733
set(gca, 'YGrid','on');
28-
legend1=legend('Harris','Hessian','Laplacian','DoG','FastHes','CenSurPoly','CenSurStar','Kaze G1','Kaze G2','Kaze G3');
34+
legend1=legend('Harris','Hessian','Laplacian','DoG','FastHes','Harris-Laplace','Hessian-Laplace','CenSurPoly','CenSurStar','Kaze G1','Kaze G2','Kaze G3');
2935
set(legend1,'FontSize',40,'FontName','Courier 10 Pitch');
3036

3137
title('Photo 1','FontSize',50,'FontName','Courier 10 Pitch');

TestFeatures/geraFeatures.m

+28-19
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@
2323
%imshow(im);
2424
%hold on
2525
%drawcircles(points);
26-
%hold off
27-
rmpath Harris
26+
%hold off
27+
%imshow(im);
28+
%hold on
29+
% drawcircles(points);
30+
%hold off
31+
%rmpath Harris
2832

2933
elseif strcmp(algoritmo,'kazeg1')
3034
%addpath Kaze
@@ -54,10 +58,10 @@
5458
if length(points) > 5
5559
points =especialnms(im,points,N,delta,points(:,3));
5660
end
57-
% imshow(im);
58-
% hold on
59-
% drawcircles(points);
60-
% hold off
61+
% imshow(im);
62+
% hold on
63+
% drawcircles(points);
64+
% hold off
6165

6266
%rmpath Kaze
6367

@@ -164,7 +168,7 @@
164168
% drawcircles(points)
165169
% length(points)
166170

167-
points=removeBorderPoints(points,im);
171+
% points=removeBorderPoints(points,im);
168172

169173
if length(points) > 5
170174
points = especialnms(im,points,N,delta,points(:,4));
@@ -176,7 +180,7 @@
176180
% points=int32(points);
177181
% points=points';
178182
% points = especialnms(im,points,N,delta);
179-
% figure;
183+
% figure;
180184
% imshow(im);
181185
% hold on
182186
% drawcircles(points)
@@ -222,7 +226,10 @@
222226
points = Hessian(im,N,delta);
223227

224228

225-
229+
%imshow(im);
230+
%hold on
231+
%drawcircles(points);
232+
% hold off
226233

227234
%figure;
228235
%imshow(im);
@@ -245,17 +252,19 @@
245252

246253
elseif strcmp(algoritmo,'laplacian')
247254
%im = rgb2gray(im);
248-
addpath Laplacian
255+
% addpath Laplacian
249256
points = laplacian(im,N,delta);
250257

251258
%if length(points) > 5
252259
% points = especialnms(im,points,N,delta);
253-
%end
254-
% figure;
255-
% imshow(im);
256-
% hold on
257-
% drawcircles(points)
258-
rmpath Laplacian
260+
% %end
261+
%figure;
262+
%imshow(im);
263+
%hold on
264+
%drawcircles(points)
265+
266+
267+
%rmpath Laplacian
259268

260269
elseif strcmp(algoritmo,'sift')
261270

@@ -292,9 +301,9 @@
292301
end
293302

294303
figure;
295-
imshow(im);
296-
hold on
297-
drawcircles(points);
304+
imshow(im);
305+
hold on
306+
drawcircles(points);
298307

299308

300309
elseif strcmp(algoritmo,'iisift')

TestFeatures/geraRepeatVectorConst.m

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
% Just calculate the Repeatability region over a region that is constant.
22
%
33

4-
function repVec = geraRepeatVectorConst(detector,imvec,N,delta,epsilon,region)
4+
function repVec = geraRepeatVectorConst(detector,imvec,N,delta,epsilon,turbVec)
55

66

7+
8+
79
features0 = geraFeatures(imvec{1},detector,N,delta,1); % The first extracted features
810
%validFeatures0 = intersect(features0,region,'rows'); % the first intersected valid features with a constant region
911

@@ -13,8 +15,8 @@
1315
repVec(1) = N;
1416

1517
for i=2:length(imvec)
16-
17-
features= geraFeatures(imvec{i},detector,N,delta,1); % the subsequent image features
18+
turbVec(i)
19+
features= geraFeatures(imvec{i},detector,N,delta,turbVec(i-1)); % the subsequent image features
1820
if ~isempty(features)
1921
%validFeatures = intersect(features,region,'rows');
2022

computeEntropy.m

+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
function information=computeEntropy(points,Vnorm)
2+
3+
4+
global MemoPoints;
5+
6+
totalPoints = size(Vnorm,1)*size(Vnorm,2);
7+
8+
information = 0;
9+
%for each point
10+
11+
%MemoPoints
12+
13+
for i=1:length(points)
14+
15+
% Take a patch
16+
17+
%Vpatch = Vnorm(points(i,1)-1:points(i,1)+1,points(i,2)-1:points(i,2)+1,:);
18+
19+
entropyPatch =0;
20+
points=int32(points);
21+
size(points)
22+
%VpatchVec = reshape(Vpatch,size(Vpatch,1)*size(Vpatch,2), 4);
23+
24+
25+
%for j=1:length(VpatchVec)
26+
if(MemoPoints(points(i,1)-1,points(i,2)-1) == -1)
27+
28+
Vpoint = Vnorm(points(i,1)-1,points(i,2)-1,:);
29+
count = sum(sum(Vnorm(:,:,1) == Vpoint(1) & Vnorm(:,:,2) == Vpoint(2) & Vnorm(:,:,3) == Vpoint(3) & Vnorm(:,:,4) == Vpoint(4)));
30+
prob =count/totalPoints;
31+
32+
MemoPoints(points(i,1)-1,points(i,2)-1) = prob;
33+
entropyPatch = entropyPatch -prob*log(prob);
34+
else
35+
prob = MemoPoints(points(i,1)-1,points(i,2)-1);
36+
entropyPatch = entropyPatch -prob*log(prob);
37+
% 'memo'
38+
end
39+
40+
if(MemoPoints(points(i,1),points(i,2)-1) == -1)
41+
Vpoint = Vnorm(points(i,1),points(i,2)-1,:);
42+
count = sum(sum(Vnorm(:,:,1) == Vpoint(1) & Vnorm(:,:,2) == Vpoint(2) & Vnorm(:,:,3) == Vpoint(3) & Vnorm(:,:,4) == Vpoint(4)));
43+
prob =count/totalPoints;
44+
45+
MemoPoints(points(i,1),points(i,2)-1) = prob;
46+
entropyPatch = entropyPatch -prob*log(prob);
47+
else
48+
prob = MemoPoints(points(i,1),points(i,2)-1);
49+
entropyPatch = entropyPatch -prob*log(prob);
50+
%'memo'
51+
end
52+
53+
if(MemoPoints(points(i,1)+1,points(i,2)-1) == -1)
54+
Vpoint = Vnorm(points(i,1)+1,points(i,2)-1,:);
55+
count = sum(sum(Vnorm(:,:,1) == Vpoint(1) & Vnorm(:,:,2) == Vpoint(2) & Vnorm(:,:,3) == Vpoint(3) & Vnorm(:,:,4) == Vpoint(4)));
56+
prob =count/totalPoints;
57+
58+
MemoPoints(points(i,1)+1,points(i,2)-1) = prob;
59+
entropyPatch = entropyPatch -prob*log(prob);
60+
else
61+
prob = MemoPoints(points(i,1)+1,points(i,2)-1);
62+
entropyPatch = entropyPatch -prob*log(prob);
63+
% 'memo'
64+
end
65+
66+
67+
68+
if(MemoPoints(points(i,1)-1,points(i,2)) == -1)
69+
Vpoint = Vnorm(points(i,1)-1,points(i,2),:);
70+
count = sum(sum(Vnorm(:,:,1) == Vpoint(1) & Vnorm(:,:,2) == Vpoint(2) & Vnorm(:,:,3) == Vpoint(3) & Vnorm(:,:,4) == Vpoint(4)));
71+
prob =count/totalPoints;
72+
73+
MemoPoints(points(i,1)-1,points(i,2)) = prob;
74+
entropyPatch = entropyPatch -prob*log(prob);
75+
else
76+
prob = MemoPoints(points(i,1)-1,points(i,2));
77+
entropyPatch = entropyPatch -prob*log(prob);
78+
% 'memo'
79+
end
80+
81+
if(MemoPoints(points(i,1),points(i,2)) == -1)
82+
Vpoint = Vnorm(points(i,1),points(i,2),:);
83+
count = sum(sum(Vnorm(:,:,1) == Vpoint(1) & Vnorm(:,:,2) == Vpoint(2) & Vnorm(:,:,3) == Vpoint(3) & Vnorm(:,:,4) == Vpoint(4)));
84+
prob =count/totalPoints;
85+
86+
MemoPoints(points(i,1),points(i,2)) = prob;
87+
entropyPatch = entropyPatch -prob*log(prob);
88+
else
89+
prob = MemoPoints(points(i,1),points(i,2));
90+
entropyPatch = entropyPatch -prob*log(prob);
91+
% 'memo'
92+
end
93+
94+
if(MemoPoints(points(i,1)+1,points(i,2)) == -1)
95+
Vpoint = Vnorm(points(i,1)+1,points(i,2),:);
96+
count = sum(sum(Vnorm(:,:,1) == Vpoint(1) & Vnorm(:,:,2) == Vpoint(2) & Vnorm(:,:,3) == Vpoint(3) & Vnorm(:,:,4) == Vpoint(4)));
97+
prob =count/totalPoints;
98+
99+
MemoPoints(points(i,1)+1,points(i,2)) = prob;
100+
entropyPatch = entropyPatch -prob*log(prob);
101+
else
102+
prob = MemoPoints(points(i,1)+1,points(i,2));
103+
entropyPatch = entropyPatch -prob*log(prob);
104+
% 'memo'
105+
end
106+
107+
if(MemoPoints(points(i,1)-1,points(i,2)+1) == -1)
108+
Vpoint = Vnorm(points(i,1)-1,points(i,2)+1,:);
109+
count = sum(sum(Vnorm(:,:,1) == Vpoint(1) & Vnorm(:,:,2) == Vpoint(2) & Vnorm(:,:,3) == Vpoint(3) & Vnorm(:,:,4) == Vpoint(4)));
110+
prob =count/totalPoints;
111+
112+
MemoPoints(points(i,1)-1,points(i,2)+1) = prob;
113+
entropyPatch = entropyPatch -prob*log(prob);
114+
else
115+
prob = MemoPoints(points(i,1)-1,points(i,2)+1);
116+
entropyPatch = entropyPatch -prob*log(prob);
117+
% 'memo'
118+
end
119+
120+
121+
if(MemoPoints(points(i,1),points(i,2)+1) == -1)
122+
Vpoint = Vnorm(points(i,1),points(i,2)+1,:);
123+
count = sum(sum(Vnorm(:,:,1) == Vpoint(1) & Vnorm(:,:,2) == Vpoint(2) & Vnorm(:,:,3) == Vpoint(3) & Vnorm(:,:,4) == Vpoint(4)));
124+
prob =count/totalPoints;
125+
126+
MemoPoints(points(i,1),points(i,2)+1) = prob;
127+
entropyPatch = entropyPatch -prob*log(prob);
128+
else
129+
prob = MemoPoints(points(i,1),points(i,2)+1);
130+
entropyPatch = entropyPatch -prob*log(prob);
131+
% 'memo'
132+
end
133+
134+
135+
if(MemoPoints(points(i,1)+1,points(i,2)+1) == -1)
136+
Vpoint = Vnorm(points(i,1)+1,points(i,2)+1,:);
137+
count = sum(sum(Vnorm(:,:,1) == Vpoint(1) & Vnorm(:,:,2) == Vpoint(2) & Vnorm(:,:,3) == Vpoint(3) & Vnorm(:,:,4) == Vpoint(4)));
138+
prob =count/totalPoints;
139+
140+
MemoPoints(points(i,1)+1,points(i,2)+1) = prob;
141+
entropyPatch = entropyPatch -prob*log(prob);
142+
143+
144+
else
145+
prob = MemoPoints(points(i,1)+1,points(i,2)+1);
146+
entropyPatch = entropyPatch -prob*log(prob);
147+
% 'memo'
148+
end
149+
150+
151+
152+
153+
154+
%end
155+
156+
information = information + entropyPatch
157+
%else
158+
159+
end
160+
161+
% DO a memoization.
162+
163+
164+
end
165+
166+

0 commit comments

Comments
 (0)