-
Notifications
You must be signed in to change notification settings - Fork 550
Expand file tree
/
Copy pathsat.cpp
More file actions
61 lines (53 loc) · 1.88 KB
/
sat.cpp
File metadata and controls
61 lines (53 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <common/err_common.hpp>
#include <handle.hpp>
#include <imgproc_common.hpp>
#include <af/defines.h>
#include <af/image.h>
using af::dim4;
using arrayfire::common::integralImage;
using detail::cdouble;
using detail::cfloat;
using detail::intl;
using detail::schar;
using detail::uchar;
using detail::uint;
using detail::uintl;
using detail::ushort;
template<typename To, typename Ti>
inline af_array sat(const af_array& in) {
return getHandle<To>(integralImage<To, Ti>(getArray<Ti>(in)));
}
af_err af_sat(af_array* out, const af_array in) {
try {
const ArrayInfo& info = getInfo(in);
const dim4& dims = info.dims();
ARG_ASSERT(1, (dims.ndims() >= 2));
af_dtype inputType = info.getType();
af_array output = 0;
switch (inputType) {
case f64: output = sat<double, double>(in); break;
case f32: output = sat<float, float>(in); break;
case s32: output = sat<int, int>(in); break;
case u32: output = sat<uint, uint>(in); break;
case b8: output = sat<int, char>(in); break;
case s8: output = sat<int, schar>(in); break;
case u8: output = sat<uint, uchar>(in); break;
case s64: output = sat<intl, intl>(in); break;
case u64: output = sat<uintl, uintl>(in); break;
case s16: output = sat<int, short>(in); break;
case u16: output = sat<uint, ushort>(in); break;
default: TYPE_ERROR(1, inputType);
}
std::swap(*out, output);
}
CATCHALL;
return AF_SUCCESS;
}