Blink API
Main Page
Related Pages
Namespaces
Classes
Files
File List
blurAndGainExampleKernels.h
1
// Source string for the Gain kernel.
2
static
const
char
*
const
GainKernel =
"\
3
kernel GainKernel : ImageComputationKernel<eComponentWise>\n\
4
{\n\
5
Image<eReadWrite> dst;\n\
6
\n\
7
param:\n\
8
float multiply;\n\
9
\n\
10
void define() {\n\
11
defineParam(multiply, \"Gain\", 1.0f);\n\
12
}\n\
13
\n\
14
void process() {\n\
15
dst() *= multiply;\n\
16
}\n\
17
};\n\
18
"
;
19
20
// Source string for the Blur kernel.
21
static
const
char
*
const
BlurKernel =
"\
22
kernel BlurKernel : ImageComputationKernel<eComponentWise>\n\
23
{\n\
24
Image<eRead, eAccessRanged1D, eEdgeClamped> src; //the input image\n\
25
Image<eWrite> dst; //the output image\n\
26
\n\
27
param:\n\
28
int radius;\n\
29
bool horizontal;\n\
30
\n\
31
//In define(), parameters can be given labels and default values.\n\
32
void define() {\n\
33
defineParam(radius, \"Radius\", 10);\
34
defineParam(horizontal, \"Horizontal\", true);\
35
}\n\
36
\n\
37
//The init() function is run before any calls to kernel().\n\
38
void init() {\n\
39
Axis axis = horizontal ? eX : eY;\n\
40
src.setAxis(axis);\n\
41
src.setRange(-radius, radius);\n\
42
}\n\
43
\n\
44
//The kernel function is run at every pixel to produce the output.\n\
45
void process() {\n\
46
ValueType(dst) value = 0;\n\
47
for(int x = -radius; x <= radius; ++x) {\n\
48
value += src(x);\n\
49
}\n\
50
dst() = value / (2 * radius + 1);\n \
51
}\n\
52
};\n\
53
"
;
©2022 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.foundry.com