diff options
author | leochanj <jbakita@cs.unc.edu> | 2020-10-21 01:52:54 -0400 |
---|---|---|
committer | leochanj <jbakita@cs.unc.edu> | 2020-10-21 15:59:54 -0400 |
commit | 0efc775370d2ff91927d1b383a99eab78dc5538f (patch) | |
tree | a41fe470fee5adc4d944ecd6b917bc48df8c7e0f /SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/wrap.c | |
parent | e2b50015cebdfba68699abd6e8575e38230f5a78 (diff) |
debug libextra and remove matlab
FLUSH_CACHES
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/wrap.c')
-rwxr-xr-x | SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/wrap.c | 281 |
1 files changed, 0 insertions, 281 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/wrap.c b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/wrap.c deleted file mode 100755 index a081123..0000000 --- a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/MEX/wrap.c +++ /dev/null | |||
@@ -1,281 +0,0 @@ | |||
1 | /* | ||
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
3 | ;;; File: wrap.c | ||
4 | ;;; Author: Eero Simoncelli | ||
5 | ;;; Description: Circular convolution on 2D images. | ||
6 | ;;; Creation Date: Spring, 1987. | ||
7 | ;;; MODIFICATIONS: | ||
8 | ;;; 6/96: Switched array types to double float. | ||
9 | ;;; 2/97: made more robust and readable. Added STOP arguments. | ||
10 | ;;; ---------------------------------------------------------------- | ||
11 | ;;; Object-Based Vision and Image Understanding System (OBVIUS), | ||
12 | ;;; Copyright 1988, Vision Science Group, Media Laboratory, | ||
13 | ;;; Massachusetts Institute of Technology. | ||
14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
15 | */ | ||
16 | |||
17 | #include <stdlib.h> | ||
18 | |||
19 | #include "convolve.h" | ||
20 | |||
21 | /* | ||
22 | -------------------------------------------------------------------- | ||
23 | Performs correlation (i.e., convolution with filt(-x,-y)) of FILT | ||
24 | with IMAGE followed by subsampling (a.k.a. REDUCE in Burt&Adelson81). | ||
25 | The operations are combined to avoid unnecessary computation of the | ||
26 | convolution samples that are to be discarded in the subsampling | ||
27 | operation. The convolution is done in 9 sections so that mod | ||
28 | operations are not performed unnecessarily. The subsampling lattice | ||
29 | is specified by the START, STEP and STOP parameters. | ||
30 | -------------------------------------------------------------------- */ | ||
31 | |||
32 | /* abstract out the inner product computation */ | ||
33 | #define INPROD(YSTART,YIND,XSTART,XIND) \ | ||
34 | { \ | ||
35 | sum=0.0; \ | ||
36 | for (y_im=YSTART, filt_pos=0, x_filt_stop=x_fdim; \ | ||
37 | x_filt_stop<=filt_size; \ | ||
38 | y_im++, x_filt_stop+=x_fdim) \ | ||
39 | for (x_im=XSTART ; \ | ||
40 | filt_pos<x_filt_stop; \ | ||
41 | filt_pos++, x_im++) \ | ||
42 | sum += imval[YIND][XIND] * filt[filt_pos]; \ | ||
43 | result[res_pos] = sum; \ | ||
44 | } | ||
45 | |||
46 | int internal_wrap_reduce(image, x_dim, y_dim, filt, x_fdim, y_fdim, | ||
47 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
48 | result) | ||
49 | register image_type *filt, *result; | ||
50 | register int x_dim, y_dim, x_fdim, y_fdim; | ||
51 | image_type *image; | ||
52 | int x_start, x_step, x_stop, y_start, y_step, y_stop; | ||
53 | { | ||
54 | register double sum; | ||
55 | register int filt_size = x_fdim*y_fdim; | ||
56 | image_type **imval; | ||
57 | register int filt_pos, x_im, y_im, x_filt_stop; | ||
58 | register int x_pos, y_pos, res_pos; | ||
59 | int x_ctr_stop = x_dim - x_fdim + 1; | ||
60 | int y_ctr_stop = y_dim - y_fdim + 1; | ||
61 | int x_ctr_start = 0; | ||
62 | int y_ctr_start = 0; | ||
63 | int x_fmid = x_fdim/2; | ||
64 | int y_fmid = y_fdim/2; | ||
65 | |||
66 | /* shift start/stop coords to filter upper left hand corner */ | ||
67 | x_start -= x_fmid; y_start -= y_fmid; | ||
68 | x_stop -= x_fmid; y_stop -= y_fmid; | ||
69 | |||
70 | if (x_stop < x_ctr_stop) x_ctr_stop = x_stop; | ||
71 | if (y_stop < y_ctr_stop) y_ctr_stop = y_stop; | ||
72 | |||
73 | /* Set up pointer array for rows */ | ||
74 | imval = (image_type **) malloc(y_dim*sizeof(image_type *)); | ||
75 | if (imval IS NULL) | ||
76 | { | ||
77 | printf("INTERNAL_WRAP: Failed to allocate temp array!"); | ||
78 | return(-1); | ||
79 | } | ||
80 | for (y_pos=y_im=0;y_pos<y_dim;y_pos++,y_im+=x_dim) | ||
81 | imval[y_pos] = (image+y_im); | ||
82 | |||
83 | for (res_pos=0, y_pos=y_start; /* TOP ROWS */ | ||
84 | y_pos<y_ctr_start; | ||
85 | y_pos+=y_step) | ||
86 | { | ||
87 | for (x_pos=x_start; | ||
88 | x_pos<x_ctr_start; | ||
89 | x_pos+=x_step, res_pos++) | ||
90 | INPROD(y_pos+y_dim, y_im%y_dim, x_pos+x_dim, x_im%x_dim) | ||
91 | |||
92 | for (; | ||
93 | x_pos<x_ctr_stop; | ||
94 | x_pos+=x_step, res_pos++) | ||
95 | INPROD(y_pos+y_dim, y_im%y_dim, x_pos, x_im) | ||
96 | |||
97 | for (; | ||
98 | x_pos<x_stop; | ||
99 | x_pos+=x_step, res_pos++) | ||
100 | INPROD(y_pos+y_dim, y_im%y_dim, x_pos, x_im%x_dim) | ||
101 | } /* end TOP ROWS */ | ||
102 | |||
103 | for (; /* MID ROWS */ | ||
104 | y_pos<y_ctr_stop; | ||
105 | y_pos+=y_step) | ||
106 | { | ||
107 | for (x_pos=x_start; | ||
108 | x_pos<x_ctr_start; | ||
109 | x_pos+=x_step, res_pos++) | ||
110 | INPROD(y_pos, y_im, x_pos+x_dim, x_im%x_dim) | ||
111 | |||
112 | for (; /* CENTER SECTION */ | ||
113 | x_pos<x_ctr_stop; | ||
114 | x_pos+=x_step, res_pos++) | ||
115 | INPROD(y_pos, y_im, x_pos, x_im) | ||
116 | |||
117 | for (; | ||
118 | x_pos<x_stop; | ||
119 | x_pos+=x_step, res_pos++) | ||
120 | INPROD(y_pos, y_im, x_pos, x_im%x_dim) | ||
121 | } /* end MID ROWS */ | ||
122 | |||
123 | for (; /* BOTTOM ROWS */ | ||
124 | y_pos<y_stop; | ||
125 | y_pos+=y_step) | ||
126 | { | ||
127 | for (x_pos=x_start; | ||
128 | x_pos<x_ctr_start; | ||
129 | x_pos+=x_step, res_pos++) | ||
130 | INPROD(y_pos, y_im%y_dim, x_pos+x_dim, x_im%x_dim) | ||
131 | |||
132 | for (; | ||
133 | x_pos<x_ctr_stop; | ||
134 | x_pos+=x_step, res_pos++) | ||
135 | INPROD(y_pos, y_im%y_dim, x_pos, x_im) | ||
136 | |||
137 | for (; | ||
138 | x_pos<x_stop; | ||
139 | x_pos+=x_step, res_pos++) | ||
140 | INPROD(y_pos, y_im%y_dim, x_pos, x_im%x_dim) | ||
141 | } /* end BOTTOM ROWS */ | ||
142 | |||
143 | free ((image_type **) imval); | ||
144 | |||
145 | return(0); | ||
146 | } /* end of internal_wrap_reduce */ | ||
147 | |||
148 | |||
149 | |||
150 | /* | ||
151 | -------------------------------------------------------------------- | ||
152 | Performs upsampling (padding with zeros) followed by convolution of | ||
153 | FILT with IMAGE (a.k.a. EXPAND in Burt&Adelson81). The operations | ||
154 | are combined to avoid unnecessary multiplication of filter samples | ||
155 | with zeros in the upsampled image. The convolution is done in 9 | ||
156 | sections so that mod operation is not performed unnecessarily. | ||
157 | Arguments are described in the comment above internal_wrap_reduce. | ||
158 | |||
159 | WARNING: this subroutine destructively modifes the RESULT image, so | ||
160 | the user must zero the result before invocation! | ||
161 | -------------------------------------------------------------------- */ | ||
162 | |||
163 | /* abstract out the inner product computation */ | ||
164 | #define INPROD2(YSTART,YIND,XSTART,XIND) \ | ||
165 | { \ | ||
166 | val = image[im_pos]; \ | ||
167 | for (y_res=YSTART, filt_pos=0, x_filt_stop=x_fdim; \ | ||
168 | x_filt_stop<=filt_size; \ | ||
169 | y_res++, x_filt_stop+=x_fdim) \ | ||
170 | for (x_res=XSTART; \ | ||
171 | filt_pos<x_filt_stop; \ | ||
172 | filt_pos++, x_res++) \ | ||
173 | imval[YIND][XIND] += val * filt[filt_pos]; \ | ||
174 | } | ||
175 | |||
176 | int internal_wrap_expand(image, filt, x_fdim, y_fdim, | ||
177 | x_start, x_step, x_stop, y_start, y_step, y_stop, | ||
178 | result, x_dim, y_dim) | ||
179 | register image_type *filt, *result; | ||
180 | register int x_fdim, y_fdim, x_dim, y_dim; | ||
181 | image_type *image; | ||
182 | int x_start, x_step, x_stop, y_start, y_step, y_stop; | ||
183 | { | ||
184 | register double val; | ||
185 | register int filt_size = x_fdim*y_fdim; | ||
186 | image_type **imval; | ||
187 | register int filt_pos, x_res, y_res, x_filt_stop; | ||
188 | register int x_pos, y_pos, im_pos; | ||
189 | int x_ctr_stop = x_dim - x_fdim + 1; | ||
190 | int y_ctr_stop = y_dim - y_fdim + 1; | ||
191 | int x_ctr_start = 0; | ||
192 | int y_ctr_start = 0; | ||
193 | int x_fmid = x_fdim/2; | ||
194 | int y_fmid = y_fdim/2; | ||
195 | |||
196 | /* shift start/stop coords to filter upper left hand corner */ | ||
197 | x_start -= x_fmid; y_start -= y_fmid; | ||
198 | x_stop -= x_fmid; y_stop -= y_fmid; | ||
199 | |||
200 | if (x_stop < x_ctr_stop) x_ctr_stop = x_stop; | ||
201 | if (y_stop < y_ctr_stop) y_ctr_stop = y_stop; | ||
202 | |||
203 | /* Set up pointer array for rows */ | ||
204 | imval = (image_type **) malloc(y_dim*sizeof(image_type *)); | ||
205 | if (imval IS NULL) | ||
206 | { | ||
207 | printf("INTERNAL_WRAP: Failed to allocate temp array!"); | ||
208 | return(-1); | ||
209 | } | ||
210 | for (y_pos=y_res=0;y_pos<y_dim;y_pos++,y_res+=x_dim) | ||
211 | imval[y_pos] = (result+y_res); | ||
212 | |||
213 | for (im_pos=0, y_pos=y_start; /* TOP ROWS */ | ||
214 | y_pos<y_ctr_start; | ||
215 | y_pos+=y_step) | ||
216 | { | ||
217 | for (x_pos=x_start; | ||
218 | x_pos<x_ctr_start; | ||
219 | x_pos+=x_step, im_pos++) | ||
220 | INPROD2(y_pos+y_dim, y_res%y_dim, x_pos+x_dim, x_res%x_dim) | ||
221 | |||
222 | for (; | ||
223 | x_pos<x_ctr_stop; | ||
224 | x_pos+=x_step, im_pos++) | ||
225 | INPROD2(y_pos+y_dim, y_res%y_dim, x_pos, x_res) | ||
226 | |||
227 | for (; | ||
228 | x_pos<x_stop; | ||
229 | x_pos+=x_step, im_pos++) | ||
230 | INPROD2(y_pos+y_dim, y_res%y_dim, x_pos, x_res%x_dim) | ||
231 | } /* end TOP ROWS */ | ||
232 | |||
233 | for (; /* MID ROWS */ | ||
234 | y_pos<y_ctr_stop; | ||
235 | y_pos+=y_step) | ||
236 | { | ||
237 | for (x_pos=x_start; | ||
238 | x_pos<x_ctr_start; | ||
239 | x_pos+=x_step, im_pos++) | ||
240 | INPROD2(y_pos, y_res, x_pos+x_dim, x_res%x_dim) | ||
241 | |||
242 | for (; /* CENTER SECTION */ | ||
243 | x_pos<x_ctr_stop; | ||
244 | x_pos+=x_step, im_pos++) | ||
245 | INPROD2(y_pos, y_res, x_pos, x_res) | ||
246 | |||
247 | for (; | ||
248 | x_pos<x_stop; | ||
249 | x_pos+=x_step, im_pos++) | ||
250 | INPROD2(y_pos, y_res, x_pos, x_res%x_dim) | ||
251 | } /* end MID ROWS */ | ||
252 | |||
253 | for (; /* BOTTOM ROWS */ | ||
254 | y_pos<y_stop; | ||
255 | y_pos+=y_step) | ||
256 | { | ||
257 | for (x_pos=x_start; | ||
258 | x_pos<x_ctr_start; | ||
259 | x_pos+=x_step, im_pos++) | ||
260 | INPROD2(y_pos, y_res%y_dim, x_pos+x_dim, x_res%x_dim) | ||
261 | |||
262 | for (; | ||
263 | x_pos<x_ctr_stop; | ||
264 | x_pos+=x_step, im_pos++) | ||
265 | INPROD2(y_pos, y_res%y_dim, x_pos, x_res) | ||
266 | |||
267 | for (; | ||
268 | x_pos<x_stop; | ||
269 | x_pos+=x_step, im_pos++) | ||
270 | INPROD2(y_pos, y_res%y_dim, x_pos, x_res%x_dim) | ||
271 | } /* end BOTTOM ROWS */ | ||
272 | |||
273 | free ((image_type **) imval); | ||
274 | return(0); | ||
275 | } /* end of internal_wrap_expand */ | ||
276 | |||
277 | |||
278 | |||
279 | /* Local Variables: */ | ||
280 | /* buffer-read-only: t */ | ||
281 | /* End: */ | ||