Basic Image AlgorithmS Library
2.8.0
Main Page
Related Pages
Modules
Classes
Examples
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
OpenCLFramework
Algorithm
clfImageOperator.cpp
1
/*
2
* clfImageOperator.cpp
3
*
4
* Created on: Dec 16, 2011
5
* Author: fkellner
6
*/
7
8
#include <OpenCLFramework/Algorithm/clfImageOperator.hh>
9
#include <Base/Common/BIASpragma.hh>
10
11
using namespace
BIAS;
12
13
clfImageOperator::clfImageOperator
(
clfContext
*ctx,
bool
sharedGL,
unsigned
int
device)
14
:
clfAlgorithm
(ctx,sharedGL,device)
15
{
16
// add code to our program
17
programCL_
->
AddSource
(
"/OpenCLFramework/Algorithm/cl/imageOperator.cl"
);
18
programCL_
->
Build
();
19
programCL_
->
AddKernel
(
"DifferenceImage"
);
20
programCL_
->
AddKernel
(
"DifferenceAbsImage"
);
21
programCL_
->
AddKernel
(
"DifferenceZeroLimitImage"
);
22
programCL_
->
AddKernel
(
"CutOffMinThreshold"
);
23
}
24
25
clfImageOperator::~clfImageOperator
()
26
{
27
}
28
29
void
clfImageOperator::Difference
(
clfImage2D
*im0,
clfImage2D
*im1,
clfImage2D
*result,
bool
asAbs,
bool
zeroCut)
30
{
31
std::string kernelname =
"DifferenceImage"
;
32
if
(asAbs) kernelname =
"DifferenceAbsImage"
;
33
if
(zeroCut) kernelname =
"DifferenceZeroLimitImage"
;
34
programCL_
->
KernelSetArgument
(kernelname, 0, *im0);
35
programCL_
->
KernelSetArgument
(kernelname, 1, *im1);
36
programCL_
->
KernelSetArgument
(kernelname, 2, *result);
37
unsigned
int
w,h;
38
result->
GetImageDim
(w,h);
39
unsigned
int
lx=0, ly=0;
40
if
(w%16==0) lx=16;
41
if
(h%16==0) ly=16;
42
context_
->
RunOn2DRange
(*
programCL_
, kernelname, w,h, lx,ly);
43
}
44
45
void
clfImageOperator::CutOffMinThreshold
(
clfImage2D
*im0,
clfImage2D
*result,
float
minVal) {
46
programCL_
->
KernelSetArgument
(
"CutOffMinThreshold"
, 0, *im0);
47
programCL_
->
KernelSetArgument
(
"CutOffMinThreshold"
, 1, *result);
48
unsigned
int
w,h;
49
result->
GetImageDim
(w,h);
50
unsigned
int
lx=0, ly=0;
51
if
(w%16==0) lx=16;
52
if
(h%16==0) ly=16;
53
context_
->
RunOn2DRange
(*
programCL_
,
"CutOffMinThreshold"
, w,h, lx,ly);
54
}
55
BIAS::clfAlgorithm
Definition:
clfAlgorithm.hh:17
BIAS::clfAlgorithm::programCL_
clfProgram * programCL_
Definition:
clfAlgorithm.hh:35
BIAS::clfProgram::AddSource
std::string AddSource(std::string filename)
adds source code from a file
Definition:
clfProgram.cpp:64
BIAS::clfImage2D::GetImageDim
void GetImageDim(unsigned int &width, unsigned int &height) const
Definition:
clfImage2D.hh:110
BIAS::clfImageOperator::~clfImageOperator
virtual ~clfImageOperator()
Definition:
clfImageOperator.cpp:25
BIAS::clfImage2D
OpenCL Image2D wrapper.
Definition:
clfImage2D.hh:46
BIAS::clfImageOperator::clfImageOperator
clfImageOperator(clfContext *ctx=NULL, bool sharedGL=false, unsigned int device=0)
Definition:
clfImageOperator.cpp:13
BIAS::clfProgram::Build
void Build(int deviceNr=0, std::string options="")
builds the sources added by AddSource and AddSourceFromString
Definition:
clfProgram.cpp:115
BIAS::clfContext
OpenCL Context wrapper.
Definition:
clfContext.hh:49
BIAS::clfProgram::KernelSetArgument
void KernelSetArgument(std::string kernelname, unsigned int argnumber, clfBuffer &buffer)
set kernel argument
Definition:
clfProgram.cpp:177
BIAS::clfProgram::AddKernel
void AddKernel(std::string kernelname)
adds a kernel to the program.
Definition:
clfProgram.cpp:158
BIAS::clfContext::RunOn2DRange
void RunOn2DRange(clfProgram &program, std::string kernelname, unsigned int globalrangeX, unsigned int globalrangeY, unsigned int localrangeX=0, unsigned int localrangeY=0)
run a kernel on a 2D memory range
Definition:
clfContext.cpp:234
BIAS::clfImageOperator::CutOffMinThreshold
void CutOffMinThreshold(clfImage2D *im0, clfImage2D *result, float minVal)
Definition:
clfImageOperator.cpp:45
BIAS::clfAlgorithm::context_
clfContext * context_
Definition:
clfAlgorithm.hh:34
BIAS::clfImageOperator::Difference
void Difference(clfImage2D *im0, clfImage2D *im1, clfImage2D *result, bool asAbs=false, bool zeroCut=false)
Definition:
clfImageOperator.cpp:29
Generated on Tue Feb 6 2018 02:01:42 for Basic Image AlgorithmS Library by
1.8.5