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
|
/********************************
Author: Sravanthi Kota Venkata
********************************/
#include "mser.h"
#include <malloc.h>
#include "extra.h"
#define min(a,b) (a<b)?a:b
#define max(a,b) (a>b)?a:b
int main(int argc, char* argv[])
{
SET_UP
int which_image;
int i, j, k;
I2D *idx;
I2D *I;
I2D *It;
I2D *out;
int rows=196, cols=98;
int minVal = 1000;
int maxVal = -1000;
int lev = 10;
char im1[100], im2[100];
iArray *subs_pt, *nsubs_pt, *strides_pt, *visited_pt, *dims;
uiArray* joins_pt;
ulliArray *acc_pt, *ell_pt;
region_t* regions_pt;
pair_t* pairs_pt;
node_t* forest_pt;
int ndims, nel, gdl, nmer;
scanf("%s", im1);
I = readImage(im1);
rows = I->height;
cols = I->width;
It = readImage(im1);
k = 0;
for(i=0; i<cols; i++)
{
for(j=0; j<rows; j++)
{
asubsref(It,k++) = subsref(I,j,i);
}
}
ndims = 2;
nel = It->height * It->width;
gdl = ndims * (ndims+1)/2 + ndims;
nmer = NMER_MAX;
dims = malloc(sizeof(iArray) + sizeof(int)*ndims);
/* allocate stuff */
subs_pt = malloc(sizeof(iArray) + sizeof(int)*ndims);
nsubs_pt = malloc(sizeof(iArray) + sizeof(int)*ndims);
strides_pt = malloc(sizeof(uiArray)+sizeof(unsigned int)*ndims);
visited_pt = malloc(sizeof(uiArray) + sizeof(unsigned int)*nel);
joins_pt = malloc(sizeof(uiArray) + sizeof(unsigned int)*nel);
regions_pt = (region_t*)malloc(sizeof(region_t)*nel);
pairs_pt = (pair_t*)malloc(sizeof(pair_t)*nel);
forest_pt = (node_t*)malloc(sizeof(node_t)*nel);
acc_pt = malloc(sizeof(ulliArray) + sizeof(acc_t)*nel) ;
ell_pt = malloc(sizeof(ulliArray) + sizeof(acc_t)*gdl*nmer) ;
out = iMallocHandle(1, nmer);
for_each_job {
idx = mser(It, 2, subs_pt, nsubs_pt, strides_pt, visited_pt, dims,
joins_pt,
regions_pt,
pairs_pt,
forest_pt,
acc_pt, ell_pt,
out);
}
#ifdef CHECK
/** Self checking - use expected.txt from data directory **/
{
int tol, ret=0;
tol = 1;
#ifdef GENERATE_OUTPUT
writeMatrix(idx, argv[1]);
#endif
ret = selfCheck(idx, "expected_C.txt", tol);
if (ret == -1)
printf("Error in MSER\n");
}
/** Self checking done **/
#endif
free(dims);
free( forest_pt ) ;
free( pairs_pt ) ;
free( regions_pt ) ;
free( visited_pt ) ;
free( strides_pt ) ;
free( nsubs_pt ) ;
free( subs_pt ) ;
free( joins_pt ) ;
free( acc_pt ) ;
free( ell_pt ) ;
iFreeHandle(idx);
iFreeHandle(I);
iFreeHandle(It);
WRITE_TO_FILE
return 0;
}
|