On this page |

This node convolves the pixels of a layer. This node takes the 3×3 neighborhood of each pixel in the input image, multiplies its 9 values by a set of coefficients, adds another set of values, and then combines the 9 modified values. The combined result is written into the output pixel. Use the output of this node as a basic primitive for performing edge detection or neighborhood counting.

Use only the Multiplicative parameters to create an equivalent of a 3×3 convolution, which is the default output since the Additive parameters are initially set to `0`

. Use both the Multiplicative and Additive parameters to create a large variety of 3×3 kernels. Turn off different **Active Terms** so they don’t apply to the **Combine Operation**, which improves performance but restricts the kernel to a specific shape (for example, a plus sign).

Note

Convolution is done in buffer space, which means it doesn’t respect pixel scale.

Click the Recipe menu to apply preset use cases to this node. Use a preset when you want to apply one of these patterns on all 3×3 neighborhoods. See Recipes for more information.

## Parameters ¶

Signature

The layer type that the source accepts.

See Signatures for more information.

Mask

The amount of the new value to mix in with the original value. Higher values mix in more of the new value. Lower values mix in less of the new value. You can also set the RGBA channels to which you apply the effects of this node.

The default value is `1`

, which means this node uses only the new value. See Mask for more information.

Toggle RGB

Turns the Red, Green, and Blue channels on and off.

Red (default)

Applies this node’s effects to the Red channel.

Green (default)

Applies this node’s effects to the Green channel.

Blue (default)

Applies this node’s effects to the Blue channel.

Alpha (default)

Applies this node’s effects to the Alpha channel.

## Multiplicative ¶

Uniform Scale

The amount to scale all coefficients of the kernel. Use this value to set the normalization constant to make the kernel values integral. This value doesn’t apply if **Normalize Kernel** is on.

Use the following dimensions to additionally scale the coefficients by the distance between samples used for the convolution. The samples are the buffer elements in a 3×3 neighborhood around the currently processed buffer element. See Spaces for more information about buffer space.

(asterisk)1

Don’t scale the coefficients.

(asterisk)dX

Scale the coefficients by the image space distance between horizontally adjacent samples. This is the buffer element width.

/dX

Divide the coefficients by the image space distance between horizontally adjacent samples. This is the buffer element width.

Note

Use this value when building gradient kernels.

Top

The three coefficients to multiply with the `(x-1, y+1)`

, `(x, y+1)`

, and `(x+1, y+1)`

pixels.

Middle

The three coefficients to multiply with the `(x-1, y)`

, `(x, y)`

, and `(x+1, y)`

pixels.

Bottom

The three coefficients to multiply with the `(x-1, y-1)`

, `(x, y-1)`

, and `(x+1, y-1)`

pixels.

Normalize Kernel

Normalizes the kernel by the sum of all coefficients. This prevents the application of the kernel from brightening or darkening the image.

The node doesn’t normalize the kernel if the kernel sums to zero (for example, as it does when you use the `Outline`

recipe).

## Additive ¶

Uniform Scale

The amount to scale all additive values.

Use the following dimensions to additionally scale the additive values by the distance between samples used for the convolution. The samples are the buffer elements in a 3×3 neighborhood around the currently processed buffer element. See Spaces for more information about buffer space.

(asterisk)1

Don’t scale the values.

(asterisk)dX

Scale the values by the image space distance between horizontally adjacent samples. This is the buffer element width.

Note

Use this value when building distance fall-off kernels.

/dX

Divide the values by the image space distance between horizontally adjacent samples. This is the buffer element width.

Top

The three values to add to the `(x-1, y+1)`

, `(x, y+1)`

, and `(x+1, y+1)`

pixels.

Middle

The three values to add to the `(x-1, y)`

, `(x, y)`

, and `(x+1, y)`

pixels.

Bottom

The three values to add to the `(x-1, y-1)`

, `(x, y-1)`

, and `(x+1, y-1)`

pixels.

Combine Operation

Mixes each active pixel in the 3×3 neighborhood together to create the output. This combination occurs after each pixel is scaled by the coefficent and has added additional values.

This parameter considers only the **Active Terms** that are on.

Add

Add the computed pixel values together.

Multiply

Multiply the computed pixel values together.

Maximum

Use the pixel value with the largest component out of all computed values.

Minimum

Use the pixel value with the smallest component out of all computed values.

Active Terms

Controls which pixels in the 3×3 neighborhood are active and contribute to the final result.

Terms you turn off aren’t read from the input layer, which slightly increases performance. Off terms also don’t contribute to the **Combine Operation** or have their weights included in the normalization.

Clamp Below Zero

Clamps final resulting values below zero to zero before mixing these pixel values into the original image.

Clamp Above One

Clamps final resulting values above one to one before mixing these pixel values into the original image.

Treat RGBA as Premultiplied

Un-premultiplies the RGBA layers before applying the kernel, and then premultiplies the RGBA layers after applying the kernel. Turn this off when you blur the alpha and color (RGB) layers, because blur operations require premultiplied space.

Note

RGBA layers are usually premultiplied, so applying edge detection to RGB channels reports edges where opacity varies. This lets kernels used for edge detection perform as if the image isn’t premultiplied.

## Inputs ¶

source

The original layer to convolve.

mask

An optional per-pixel mask amount that’s scaled by the **Mask** parameter.

## Outputs ¶

convolve

The convolved source layer.

See also |