Blink API

blurAndGainExampleKernels.h

00001 
00002 // Source string for the Gain kernel.
00003 static const char* const GainKernel = "\
00004 kernel GainKernel : ImageComputationKernel<eComponentWise>\n\
00005 {\n\
00006   Image<eReadWrite> dst;\n\
00007 \n\
00008   param:\n\
00009     float multiply;\n\
00010 \n\
00011   void define() {\n\
00012     defineParam(multiply, \"Gain\", 1.0f);\n\
00013   }\n\
00014 \n\
00015   void process() {\n\
00016     dst() *= multiply;\n\
00017    }\n\
00018 };\n\
00019 ";
00020 
00021 // Source string for the Blur kernel.
00022 static const char* const BlurKernel = "\
00023 kernel BlurKernel : ImageComputationKernel<eComponentWise>\n\
00024 {\n\
00025   Image<eRead, eAccessRanged1D, eEdgeClamped> src;  //the input image\n\
00026   Image<eWrite> dst;  //the output image\n\
00027 \n\
00028   param:\n\
00029    int radius;\n\
00030    bool horizontal;\n\
00031 \n\
00032   //In define(), parameters can be given labels and default values.\n\
00033   void define() {\n\
00034     defineParam(radius, \"Radius\", 10);\
00035     defineParam(horizontal, \"Horizontal\", true);\
00036   }\n\
00037 \n\
00038   //The init() function is run before any calls to kernel().\n\
00039   void init() {\n\
00040     Axis axis = horizontal ? eX : eY;\n\
00041     src.setAxis(axis);\n\
00042     src.setRange(-radius, radius);\n\
00043   }\n\
00044 \n\
00045   //The kernel function is run at every pixel to produce the output.\n\
00046   void process() {\n\
00047     ValueType(dst) value = 0;\n\
00048     for(int x = -radius; x <= radius; ++x) {\n\
00049       value += src(x);\n\
00050     }\n\
00051     dst() = value / (2 * radius + 1);\n \
00052   }\n\
00053 };\n\
00054 ";
 All Classes Namespaces Files Functions Variables


©2013 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.thefoundry.co.uk