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
|
/********************************
Author: Sravanthi Kota Venkata
********************************/
#include <stdio.h>
#include <stdlib.h>
#include "sift.h"
#include <malloc.h>
#include "extra.h"
#define SIFT_MEM 1<<29
void normalizeImage(F2D* image)
{
int i;
int rows;
int cols;
int tempMin = 10000, tempMax = -1;
rows = image->height;
cols = image->width;
for(i=0; i<(rows*cols); i++)
if(tempMin > asubsref(image,i))
tempMin = asubsref(image,i);
for(i=0; i<(rows*cols); i++)
asubsref(image,i) = asubsref(image,i) - tempMin;
for(i=0; i<(rows*cols); i++)
if(tempMax < asubsref(image,i))
tempMax = asubsref(image,i);
for(i=0; i<(rows*cols); i++)
asubsref(image,i) = ( asubsref(image,i) / (tempMax+0.0) );
}
int main(int argc, char* argv[])
{
SET_UP
mallopt(M_TOP_PAD, SIFT_MEM);
mallopt(M_MMAP_MAX, 0);
I2D* im;
F2D *image;
int rows, cols, i, j;
F2D* frames;
unsigned int* startTime, *endTime, *elapsed;
char imSrc[100];
printf("Input image: ");
scanf("%s", imSrc);
im = readImage(imSrc);
image = fiDeepCopy(im);
rows = image->height;
cols = image->width;
printf("start\n");
for_each_job{
image = fiDeepCopy(im);
normalizeImage(image);
/** Extract sift features for the normalized image **/
frames = sift(image);
}
printf("end..\n");
#ifdef CHECK
{
int ret=0;
float tol = 0.2;
#ifdef GENERATE_OUTPUT
fWriteMatrix(frames, argv[1]);
#endif
ret = fSelfCheck(frames, "expected_C.txt", tol);
if (ret == -1)
printf("Error in SIFT\n");
}
#endif
iFreeHandle(im);
fFreeHandle(frames);
WRITE_TO_FILE
return 0;
}
|