Configuring SVG feConvolveMatrix kernelMatrix

The SVG <feConvolveMatrix> filter primitive applies matrix convolution effects—such as blurring, sharpening, edge detection, and embossing—by combining neighboring pixels based on a mathematical grid. The kernelMatrix attribute defines this grid of transformation values, but its behavior, dimensions, and visual outcome depend on several key companion attributes. This guide details the essential parameters that directly configure and control the kernelMatrix.


Core Attributes that Configure kernelMatrix

1. kernelMatrix

2. order

3. targetX and targetY

4. divisor

5. bias

6. edgeMode

7. preserveAlpha

8. kernelUnitLength


Example Configuration

<filter id="sharpen">
  <feConvolveMatrix
    order="3 3"
    kernelMatrix="
       0 -1  0
      -1  5 -1
       0 -1  0"
    divisor="1"
    bias="0"
    targetX="1"
    targetY="1"
    edgeMode="duplicate"
    preserveAlpha="true" />
</filter>