Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7d9e15d

Browse files
committed
Changes were uncommited - now I don't know what is there
1 parent 103d339 commit 7d9e15d

File tree

1 file changed

+23
-31
lines changed

1 file changed

+23
-31
lines changed

‎CppSource/FilterBasedOnGradientAnalysis.cpp‎

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void computeModules(Tu*** src, Tf*** dst, Ts**** grads, uint32_t height, uint32_
150150

151151
//The class that implements filtering. To use it create an instance of Filter class
152152
//and then call operator () from it
153-
template<typename Tf, typename Tu>
153+
template<typename Tf, typename Tu, typename Ts>
154154
class Filter
155155
{
156156
private:
@@ -205,13 +205,14 @@ class Filter
205205
Recieves:
206206
Tu*** src - source image, array with the shape (height x width x colors)
207207
Tf*** dst - destination image with the same shape as src
208+
Tf**** grads - the array of gradients with the shape (n, m, 3, 2)
208209
Tf*** modules - the array of gradient modules with the same shape as src
209210
Tf*** modules - the array of gradient modules with the same shape as src
210211
uint32_t ksize - size of filtering kernel (odd values expected)
211212
uint32_t n - number of sequential runs
212213
uint32_t height, width, colors - dimensions of the src image
213214
*/
214-
void operator()(Tu*** src, Tf*** dst, Tf*** modules, Tf*** angles,
215+
void operator()(Tu*** src, Tf*** dst, Ts**** grads, Tf*** modules, Tf*** angles,
215216
uint32_t ksize, uint32_t n, uint32_t height, uint32_t width, uint32_t colors)
216217
{
217218
Tu*** srcProxy = new Tu**[height];
@@ -226,27 +227,11 @@ class Filter
226227
}
227228
}
228229

229-
int32_t**** grads = new int32_t***[height];
230-
for (uint32_t i = 0; i < height; i++)
230+
for (int iter_num = 0; iter_num < n; iter_num++)
231231
{
232-
grads[i] = new int32_t**[width];
233-
for (uint32_t j = 0; j < width; j++)
234-
{
235-
grads[i][j] = new int32_t*[colors];
236-
for (uint32_t c = 0; c < colors; c++)
237-
{
238-
grads[i][j][c] = new int32_t[2];
239-
for (uint32_t k = 0; k < 2; k++)
240-
grads[i][j][c][k] = 0;
241-
}
242-
}
243-
}
244-
245-
for (int i = 0; i < n; i++)
246-
{
247-
computeGrads<Tu, int32_t>(srcProxy, grads, height, width, colors);
248-
computeModules<Tf, Tu, int32_t>(srcProxy, modules, grads, height, width, colors);
249-
computeAngles<Tf, Tu, int32_t>(srcProxy, angles, grads, height, width, colors);
232+
computeGrads<Tu, Ts>(srcProxy, grads, height, width, colors);
233+
computeModules<Tf, Tu, Ts>(srcProxy, modules, grads, height, width, colors);
234+
computeAngles<Tf, Tu, Ts>(srcProxy, angles, grads, height, width, colors);
250235
this->filter(srcProxy, dst, modules, angles, ksize, height, width, colors);
251236

252237
for (uint32_t i = 0; i < height; i++)
@@ -259,7 +244,18 @@ class Filter
259244
}
260245
}
261246
}
247+
std::cout << iter_num << ' ';
248+
}
249+
250+
for (uint32_t i = 0; i < height; i++)
251+
{
252+
for (uint32_t j = 0; j < width; j++)
253+
{
254+
delete srcProxy[i][j];
255+
}
256+
delete srcProxy[i];
262257
}
258+
delete srcProxy;
263259
}
264260

265261
Mat operator()(Mat src, uint32_t ksize, uint32_t n=1)
@@ -290,15 +286,15 @@ class Filter
290286
Tu*** intoutput = new Tu**[height];
291287
Tf*** modules = new Tf**[height];
292288
Tf*** angles = new Tf**[height];
293-
int32_t**** grads = new int32_t***[height];
289+
Ts**** grads = new Ts***[height];
294290
for (uint32_t i = 0; i < height; i++)
295291
{
296292
image[i] = new Tu*[width];
297293
output[i] = new Tf*[width];
298294
intoutput[i] = new Tu*[width];
299295
modules[i] = new Tf*[width];
300296
angles[i] = new Tf*[width];
301-
grads[i] = new int32_t**[width];
297+
grads[i] = new Ts**[width];
302298
for (uint32_t j = 0; j < width; j++)
303299
{
304300
image[i][j] = src.ptr<Tu>(i, j);
@@ -307,26 +303,22 @@ class Filter
307303
intoutput[i][j] = new Tu[colors];
308304
modules[i][j] = new Tf[colors];
309305
angles[i][j] = new Tf[colors];
310-
grads[i][j] = new int32_t*[colors];
306+
grads[i][j] = new Ts*[colors];
311307
for (uint32_t c = 0; c < colors; c++)
312308
{
313309
output[i][j][c] = .0;
314310
intoutput[i][j][c] = 0;
315311
modules[i][j][c] = .0;
316312
angles[i][j][c] = .0;
317-
grads[i][j][c] = new int32_t[2];
313+
grads[i][j][c] = new Ts[2];
318314
for (uint32_t k = 0; k < 2; k++)
319315
grads[i][j][c][k] = 0;
320316
}
321317
}
322318
}
323319

324-
computeGrads<Tu, int32_t>(image, grads, height, width, colors);
325-
computeModules<Tf, Tu, int32_t>(image, modules, grads, height, width, colors);
326-
computeAngles<Tf, Tu, int32_t>(image, angles, grads, height, width, colors);
327-
328320
//filtering with regular function
329-
this->operator()(image, output, modules, angles, ksize, n, height, width, colors);
321+
this->operator()(image, output, grads, modules, angles, ksize, n, height, width, colors);
330322

331323
//deallocating memory that gradients, modules and angles were using
332324
for (uint32_t i = 0; i < height; i++)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /