Apple Shake 4 User Manual

Page 866

Advertising
background image

866

Chapter 28

Filters

sobelH: horizontal embossing

sobelV: veritcal embossing

BabuV: another vertical edge detection

BabuH: another horizontal edge detection

You can use these convolution matrixes as is, or as models to create your own matrixes.

Creating Custom Convolution Kernels

Convolution kernels consist of properly formatted data, which is used by the Convolve
node to produce the desired image processing effect. This data is included by default
in the include/nreal.h file, but may also be placed in other files in the same way you
would add a macro. For example, you could add convolution kernels to include/startup/
my_file.h
.

A convolution kernel must have the following information. Each parameter should be
followed by a comma:

The kernel begins with the following declaration:

DefKernel (

The first parameter is the kernel’s name, enclosed in quotes.

The second parameter is the size of the kernel matrix—in this case, 5 x 5.

The third parameter is the gain factor. Each number is multiplied by this number, so 1
results in no change.

The fourth parameter is the offset, which is added to the result before it is clamped/
quantized. 0 results in no offset.

Next, the kernel matrix is entered as a comma-delimited list. In the case of a 5 x 5
matrix, this list would take the form of five lines of five comma-delimited values.

The final line should be the end parenthesis and a semicolon, to end the declaration.

Here’s an example of a properly formatted kernel:

DefKernel(

“edge5x5”,
5, 5,
1,
0,
-1, -1, -1, -1, -1,
-1, -1, -1, -1, -1,
-1, -1, 24, -1, -1,
-1, -1, -1, -1, -1,
-1, -1, -1, -1, -1

);

Advertising