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

Function af_sobel_operator

src/api/c/sobel.cpp:38–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38af_err af_sobel_operator(af_array *dx, af_array *dy, const af_array img,
39 const unsigned ker_size) {
40 try {
41 // FIXME: ADD SUPPORT FOR OTHER KERNEL SIZES
42 // ARG_ASSERT(4, (ker_size==3 || ker_size==5 || ker_size==7));
43 ARG_ASSERT(4, (ker_size == 3));
44
45 const ArrayInfo &info = getInfo(img);
46 af::dim4 dims = info.dims();
47
48 DIM_ASSERT(3, (dims.ndims() >= 2));
49
50 ArrayPair output;
51 af_dtype type = info.getType();
52 switch (type) {
53 case f32:
54 output = sobelDerivatives<float, float>(img, ker_size);
55 break;
56 case f64:
57 output = sobelDerivatives<double, double>(img, ker_size);
58 break;
59 case s32: output = sobelDerivatives<int, int>(img, ker_size); break;
60 case u32:
61 output = sobelDerivatives<uint, int>(img, ker_size);
62 break;
63 case s16:
64 output = sobelDerivatives<short, int>(img, ker_size);
65 break;
66 case u16:
67 output = sobelDerivatives<ushort, int>(img, ker_size);
68 break;
69 case b8: output = sobelDerivatives<char, int>(img, ker_size); break;
70 case s8:
71 output = sobelDerivatives<schar, int>(img, ker_size);
72 break;
73 case u8:
74 output = sobelDerivatives<uchar, int>(img, ker_size);
75 break;
76 default: TYPE_ERROR(1, type);
77 }
78 std::swap(*dx, output.first);
79 std::swap(*dy, output.second);
80 }
81 CATCHALL;
82
83 return AF_SUCCESS;
84}

Callers 2

testSobelDerivativesFunction · 0.50
sobelFunction · 0.50

Calls 4

swapFunction · 0.85
dimsMethod · 0.45
ndimsMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected