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

Function diffs

examples/image_processing/optical_flow.cpp:18–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16using namespace af;
17
18static void diffs(array& Ix, array& Iy, array& It, array I1, array I2) {
19 // 3x3 derivative kernels
20 float dx_kernel[] = {-1.0f / 6.0f, -1.0f / 6.0f, -1.0f / 6.0f,
21 0.0f / 6.0f, 0.0f / 6.0f, 0.0f / 6.0f,
22 1.0f / 6.0f, 1.0f / 6.0f, 1.0f / 6.0f};
23 float dy_kernel[] = {-1.0f / 6.0f, 0.0f / 6.0f, 1.0f / 6.0f,
24 -1.0f / 6.0f, 0.0f / 6.0f, 1.0f / 6.0f,
25 -1.0f / 6.0f, 0.0f / 6.0f, 1.0f / 6.0f};
26 array dx = array(dim4(3, 3), dx_kernel);
27 array dy = array(dim4(3, 3), dy_kernel);
28 array dt = constant(1, 1, 2) / 4.0;
29
30 Ix = convolve(I1, dx) + convolve(I2, dx);
31 Iy = convolve(I1, dy) + convolve(I2, dy);
32 It = convolve(I2, dt) - convolve(I1, dt);
33}
34
35static void optical_flow_demo(bool console) {
36 af::Window wnd("Horn-Schunck Optical Flow Demo");

Callers 1

optical_flow_demoFunction · 0.85

Calls 4

constantFunction · 0.85
arrayClass · 0.50
dim4Class · 0.50
convolveFunction · 0.50

Tested by

no test coverage detected