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

Function af_medfilt1

src/api/c/filters.cpp:38–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38af_err af_medfilt1(af_array *out, const af_array in, const dim_t wind_width,
39 const af_border_type edge_pad) {
40 try {
41 ARG_ASSERT(2, (wind_width > 0));
42 ARG_ASSERT(4, (edge_pad >= AF_PAD_ZERO && edge_pad <= AF_PAD_SYM));
43
44 const ArrayInfo &info = getInfo(in);
45 af::dim4 dims = info.dims();
46
47 dim_t input_ndims = dims.ndims();
48 DIM_ASSERT(1, (input_ndims >= 1));
49
50 if (wind_width == 1) {
51 *out = retain(in);
52 return AF_SUCCESS;
53 }
54 af_array output = nullptr;
55 af_dtype type = info.getType();
56 switch (type) {
57 case f32: output = medfilt1<float>(in, wind_width, edge_pad); break;
58 case f64:
59 output = medfilt1<double>(in, wind_width, edge_pad);
60 break;
61 case b8: output = medfilt1<char>(in, wind_width, edge_pad); break;
62 case s32: output = medfilt1<int>(in, wind_width, edge_pad); break;
63 case u32: output = medfilt1<uint>(in, wind_width, edge_pad); break;
64 case s16: output = medfilt1<short>(in, wind_width, edge_pad); break;
65 case u16:
66 output = medfilt1<ushort>(in, wind_width, edge_pad);
67 break;
68 case s8: output = medfilt1<schar>(in, wind_width, edge_pad); break;
69 case u8: output = medfilt1<uchar>(in, wind_width, edge_pad); break;
70 default: TYPE_ERROR(1, type);
71 }
72 std::swap(*out, output);
73 }
74 CATCHALL;
75
76 return AF_SUCCESS;
77}
78
79template<typename T>
80inline af_array medfilt2(af_array const &in, dim_t w_len, dim_t w_wid,

Callers 5

af_medfilt2Function · 0.70
medfilt1_TestFunction · 0.50
medfilt1d_WindowTestFunction · 0.50
medfilt1d_PadTestFunction · 0.50
medfilt1Function · 0.50

Calls 5

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

Tested by

no test coverage detected