diff options
Diffstat (limited to 'SD-VBS/common/c/fResortIndices.c')
-rw-r--r-- | SD-VBS/common/c/fResortIndices.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/SD-VBS/common/c/fResortIndices.c b/SD-VBS/common/c/fResortIndices.c new file mode 100644 index 0000000..d4d1cda --- /dev/null +++ b/SD-VBS/common/c/fResortIndices.c | |||
@@ -0,0 +1,77 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #include "sdvbs_common.h" | ||
6 | |||
7 | I2D* fResortIndices(F2D* input, int dim, F2D* in, I2D* ind) | ||
8 | { | ||
9 | int rows, cols; | ||
10 | //F2D *in; | ||
11 | int i, j, k; | ||
12 | //I2D *ind; | ||
13 | |||
14 | rows = input->height; | ||
15 | cols = input->width; | ||
16 | |||
17 | in = fCopy(input, in); | ||
18 | //ind = iMallocHandle(rows,cols); | ||
19 | |||
20 | for(i=0; i<cols; i++) { | ||
21 | for(j=0; j<rows; j++) { | ||
22 | subsref(ind,j,i) = 0; | ||
23 | } | ||
24 | } | ||
25 | |||
26 | if(dim == 1) | ||
27 | { | ||
28 | for(k=0; k<rows; k++) | ||
29 | { | ||
30 | for(i=0; i<cols; i++) | ||
31 | { | ||
32 | float localMax = subsref(in,k,i); | ||
33 | int localIndex = i; | ||
34 | subsref(ind,k,i) = i; | ||
35 | for(j=0; j<cols; j++) | ||
36 | { | ||
37 | if(localMax < subsref(in,k,j)) | ||
38 | { | ||
39 | subsref(ind,k,i) = j; | ||
40 | localMax = subsref(in,k,j); | ||
41 | localIndex = j; | ||
42 | } | ||
43 | } | ||
44 | subsref(in,k,localIndex) = 0; | ||
45 | } | ||
46 | } | ||
47 | |||
48 | //fFreeHandle(in); | ||
49 | return ind; | ||
50 | } | ||
51 | |||
52 | for(k=0; k<cols; k++) | ||
53 | { | ||
54 | for(i=0; i<rows; i++) | ||
55 | { | ||
56 | float localMax = subsref(in,i,k); | ||
57 | int localIndex = i; | ||
58 | subsref(ind,i,k) = i; | ||
59 | for(j=0; j<rows; j++) | ||
60 | { | ||
61 | if(localMax < subsref(in,j,k)) | ||
62 | { | ||
63 | subsref(ind,i,k) = j; | ||
64 | localMax = subsref(in,j,k); | ||
65 | localIndex = j; | ||
66 | } | ||
67 | } | ||
68 | subsref(in,localIndex,k) = 0; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | //fFreeHandle(in); | ||
73 | return ind; | ||
74 | } | ||
75 | |||
76 | |||
77 | |||