Skip to content

Commit ade2a74

Browse files
NautecNautec
Nautec
authored and
Nautec
committedApr 15, 2015
Last version of gera features
1 parent 3b790ef commit ade2a74

File tree

10 files changed

+147
-70
lines changed

10 files changed

+147
-70
lines changed
 

‎EvaluateTurbidity/calculateIDTall.m

+9-9
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@
3131
Iim= imvec{1};
3232
distance = 0.58;
3333
dmapR = calculateDmap(Iim(:,:,1),distance);
34-
[I, spImage] = spAverageImage(imvec{1},128);
35-
% [dmap] = spAverageImageWSpImageGray(dmapR,spImage);
34+
[I, spImage] = spAverageImageGray(imvec{1},164);
35+
[dmap] = spAverageImageWSpImageGray(dmapR,spImage);
3636
for i=2:length(imvec)
37-
SDIvec = [ SDIvec ,100 * floor((1- ssim_index(rgb2gray(imvec{1}),rgb2gray(imvec{i})))*10000)/10000];
37+
%SDIvec = [ SDIvec ,100 * floor((1- ssim_index(rgb2gray(imvec{1}),rgb2gray(imvec{i})))*10000)/10000];
3838

3939
Binf = binfvec{i};
40-
BinfR(:,:,1) = imresize(Binf(:,:,1), size(Iim(:,:,1)));
41-
BinfR(:,:,2) = imresize(Binf(:,:,2), size(Iim(:,:,2)));
42-
BinfR(:,:,3) = imresize(Binf(:,:,3), size(Iim(:,:,3)));
43-
[Binf ] = spAverageImageWSpImage(BinfR,spImage);
40+
BinfR= imresize(Binf, size(Iim));
41+
%BinfR(:,:,2) = imresize(Binf(:,:,2), size(Iim(:,:,2)));
42+
%BinfR(:,:,3) = imresize(Binf(:,:,3), size(Iim(:,:,3)));
43+
[Binf ] = spAverageImageWSpImageGray(BinfR,spImage);
4444

4545

46-
% [J] = spAverageImageWSpImage(imvec{i}, spImage);
46+
[J] = spAverageImageWSpImageGray(imvec{i}, spImage);
4747

4848
%[J, spImage] = spAverageImage(imvec{i} ,96);
49-
x= [ x, estimateIDT(imvec{i},I,Binf,dmapR,i,spImage)];
49+
x= [ x, estimateIDT(J,I,Binf,dmap,i,spImage)];
5050

5151

5252
end

‎EvaluateTurbidity/estimateC.m

+4-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
tmap = zeros(xf-xi +1,1);
5858
for i=xi:xf
5959
B = I(i) - Binf;
60-
C = J(i);
60+
C = J(i) - Binf;
6161
tmap(i-xi+1) = B/C;
6262
% tmap(i-xi+1,j-yi+1) = -log(tmap(i-xi+1,j-yi+1));
6363
% tmap(i-xi+1,j-yi+1) = real(tmap(i-xi+1,j-yi+1) );
@@ -84,9 +84,10 @@
8484
%imshow(tmap);
8585
%
8686
dmap = dmap(xi:xf);
87-
tmap = - log(tmap);
87+
tmap = log(tmap);
8888
tmap = real(tmap);
89-
%tmap= tmap*8.2940496401;
89+
% tmap= tmap*8.2940496401;
90+
9091
tmap = tmap.*dmap;
9192
% %figure
9293
% %imshow(tmap);

‎EvaluateTurbidity/estimateIDT.m

+14-14
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
%[H S I ] = rgb2hsv(I);
88
%[H S J ] = rgb2hsv(J);
99
%Binf = double(rgb2gray(Binf))/255;
10-
Binf = double(Binf)/255;
10+
Binf = double(Binf);
1111
J = double(J);
1212
I = double(I);
1313

@@ -21,17 +21,17 @@
2121

2222

2323

24-
%Bvec = sort(Binf(:,1),'descend');
24+
Bvec = sort(Binf,'descend');
2525

26-
%BinfR = mean(Bvec(1:15))
26+
Binf = mean(Bvec(1:15))
2727

28-
%Bvec = sort(Binf(:,2),'descend');
28+
% Bvec = sort(Binf(:,2),'descend');
2929

30-
%BinfG = mean(Bvec(1:15))
30+
% BinfG = mean(Bvec(1:15))
3131

32-
%Bvec = sort(Binf(:,3),'descend');
32+
% Bvec = sort(Binf(:,3),'descend');
3333

34-
%BinfB = mean(Bvec(1:15))
34+
% BinfB = mean(Bvec(1:15))
3535

3636

3737

@@ -43,18 +43,18 @@
4343

