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

Function af_medfilt2

src/api/c/filters.cpp:86–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86af_err af_medfilt2(af_array *out, const af_array in, const dim_t wind_length,
87 const dim_t wind_width, const af_border_type edge_pad) {
88 try {
89 ARG_ASSERT(2, (wind_length == wind_width));
90 ARG_ASSERT(2, (wind_length > 0));
91 ARG_ASSERT(3, (wind_width > 0));
92 ARG_ASSERT(4, (edge_pad >= AF_PAD_ZERO && edge_pad <= AF_PAD_SYM));
93
94 const ArrayInfo &info = getInfo(in);
95 af::dim4 dims = info.dims();
96
97 if (info.isColumn()) {
98 return af_medfilt1(out, in, wind_width, edge_pad);
99 }
100
101 dim_t input_ndims = dims.ndims();
102 DIM_ASSERT(1, (input_ndims >= 2));
103
104 if (wind_length == 1) {
105 *out = retain(in);
106 return AF_SUCCESS;
107 }
108 af_array output = nullptr;
109 af_dtype type = info.getType();
110 switch (type) {
111 case f32:
112 output = medfilt2<float>(in, wind_length, wind_width, edge_pad);
113 break;
114 case f64:
115 output =
116 medfilt2<double>(in, wind_length, wind_width, edge_pad);
117 break;
118 case b8:
119 output = medfilt2<char>(in, wind_length, wind_width, edge_pad);
120 break;
121 case s32:
122 output = medfilt2<int>(in, wind_length, wind_width, edge_pad);
123 break;
124 case u32:
125 output = medfilt2<uint>(in, wind_length, wind_width, edge_pad);
126 break;
127 case s16:
128 output = medfilt2<short>(in, wind_length, wind_width, edge_pad);
129 break;
130 case u16:
131 output =
132 medfilt2<ushort>(in, wind_length, wind_width, edge_pad);
133 break;
134 case s8:
135 output = medfilt2<schar>(in, wind_length, wind_width, edge_pad);
136 break;
137 case u8:
138 output = medfilt2<uchar>(in, wind_length, wind_width, edge_pad);
139 break;
140 default: TYPE_ERROR(1, type);
141 }
142 std::swap(*out, output);
143 }

Callers 7

af_medfiltFunction · 0.70
medfiltTestFunction · 0.50
medfiltImageTestFunction · 0.50
medfiltInputTestFunction · 0.50
medfiltWindowTestFunction · 0.50
medfiltPadTestFunction · 0.50
medfilt2Function · 0.50

Calls 7

retainFunction · 0.85
swapFunction · 0.85
isColumnMethod · 0.80
af_medfilt1Function · 0.70
dimsMethod · 0.45
ndimsMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected