summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/sift/src/matlab/imsmooth_.c
diff options
context:
space:
mode:
authorleochanj105 <leochanj@live.unc.edu>2020-10-20 03:47:33 -0400
committerleochanj105 <leochanj@live.unc.edu>2020-10-20 03:47:33 -0400
commita32f220f06cc463e5b56e7fa0b1b1334d94d08f3 (patch)
tree4af4caa60074465d85fc2ef5cc1b23e74c064329 /SD-VBS/benchmarks/sift/src/matlab/imsmooth_.c
parent79f30887129145e15e5172e36a7d7602859fc932 (diff)
matlab removed
Diffstat (limited to 'SD-VBS/benchmarks/sift/src/matlab/imsmooth_.c')
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/imsmooth_.c103
1 files changed, 0 insertions, 103 deletions
diff --git a/SD-VBS/benchmarks/sift/src/matlab/imsmooth_.c b/SD-VBS/benchmarks/sift/src/matlab/imsmooth_.c
deleted file mode 100644
index e0adeff..0000000
--- a/SD-VBS/benchmarks/sift/src/matlab/imsmooth_.c
+++ /dev/null
@@ -1,103 +0,0 @@
1#include<stdlib.h>
2#include<string.h>
3#include<math.h>
4#include "imsmooth.h"
5
6#define greater(a,b) ((a) > (b))
7#define min(a,b) (((a)<(b))?(a):(b))
8#define max(a,b) (((a)>(b))?(a):(b))
9
10const double win_factor = 1.5 ;
11const int nbins = 36 ;
12
13float* imsmooth(float* I_pt_, float dsigma)
14{
15 int M,N ;
16 float *I_pt ;
17 float* J_pt_, *J_pt ;
18 float* out_, *out;
19 float s ;
20 enum {I=0,S} ;
21 enum {J=0} ;
22
23 /* ------------------------------------------------------------------
24 ** Check the arguments
25 ** --------------------------------------------------------------- */
26
27 M = (int)in_[0];
28 N = (int)in_[1];
29
30 out_ = fMallocHandle(M, N);
31 J_pt_ = &(out_[0]);
32 J_pt = &(J_pt_[4]);
33 s = dsigma;
34
35
36 /* ------------------------------------------------------------------
37 ** Do the job
38 ** --------------------------------------------------------------- */
39 if(s > 0.01)
40 {
41
42 int W = (int) ceil(4*s) ;
43 int i ;
44 int j ;
45 float* g0_, *g0, *buffer_, *buffer, acc;
46 g0_ = fMallocHandle(1, 2*W+1);
47 g0 = &(g0_[4]);
48 buffer_ = fMallocHandle(M, N);
49 acc=0.0 ;
50
51 for(j = 0 ; j < 2*W+1 ; ++j)
52 {
53 g0[j] = exp(-0.5 * (j - W)*(j - W)/(s*s)) ;
54 acc += g0[j] ;
55 }
56
57 for(j = 0 ; j < 2*W+1 ; ++j)
58 {
59 g0[j] /= acc ;
60 }
61
62 /*
63 ** Convolve along the columns
64 **/
65
66 for(j = 0 ; j < N ; ++j)
67 {
68 for(i = 0 ; i < M ; ++i)
69 {
70 float* start = I_pt + max(i-W,0) + j*M ;
71 float* stop = I_pt + min(i+W,M-1) + j*M + 1 ;
72 float* g = g0 + max(0, W-i) ;
73 acc = 0.0 ;
74 while(stop != start) acc += (*g++) * (*start++) ;
75 *buffer++ = acc ;
76 }
77 }
78 buffer -= M*N ;
79
80 /*
81 ** Convolve along the rows
82 **/
83 for(j = 0 ; j < N ; ++j)
84 {
85 for(i = 0 ; i < M ; ++i)
86 {
87 float* start = buffer + i + max(j-W,0)*M ;
88 float* stop = buffer + i + min(j+W,N-1)*M + M ;
89 float* g = g0 + max(0, W-j) ;
90 acc = 0.0 ;
91 while(stop != start) { acc += (*g++) * (*start) ; start+=M ;}
92 *J_pt++ = acc ;
93 }
94 }
95 free(buffer) ;
96 free(g0) ;
97 }
98 else
99 {
100 memcpy(J_pt, I_pt, sizeof(double)*M*N) ;
101 }
102 return J_pt_;
103}