4444

4545
%cR = solveCfun (double(J(:,:,1)),Binf(:,1),I(:,1),0.78,dmap,spImage)
46-
cR = estimateC(J(:,1),I(:,1),dmap,BinfR);
47-
fprintf('cR = %f',cR);
46+
idt = estimateC(J,I,dmap,Binf);
47+
fprintf('idt = %f',idt);
4848
%print(sprintf('%d_r',i),'-dpng');
4949
%close;
5050
%cG = solveCfun (double(J(:,:,2)),Binf(:,2),I(:,2),0.78,dmap,spImage)
51-
cG = estimateC(J(:,2),I(:,2),dmap,BinfG);
52-
fprintf('cG = %f',cG);
51+
% cG = estimateC(J(:,2),I(:,2),dmap,BinfG);
52+
% fprintf('cG = %f',cG);
5353
% print(sprintf('%d_g',i),'-dpng');
5454
%close;
5555
%cB = solveCfun (double(J(:,:,3)),Binf(:,3),I(:,3),0.78,dmap,spImage)
56-
cB = estimateC(J(:,3),I(:,3),dmap,BinfB);
57-
fprintf('cB = %f',cB);
56+
% cB = estimateC(J(:,3),I(:,3),dmap,BinfB);
57+
% fprintf('cB = %f',cB);
5858
% print(sprintf('%d_b',i),'-dpng');
5959
%close;
6060

@@ -94,6 +94,6 @@
9494
%
9595
%
9696
% idt = (idtR + idtG + idtB)/2;
97-
idt=(cR + cG + cB)/3;
97+
%idt=(cR + cG + cB)/3;
9898

9999
end

‎Features/vlfeat-0.9.18/toolbox/sift/vl_sift.c

