| 33 | } |
| 34 | |
| 35 | af_err af_mean_shift(af_array *out, const af_array in, |
| 36 | const float spatial_sigma, const float chromatic_sigma, |
| 37 | const unsigned num_iterations, const bool is_color) { |
| 38 | try { |
| 39 | ARG_ASSERT(2, (spatial_sigma >= 0)); |
| 40 | ARG_ASSERT(3, (chromatic_sigma >= 0)); |
| 41 | ARG_ASSERT(4, (num_iterations > 0)); |
| 42 | |
| 43 | const ArrayInfo &info = getInfo(in); |
| 44 | af_dtype type = info.getType(); |
| 45 | af::dim4 dims = info.dims(); |
| 46 | |
| 47 | DIM_ASSERT(1, (dims.ndims() >= 2)); |
| 48 | if (is_color) { DIM_ASSERT(1, (dims[2] == 3)); } |
| 49 | |
| 50 | af_array output; |
| 51 | switch (type) { |
| 52 | case f32: |
| 53 | output = mean_shift<float>(in, spatial_sigma, chromatic_sigma, |
| 54 | num_iterations, is_color); |
| 55 | break; |
| 56 | case f64: |
| 57 | output = mean_shift<double>(in, spatial_sigma, chromatic_sigma, |
| 58 | num_iterations, is_color); |
| 59 | break; |
| 60 | case b8: |
| 61 | output = mean_shift<char>(in, spatial_sigma, chromatic_sigma, |
| 62 | num_iterations, is_color); |
| 63 | break; |
| 64 | case s32: |
| 65 | output = mean_shift<int>(in, spatial_sigma, chromatic_sigma, |
| 66 | num_iterations, is_color); |
| 67 | break; |
| 68 | case u32: |
| 69 | output = mean_shift<uint>(in, spatial_sigma, chromatic_sigma, |
| 70 | num_iterations, is_color); |
| 71 | break; |
| 72 | case s16: |
| 73 | output = mean_shift<short>(in, spatial_sigma, chromatic_sigma, |
| 74 | num_iterations, is_color); |
| 75 | break; |
| 76 | case u16: |
| 77 | output = mean_shift<ushort>(in, spatial_sigma, chromatic_sigma, |
| 78 | num_iterations, is_color); |
| 79 | break; |
| 80 | case s64: |
| 81 | output = mean_shift<intl>(in, spatial_sigma, chromatic_sigma, |
| 82 | num_iterations, is_color); |
| 83 | break; |
| 84 | case u64: |
| 85 | output = mean_shift<uintl>(in, spatial_sigma, chromatic_sigma, |
| 86 | num_iterations, is_color); |
| 87 | break; |
| 88 | case s8: |
| 89 | output = mean_shift<schar>(in, spatial_sigma, chromatic_sigma, |
| 90 | num_iterations, is_color); |
| 91 | break; |
| 92 | case u8: |
no test coverage detected