forked from hunter-packages/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbilateral.cpp
More file actions
62 lines (54 loc) · 2.3 KB
/
bilateral.cpp
File metadata and controls
62 lines (54 loc) · 2.3 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
62
/*******************************************************
* 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 <af/dim4.hpp>
#include <af/defines.h>
#include <af/image.h>
#include <handle.hpp>
#include <backend.hpp>
#include <bilateral.hpp>
#include <err_common.hpp>
using af::dim4;
using namespace detail;
template<typename inType, typename outType, bool isColor>
static inline af_array bilateral(const af_array &in, const float &sp_sig, const float &chr_sig)
{
return getHandle(bilateral<inType, outType, isColor>(getArray<inType>(in), sp_sig, chr_sig));
}
template<bool isColor>
static af_err bilateral(af_array *out, const af_array &in, const float &s_sigma, const float &c_sigma)
{
try {
ArrayInfo info = getInfo(in);
af_dtype type = info.getType();
af::dim4 dims = info.dims();
DIM_ASSERT(1, (dims.ndims()>=2));
af_array output;
switch(type) {
case f64: output = bilateral<double, double, isColor> (in, s_sigma, c_sigma); break;
case f32: output = bilateral<float , float, isColor> (in, s_sigma, c_sigma); break;
case b8 : output = bilateral<char , float, isColor> (in, s_sigma, c_sigma); break;
case s32: output = bilateral<int , float, isColor> (in, s_sigma, c_sigma); break;
case u32: output = bilateral<uint , float, isColor> (in, s_sigma, c_sigma); break;
case u8 : output = bilateral<uchar , float, isColor> (in, s_sigma, c_sigma); break;
case s16: output = bilateral<short , float, isColor> (in, s_sigma, c_sigma); break;
case u16: output = bilateral<ushort, float, isColor> (in, s_sigma, c_sigma); break;
default : TYPE_ERROR(1, type);
}
std::swap(*out,output);
}
CATCHALL;
return AF_SUCCESS;
}
af_err af_bilateral(af_array *out, const af_array in, const float spatial_sigma, const float chromatic_sigma, const bool isColor)
{
if (isColor)
return bilateral<true>(out,in,spatial_sigma,chromatic_sigma);
else
return bilateral<false>(out,in,spatial_sigma,chromatic_sigma);
}