SVG Filter Primitives and feColorMatrix: Formulas Explained

Contents
When you want to add sepia, hue rotation, or inversion to a photo or card on the web, CSS's filter property only lets you adjust predefined preset values, so the range of expression is limited. With SVG filters and primitives, you can implement things like color matrix transforms or linear-function-based brightness and contrast adjustments using web standards alone, with no JavaScript math. This post covers how feColorMatrix changes colors, how to combine feGaussianBlur and feComponentTransfer to create blur, brightness, contrast, and inversion effects, and how to dial in values with sliders and grab the code right away.
Summary ① feColorMatrix recalculates RGBA color values with a 4×5 matrix to change saturation, sepia, and hue. ② Combining feGaussianBlur with feComponentTransfer lets you create blur, brightness, contrast, and inversion effects. ③ If calculating and tuning each value by hand is a hassle, you can adjust sliders in the SVG Filter Generator and get the code instantly.
Why You Need SVG Filters
The CSS filter property (blur, brightness, contrast, saturate, and so on) only lets you adjust predefined values, which makes it hard to fully reconstruct a color or bundle several effects into a single linear function. In SVG, you can chain filter primitive nodes like feGaussianBlur, feColorMatrix, and feComponentTransfer inside a filter tag and let the browser do the math.
How feColorMatrix Changes Colors
feColorMatrix multiplies a pixel's original RGBA values by a 4×5 matrix to reconstruct the color. Written out as formulas, each output channel is calculated like this.
R' = a00×R + a01×G + a02×B + a03×A + a04 G' = a10×R + a11×G + a12×B + a13×A + a14 B' = a20×R + a21×G + a22×B + a23×A + a24 A' = a30×R + a31×G + a32×B + a33×A + a34
In other words, the result color (R', G', B', A') is the original R, G, B, and A values multiplied by each coefficient in the matrix and then added together. For example, a grayscale conversion that drops saturation to 0 works by multiplying R, G, and B by weights based on how much brightness the human eye perceives in each (about 0.2126, 0.7152, and 0.0722) so all three channels land on the same value.
Building Blur, Brightness, and Contrast with feGaussianBlur and feComponentTransfer
feGaussianBlur applies a Gaussian kernel blur by the stdDeviation amount, softening the image. If you add feComponentTransfer with feFuncR/feFuncG/feFuncB set to type="linear", you can apply a linear function of the form result = input × slope + intercept to each channel value in one pass. Here's the SVG filter source that chains these two primitives together.
<svg width="0" height="0">
<filter id="ut-custom-filter">
<!-- 1. Blur -->
<feGaussianBlur stdDeviation="4" />
<!-- 2. Handle brightness, contrast, and inversion with one linear function -->
<feComponentTransfer>
<feFuncR type="linear" slope="1.100" intercept="-0.050" />
<feFuncG type="linear" slope="1.100" intercept="-0.050" />
<feFuncB type="linear" slope="1.100" intercept="-0.050" />
</feComponentTransfer>
</filter>
</svg>
<div class="filter-applied-card">
<h2>SOFT CARD</h2>
<p>A card with blur, brightness, and contrast adjusted together by an SVG filter</p>
</div>
.filter-applied-card {
width: 320px;
padding: 32px;
background: linear-gradient(135deg, #0284c7, #6366f1);
color: #ffffff;
border-radius: 16px;
/* Bind the SVG filter ID */
filter: url(#ut-custom-filter);
}
Raising the slope value makes things brighter and crisper, adjusting intercept shifts the center point of contrast, and flipping the sign of slope produces an inversion effect. You have to repeat the process of calculating and changing each of these values one at a time—if you'd rather adjust sliders and see the result instantly, try it with our tool below.
Dial in the blur, brightness, contrast, saturation, and hue rotation values with sliders, then copy the SVG and CSS filter code right away.

Filter Primitives Quick Reference
| Node | Role |
|---|---|
| feGaussianBlur (stdDeviation="N") | Applies a Gaussian kernel blur in pixel units. |
| feComponentTransfer (type="linear") | Computes brightness, contrast, and inversion in one pass using a linear function defined by slope and intercept. |
| feColorMatrix (type="matrix") | Reconstructs saturation, sepia, and opacity through a 4×5 matrix multiplication. |
| feColorMatrix (type="hueRotate") | Rotates the color wheel by the specified angle to change hue. |
Notes on Performance and Rendering
- The larger the stdDeviation value on feGaussianBlur, the wider the blur radius the browser has to compute, which increases the processing load. If you want smooth playback on mobile, it's better to keep the blur value low.
- When you apply an SVG filter, the edges of the blurred area sometimes get clipped into a rectangular box. If you declare the filter element with a generous boundary area, such as x="-20%" y="-20%" width="140%" height="140%", it renders without clipping.
Wrapping Up
feColorMatrix multiplies RGBA values by a 4×5 matrix to reconstruct color, and combining feGaussianBlur with feComponentTransfer lets you create effects like blur, brightness, contrast, and inversion. You can write the code yourself and tune the values, but it's faster to move sliders, watch the result update in real time, and copy the code straight out.
Dial in the blur, brightness, contrast, saturation, and hue rotation values with sliders, then copy the SVG and CSS filter code right away.
Frequently Asked Questions
How is this different from the CSS filter property?
With SVG <filter> you combine feComponentTransfer, feColorMatrix, and other primitives yourself, which gives you finer and more flexible control than using CSS filter alone. The generated code can be applied directly in CSS as filter: url(#id).
Can I use the generated filter on actual images?
Yes. The tool's preview shows shapes (circles, rectangles, stars), but if you drop the copied SVG code into your HTML and apply the same filter property to an img or any other element, the same effect applies to images too.
How do I reset the values to their starting state?
Press the reset button and every slider returns to its default (blur 0, brightness/contrast/saturation/opacity 1, hue rotation/sepia/inversion 0).
This article was adapted from our Korean original. Read the Korean original