Convolve

Function

This allows you to enter in your very own custom filter. Standard filters are in your include/nreal.h file, and consist of sharpen, edge3x3, edge5x5, nedge3x3, blur3x3, blur5x5, and laplace. You can use these, or, using these as your model, create your own. Just place them in a standard plugins file. There is an example below.

Parameters
Type
Defaults
Function
channels
string
"rgba" The channels on which the filter is applied.
kernel
string
"blur3x3"

blur3x3: A 3x3 pixel blur.
blur5x5: A 5x5 pixel blur
sharpen: Uh, sharpening...
edge3x3: A 3x3 pixel edge detection.
edge5x5: A 5x5 pixel edge detection.
laplace: Edge detection.

percent
float
100 The mixing percent between the modified image and the original image.
absolute
int
0 Some filters return negative values. By turning on absolute, they will be inverted to positive values.


Synopsis

image Convolve( image, 
  const char * channels, 
  const char * kernel, 
  float percent,
  int absolute
);


Script

image = Convolve( 
  image, 
  "channels", 
  "kernel", 
  percent, 
  absolute
);


Command Line

shake -convolve rgba kernel percent


Example

shake lisa.iff -convolve
shake lisa.iff -convolve rgb edge3x3

Example:

Here is an example kernel. These are placed by default in the include/nreal.h file, but may also be placed in any file as you place a macro, i.e. in include/startup/my_file.h.

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
);


shake -convolve rgba edge5x5 100

See Also
Blur, Sharpen, Emboss, Median