+18-10
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ mexFunction(int nout, mxArray *out[],
344344
keys = vl_sift_get_keypoints (filt) ;
345345
nkeys = vl_sift_get_nkeypoints (filt) ;
346346
i = 0 ;
347-
347+
348348
if (verbose > 1) {
349349
printf ("vl_sift: detected %d (unoriented) keypoints\n", nkeys) ;
350350
}
@@ -358,9 +358,11 @@ mexFunction(int nout, mxArray *out[],
358358
int nangles ;
359359
VlSiftKeypoint ik ;
360360
VlSiftKeypoint const *k ;
361-
361+
362362
/* Obtain keypoint orientations ........................... */
363363
if (nikeys >= 0) {
364+
365+
364366
vl_sift_keypoint_init (filt, &ik,
365367
ikeys [4 * i + 1] - 1,
366368
ikeys [4 * i + 0] - 1,
@@ -371,7 +373,7 @@ mexFunction(int nout, mxArray *out[],
371373
}
372374

373375
k = &ik ;
374-
376+
375377
/* optionally compute orientations too */
376378
if (force_orientations) {
377379
nangles = vl_sift_calc_keypoint_orientations
@@ -381,6 +383,7 @@ mexFunction(int nout, mxArray *out[],
381383
nangles = 1 ;
382384
}
383385
} else {
386+
384387
k = keys + i ;
385388
nangles = vl_sift_calc_keypoint_orientations
386389
(filt, angles, k) ;
@@ -412,11 +415,16 @@ mexFunction(int nout, mxArray *out[],
412415

413416
/* Save back with MATLAB conventions. Notice tha the input
414417
* image was the transpose of the actual image. */
415-
frames [4 * nframes + 0] = k -> y + 1 ;
416-
frames [4 * nframes + 1] = k -> x + 1 ;
417-
frames [4 * nframes + 2] = k -> sigma ;
418-
frames [4 * nframes + 3] = VL_PI / 2 - angles [q] ;
419-
frames [4 * nframes + 4] = k -> score ;
418+
419+
// k -> score = 10;
420+
421+
//printf("%f \n",k -> y + 1);
422+
423+
frames [5 * nframes + 0] = k -> y + 1 ;
424+
frames [5 * nframes + 1] = k -> x + 1 ;
425+
frames [5 * nframes + 2] = k -> sigma ;
426+
frames [5 * nframes + 3] = VL_PI / 2 - angles [q] ;
427+
frames [5 * nframes + 4] = k -> score ;
420428

421429
if (nout > 1) {
422430
if (! floatDescriptors) {
@@ -456,9 +464,9 @@ mexFunction(int nout, mxArray *out[],
456464
(2, dims, mxDOUBLE_CLASS, mxREAL) ;
457465

458466
/* set array content to be the frames buffer */
459-
dims [0] = 4 ;
467+
dims [0] = 5 ;
460468
dims [1] = nframes ;
461-
mxSetPr (out[OUT_FRAMES], frames) ;
469+
mxSetPr (out[OUT_FRAMES], frames);
462470
mxSetDimensions (out[OUT_FRAMES], dims, 2) ;
463471

464472
if (nout > 1) {

‎Features/vlfeat-0.9.18/vl/sift.c

+12-5
Original file line numberDiff line numberDiff line change
@@ -1270,14 +1270,17 @@ vl_sift_detect (VlSiftFilt * f)
12701270
int y = f-> keys [i] .iy ;
12711271
int s = f-> keys [i]. is ;
12721272

1273+
12731274
double Dx=0,Dy=0,Ds=0,Dxx=0,Dyy=0,Dss=0,Dxy=0,Dxs=0,Dys=0 ;
12741275
double A [3*3], b [3] ;
12751276

12761277
int dx = 0 ;
12771278
int dy = 0 ;
12781279

12791280
int iter, i, j ;
1280-
1281+
printf("score \n");
1282+
1283+
12811284
for (iter = 0 ; iter < 5 ; ++iter) {
12821285

12831286
x += dx ;
@@ -1396,7 +1399,7 @@ vl_sift_detect (VlSiftFilt * f)
13961399
double xn = x + b[0] ;
13971400
double yn = y + b[1] ;
13981401
double sn = s + b[2] ;
1399-
1402+
14001403
vl_bool good =
14011404
vl_abs_d (val) > tp &&
14021405
score < (te+1)*(te+1)/te &&
@@ -1411,24 +1414,25 @@ vl_sift_detect (VlSiftFilt * f)
14111414
sn >= s_min &&
14121415
sn <= s_max ;
14131416

1417+
14141418
if (good) {
14151419
k-> o = f->o_cur ;
14161420
k-> ix = x ;
14171421
k-> iy = y ;
14181422
k-> is = s ;
14191423
k-> s = sn ;
1420-
k-> x = xn * xper ;
1424+
k-> x = xn * xper;
14211425
k-> y = yn * xper ;
14221426
k-> sigma = f->sigma0 * pow (2.0, sn/f->S) * xper ;
1423-
k -> score = score;
1427+
k -> score = vl_abs_d (val);
14241428
++ k ;
14251429
}
14261430

14271431
} /* done checking */
14281432
} /* next keypoint to refine */
14291433

14301434
/* update keypoint count */
1431-
f-> nkeys = (int)(k - f->keys) ;
1435+
f-> nkeys = (int)(k - f->keys);
14321436
}
14331437

14341438

@@ -2179,6 +2183,8 @@ vl_sift_keypoint_init (VlSiftFilt const *f,
21792183
is = (int)(s + 0.5) ;
21802184
is = VL_MIN(is, f->s_max - 2) ;
21812185
is = VL_MAX(is, f->s_min + 1) ;
2186+
float score;
2187+
score = 10;
21822188

21832189
xper = pow (2.0, o) ;
21842190
ix = (int)(x / xper + 0.5) ;
@@ -2193,6 +2199,7 @@ vl_sift_keypoint_init (VlSiftFilt const *f,
21932199
k -> x = x ;
21942200
k -> y = y ;
21952201
k -> s = s ;
2202+
k -> score = score;
21962203

21972204
k->sigma = sigma ;
21982205
}

‎Features/vlfeat-0.9.18/vl/sift.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef struct _VlSiftKeypoint
3939
float y ; /**< y coordinate. */
4040
float s ; /**< s coordinate. */
4141
float sigma ; /**< scale. */
42-
float score;
42+
float score;
4343
} VlSiftKeypoint ;
4444

4545
/** ------------------------------------------------------------------

‎Images/Photo2/Cortadas/a12.jpg

28.5 KB
Loading

‎Misc/drawcircles.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function drawcircles(points,style,radius)
99
radius = 2;
1010
end
1111

12-
NOP=1000;
12+
NOP=3;
1313
for i=1:size(points,1)
1414

1515
center = [points(i,2),points(i,1)];

‎TestFeatures/geraFeatures.m

+78-17
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,19 @@
3636
% Have to change the X by the y ! Yes. Crazy stuff
3737
aux=points(:,1);
3838
points(:,1) = points(:,2);
39-
points(:,2) = aux;
40-
39+
points(:,2) = aux;
40+
41+
42+
%
43+
% [sortedValues,sortIndex] = sort(points(:,5),'descend');
44+
% 'primeiro'
45+
% sortedValues(1)
46+
% 'n'
47+
% sortedValues(N)
48+
% 'n*3'
49+
% sortedValues(N*3)
50+
%
51+
4152
length(points)
4253

4354
if length(points) > 5
@@ -51,11 +62,12 @@
5162
%rmpath Kaze
5263

5364
elseif strcmp(algoritmo,'kazeg2')
54-
addpath Kaze
55-
im = rgb2gray(im);
5665

57-
points = kaze(im,'dthreshold',0.0000005,'diffusivity',1);
58-
points=uint32(points);
66+
67+
68+
im=uint8(im*255);
69+
points = kaze(im,'dthreshold',0,'diffusivity',1,'soffset',1.6,'turbidity',turb,'verbose',3);
70+
% points=uint32(points);
5971

6072
% Have to change the X by the y ! Yes. Crazy stuff
6173
aux=points(:,1);
@@ -72,13 +84,15 @@
7284
%drawcircles(points);
7385
%hold off
7486

75-
rmpath Kaze
87+
7688
elseif strcmp(algoritmo,'kazeg3')
77-
addpath Kaze
78-
im = rgb2gray(im);
89+
% addpath Kaze
90+
% im = rgb2gray(im);
7991

80-
points = kaze(im,'dthreshold',0.00005,'diffusivity',2);
81-
points=uint32(points);
92+
93+
im=uint8(im*255);
94+
points = kaze(im,'dthreshold',0,'diffusivity',2,'soffset',1.6,'turbidity',turb,'verbose',3);
95+
% points=uint32(points);
8296

8397
% Have to change the X by the y ! Yes. Crazy stuff
8498
aux=points(:,1);
@@ -96,7 +110,7 @@
96110
%drawcircles(points);
97111
%hold off
98112

99-
rmpath Kaze
113+
% rmpath Kaze
100114

101115
elseif strcmp(algoritmo,'censtar')
102116

@@ -251,9 +265,9 @@
251265

252266
%im(950,950) = 0;
253267
im= single(im);
254-
[points d info] = vl_sift(im);
268+
[points ] = vl_sift(im);
255269
points = points';
256-
im = uint8(im);
270+
%im = uint8(im);
257271

258272

259273

@@ -265,13 +279,60 @@
265279

266280
% points=removeBorderPoints(points,im);
267281
length(points)
268-
282+
% figure;
283+
% imshow(im);
284+
% hold on
285+
% drawcircles(points);
286+
%
287+
288+
269289
if length(points) > 5
270290

271-
points = especialnms(im,points,N,delta,info.edgeScores);
272-
end
291+
points = especialnms(im,points,N,delta,points(:,5));
292+
end
293+
294+
figure;
295+
imshow(im);
296+
hold on
297+
drawcircles(points);
273298

274299

300+
elseif strcmp(algoritmo,'iisift')
301+
302+
303+
% im = rgb2gray(im);
304+
305+
306+
%im(950,950) = 0;
307+
im= single(im);
308+
[points ] = vl_sift2(im);
309+
points = points';
310+
%im = uint8(im);
311+
312+
313+
314+
315+
% Have to change the X by the y ! Yes. Crazy stuff
316+
aux=points(:,1);
317+
points(:,1) = points(:,2);
318+
points(:,2) = aux;
319+
320+
% points=removeBorderPoints(points,im);
321+
length(points)
322+
% figure;
323+
% imshow(im);
324+
% hold on
325+
% drawcircles(points);
326+
327+
if length(points) > 5
328+
329+
points = especialnms(im,points,N,delta,points(:,5));
330+
end
331+
332+
% figure;
333+
% imshow(im);
334+
% hold on
335+
% drawcircles(points);
275336
elseif strcmp(algoritmo,'surf')
276337
%addpath Surf
277338

‎cortar.m

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
% Photo 2
2-
%xi= 332;
3-
%xf = 3890;
4-
%yi = 387;
5-
%yf = 2693;
2+
xi= 332;
3+
xf = 3890;
4+
yi = 387;
5+
yf = 2693;
66

77
% Black case
88
%xi= 523;
@@ -11,10 +11,10 @@
1111
%yf = 2427;
1212

1313
% Photo 1
14-
xi = 242;
15-
xf = 3777;
16-
yi= 375;
17-
yf = 2656;
14+
%xi = 242;
15+
%xf = 3777;
16+
%yi= 375;
17+
%yf = 2656;
1818

1919
% center 1779/1125
2020

@@ -53,9 +53,9 @@
5353

5454

5555
%imcut = bfilter2(double(imcut)/255,5,[3 0.1]);
56-
i=13;
56+
i=12;
5757

58-
imwrite(imcut,strcat('Images/Photo1/Cortadas/',sprintf('%d.jpg',i)));
58+
imwrite(imcut,strcat('Images/Photo2/Cortadas/',sprintf('%d.jpg',i)));
5959

6060

6161
end

0 commit comments

Comments
 (0)
Please sign in to comment.