Menu Home

feConvolveMatrix

osbo.com | SVG | Elements | feConvolveMatrix

The feConvolveMatrix SVG element specifies a matrix convolution filter effect.

A convolution combines pixels in the input image with neighboring pixels to produce a resulting image. A wide variety of imaging operations can be achieved through convolutions, including blurring, edge detection, sharpening, embossing and beveling.

colorX,Y = (

sum i=0 to [orderY-1] {

sum j=0 to [orderX-1] {

sourceX-targetX+j,Y-targetY+i * kernelMatrixorderX-j-1,orderY-i-1

} } ) / divisor + bias * alphaX,Y

Syntax

Attributes

bias

Specifies addition to each component after applying the kernelMatrix to the input image and after applying the divisor.

Value
<number>
Default
0

divisor

Specifies division from the number yielded after applying the kernelMatrix to the input image.

Value
<number>
Default
(sum of all values in kernelMatrix or 1 if sum is 0)

edgeMode

Specifies how to extend the input image as necessary with color values so that the matrix operations can be applied when the kernel is positioned at or near the edge of the input image.

Value
duplicate | wrap | none
Default
duplicate

in

Specifies the input for the filter primitive.

If no value is provided and this is the first filter primitive, then this filter primitive will use SourceGraphic as its input. If no value is provided and this is a subsequent filter primitive, then this filter primitive will use the result from the previous filter primitive as its input.

Value
SourceGraphic | SourceAlpha | BackgroundImage | BackgroundAlpha | FillPaint | StrokePaint | <filter-primitive-reference>
Default
SourceGraphic (or result)

kernelMatrix

Specifies the list of numbers that make up the kernel matrix for the convolution.

Values are separated by space characters and/or a comma. The number of entries in the list must equal orderX times orderY.

Value
<list-of-numbers>
Default
(none)

order

Specifies the number of cells in each dimension for kernelMatrix.

The values provided must be integers greater than zero. The first number, orderX, indicates the number of columns in the matrix. The second number, orderY, indicates the number of rows in the matrix. If orderY is not provided, it defaults to orderX.

Value
<number-optional-number>
Default
3

preserveAlpha

Specifies whether the convolution will preserve the alpha channel.

Value
false | true
Default
false

targetX

Specifies the positioning in X of the convolution matrix relative to a given target pixel in the input image.

The leftmost column of the matrix is column number zero. The value must be such that: 0 <= targetX < orderX.

Value
<integer>
Default
floor ( orderX / 2 )

targetY

Specifies the positioning in Y of the convolution matrix relative to a given target pixel in the input image.

The topmost row of the matrix is row number zero. The value must be such that: 0 <= targetY < orderY.

Value
<integer>
Default
floor ( orderY / 2 )

Examples

bias

<number>

divisor

<number>

edgeMode

duplicate

none

wrap

in

BackgroundAlpha

BackgroundImage

FillPaint

<filter-primitive-reference>

SourceAlpha

SourceGraphic

StrokePaint

kernelMatrix

<list-of-numbers>

order

<number-optional-number>

preserveAlpha

false

true

targetX

<integer>

targetY

<integer>

Internal

feBlend

feColorMatrix

feComponentTransfer

feComposite

feDiffuseLighting

feDisplacementMap

feDistantLight

feDropShadow

feFlood

feFuncA

feFuncB

feFuncG

feFuncR

feGaussianBlur

feImage

feMerge

feMergeMode

feMorphology

feOffset

fePointLight

feSpecularLighting

feSpotLight

feTile

feTurbulence

filter

External

World Wide Web Consortium (W3C)