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

Function af_canny

src/api/c/canny.cpp:226–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224} // namespace
225
226af_err af_canny(af_array* out, const af_array in, const af_canny_threshold ct,
227 const float t1, const float t2, const unsigned sw,
228 const bool isf) {
229 try {
230 const ArrayInfo& info = getInfo(in);
231 af::dim4 dims = info.dims();
232
233 DIM_ASSERT(2, (dims.ndims() >= 2));
234 // Input should be a minimum of 5x5 image
235 // since the gaussian filter used for smoothing
236 // the input is of 5x5 size. It's not mandatory but
237 // it is essentially of no use if image is less than 5x5
238 DIM_ASSERT(2, (dims[0] >= 5 && dims[1] >= 5));
239 ARG_ASSERT(5, (sw == 3));
240
241 af_array output;
242
243 af_dtype type = info.getType();
244 switch (type) {
245 case f32:
246 output = cannyHelper<float>(getArray<float>(in), t1, ct, t2, sw,
247 isf);
248 break;
249 case f64:
250 output = cannyHelper<double>(getArray<double>(in), t1, ct, t2,
251 sw, isf);
252 break;
253 case s32:
254 output =
255 cannyHelper<int>(getArray<int>(in), t1, ct, t2, sw, isf);
256 break;
257 case u32:
258 output =
259 cannyHelper<uint>(getArray<uint>(in), t1, ct, t2, sw, isf);
260 break;
261 case s16:
262 output = cannyHelper<short>(getArray<short>(in), t1, ct, t2, sw,
263 isf);
264 break;
265 case u16:
266 output = cannyHelper<ushort>(getArray<ushort>(in), t1, ct, t2,
267 sw, isf);
268 break;
269 case s8:
270 output = cannyHelper<schar>(getArray<schar>(in), t1, ct, t2, sw,
271 isf);
272 break;
273 case u8:
274 output = cannyHelper<uchar>(getArray<uchar>(in), t1, ct, t2, sw,
275 isf);
276 break;
277 default: TYPE_ERROR(1, type);
278 }
279 // output array is binary array
280 std::swap(output, *out);
281 }
282 CATCHALL;
283

Callers 4

cannyTestFunction · 0.50
cannyImageOtsuTestFunction · 0.50
TESTFunction · 0.50
cannyFunction · 0.50

Calls 4

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

Tested by

no test coverage detected