MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / pyramid

Function pyramid

examples/image_processing/pyramids.cpp:20–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 16, 4, 1, 4, 6, 4, 1};
19
20array pyramid(const array& img, const int level, const bool sampling) {
21 array pyr = img.copy();
22 array kernel(5, 5, pyramid_kernel);
23 kernel = kernel / 256.f;
24 if (sampling) { // Downsample
25 for (int i = 0; i < level; i++) {
26 for (int j = 0; j < pyr.dims(2); j++)
27 pyr(span, span, j) = convolve(pyr(span, span, j), kernel);
28 pyr = pyr(seq(0, pyr.dims(0) - 1, 2), seq(0, pyr.dims(1) - 1, 2),
29 span);
30 }
31 } else { // Up sample
32 for (int i = 0; i < level; i++) {
33 array tmp =
34 constant(0, pyr.dims(0) * 2, pyr.dims(1) * 2, pyr.dims(2));
35 tmp(seq(0, 2 * pyr.dims(0) - 1, 2), seq(0, 2 * pyr.dims(1) - 1, 2),
36 span) = pyr;
37 for (int j = 0; j < pyr.dims(2); j++)
38 tmp(span, span, j) = convolve(tmp(span, span, j), kernel * 4.f);
39 pyr = tmp;
40 }
41 }
42 return pyr;
43}
44
45void pyramids_demo() {
46 af::Window wnd_rgb("Image Pyramids - RGB Images");

Callers 1

pyramids_demoFunction · 0.85

Calls 5

seqClass · 0.85
constantFunction · 0.85
convolveFunction · 0.50
copyMethod · 0.45
dimsMethod · 0.45

Tested by

no test coverage detected