| 199 | } |
| 200 | |
| 201 | af_err af_confidence_cc(af_array* out, const af_array in, const af_array seedx, |
| 202 | const af_array seedy, const unsigned radius, |
| 203 | const unsigned multiplier, const int iter, |
| 204 | const double segmented_value) { |
| 205 | try { |
| 206 | const ArrayInfo& inInfo = getInfo(in); |
| 207 | const ArrayInfo& seedxInfo = getInfo(seedx); |
| 208 | const ArrayInfo& seedyInfo = getInfo(seedy); |
| 209 | const af::dim4& inputDimensions = inInfo.dims(); |
| 210 | const af::dtype inputArrayType = inInfo.getType(); |
| 211 | |
| 212 | // TODO(pradeep) handle case where seeds are towards border |
| 213 | // and indexing may result in throwing exception |
| 214 | // TODO(pradeep) add batch support later |
| 215 | ARG_ASSERT( |
| 216 | 1, (inputDimensions.ndims() > 0 && inputDimensions.ndims() <= 2)); |
| 217 | |
| 218 | ARG_ASSERT(2, (seedxInfo.ndims() == 1)); |
| 219 | ARG_ASSERT(3, (seedyInfo.ndims() == 1)); |
| 220 | ARG_ASSERT(2, (seedxInfo.elements() == seedyInfo.elements())); |
| 221 | |
| 222 | af_array output = 0; |
| 223 | switch (inputArrayType) { |
| 224 | case f32: |
| 225 | output = ccHelper(getArray<float>(in), getArray<uint>(seedx), |
| 226 | getArray<uint>(seedy), radius, multiplier, |
| 227 | iter, segmented_value); |
| 228 | break; |
| 229 | case u32: |
| 230 | output = ccHelper(getArray<uint>(in), getArray<uint>(seedx), |
| 231 | getArray<uint>(seedy), radius, multiplier, |
| 232 | iter, segmented_value); |
| 233 | break; |
| 234 | case u16: |
| 235 | output = ccHelper(getArray<ushort>(in), getArray<uint>(seedx), |
| 236 | getArray<uint>(seedy), radius, multiplier, |
| 237 | iter, segmented_value); |
| 238 | break; |
| 239 | case u8: |
| 240 | output = ccHelper(getArray<uchar>(in), getArray<uint>(seedx), |
| 241 | getArray<uint>(seedy), radius, multiplier, |
| 242 | iter, segmented_value); |
| 243 | break; |
| 244 | default: TYPE_ERROR(0, inputArrayType); |
| 245 | } |
| 246 | swap(*out, output); |
| 247 | } |
| 248 | CATCHALL; |
| 249 | return AF_SUCCESS; |
| 250 | } |