forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeanshift.cpp
More file actions
57 lines (50 loc) · 1.63 KB
/
meanshift.cpp
File metadata and controls
57 lines (50 loc) · 1.63 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
/*******************************************************
* 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 <Array.hpp>
#include <err_cpu.hpp>
#include <kernel/meanshift.hpp>
#include <math.hpp>
#include <meanshift.hpp>
#include <platform.hpp>
#include <queue.hpp>
#include <af/dim4.hpp>
#include <algorithm>
#include <cmath>
using af::dim4;
using std::vector;
namespace cpu {
template<typename T>
Array<T> meanshift(const Array<T> &in, const float &spatialSigma,
const float &chromaticSigma, const unsigned &numIterations,
const bool &isColor) {
Array<T> out = createEmptyArray<T>(in.dims());
if (isColor) {
getQueue().enqueue(kernel::meanShift<T, true>, out, in, spatialSigma,
chromaticSigma, numIterations);
} else {
getQueue().enqueue(kernel::meanShift<T, false>, out, in, spatialSigma,
chromaticSigma, numIterations);
}
return out;
}
#define INSTANTIATE(T) \
template Array<T> meanshift<T>(const Array<T> &, const float &, \
const float &, const unsigned &, \
const bool &);
INSTANTIATE(float)
INSTANTIATE(double)
INSTANTIATE(char)
INSTANTIATE(int)
INSTANTIATE(uint)
INSTANTIATE(uchar)
INSTANTIATE(short)
INSTANTIATE(ushort)
INSTANTIATE(intl)
INSTANTIATE(uintl)
} // namespace cpu