SVG feColorMatrix: Cinematic Duotone & Color Grading in CSS

The Quick Answer

SVG <feColorMatrix type="matrix"> transforms image pixel channels using a 5x4 linear color matrix. To create a signature two-tone duotone effect (like Spotify's brand campaign), compute the perceived luminance of each pixel (0.2126R + 0.7152G + 0.0722B) and map dark shadows to a base tone (such as deep navy or purple) and bright highlights to a vibrant accent (such as hot pink or electric green).

Interactive Demo Live Preview
SVG feColorMatrix Duotone Grading
CINEMATIC DUOTONE
Luminance-to-Alpha Color Mapping Active

Step 1: The Mathematics of the 5x4 feColorMatrix Transform

An SVG <feColorMatrix> multiplies incoming RGBA values by a 5-column, 4-row matrix. Each row defines the new Red, Green, Blue, and Alpha output channel respectively.

matrix-math.svg
<!-- 5x4 Matrix Layout:
     [ R_r  R_g  R_b  R_a  R_offset ]
     [ G_r  G_g  G_b  G_a  G_offset ]
     [ B_r  B_g  B_b  B_a  B_offset ]
     [ A_r  A_g  A_b  A_a  A_offset ]
-->
<svg style="display: none;">
  <filter id="duotone-cyberpunk">
    <feColorMatrix type="matrix" values="
      0.33 0.33 0.33 0 0.12
      0.33 0.33 0.33 0 0.08
      0.33 0.33 0.33 0 0.85
      0    0    0    1 0" />
  </filter>
</svg>

Step 2: Luminance Mapping: Converting Images to Grayscale First

Authentic duotone requires first converting the photo to perceived luminance using ITU-R BT.709 weights (0.2126 R + 0.7152 G + 0.0722 B), and then multiplying that single luminance scalar by your shadow and highlight RGB vectors.

duotone-filter.html
<svg width="0" height="0">
  <filter id="duotone-spotify">
    <!-- Step 1: Calculate grayscale luminance -->
    <feColorMatrix type="matrix" values="
      0.2126 0.7152 0.0722 0 0
      0.2126 0.7152 0.0722 0 0
      0.2126 0.7152 0.0722 0 0
      0      0      0      1 0" result="gray" />
    
    <!-- Step 2: Map Dark Navy (#091e3a) to Neon Teal (#10b981) -->
    <feComponentTransfer in="gray">
      <feFuncR type="table" tableValues="0.03 0.06" />
      <feFuncG type="table" tableValues="0.11 0.72" />
      <feFuncB type="table" tableValues="0.22 0.50" />
    </feComponentTransfer>
  </filter>
</svg>

Step 3: Applying SVG Filters in CSS via filter: url()

Once defined, apply the filter to any HTML <img>, <video>, or background container using the CSS filter: url(#id) property.

apply-duotone.css
.hero-portrait {
  filter: url(#duotone-spotify);
  transition: filter 0.4s ease;
}

.hero-portrait:hover {
  /* Smoothly reveal natural colors on hover */
  filter: none;
}

Step 4: Hollywood Teal-and-Orange Blockbuster Grading

The most popular cinematic color grade pushes shadows into cool teal/cyan and skin tones/highlights into warm orange. Achieve this with a single high-speed matrix.

teal-orange.svg
<filter id="teal-orange">
  <feColorMatrix type="matrix" values="
    1.4  0.0  0.0 0 -0.05
    0.0  1.1  0.0 0  0.00
    0.0  0.0  0.7 0  0.15
    0.0  0.0  0.0 1  0.00" />
</filter>

Next-Level Addons: Elevating Your Implementation

Take this technique further by combining it with complementary design token studios and animation tools:

Preset: Spotify Cyber-Wash feColorMatrix

1. Image Duotone & Color Matrix Filter Generator

Explore in Duotone Matrix Studio →

Design signature brand photo grading with mathematical SVG feColorMatrix filters. Export pure CSS and inline SVG.

Original Duotone Filter

2. Comparison Testing in Before/After Slider Studio

Explore in Before/After Slider Studio →

Compare original raw photography against the SVG duotone graded version with an interactive split slider.

Halftone Dots + Duotone Retro Print

3. Halftone Pop-Art in Halftone Dither Studio

Explore in Halftone Dither Studio →

Combine two-tone color matrices with vintage comic book halftone dot screens for authentic retro print styling.

Chaam
Chaam's Pro Tip

When building high-performance UI animations or particle systems, my golden rule is: never calculate layout triggers (like getBoundingClientRect() or offsetHeight) inside animation loops. Read measurements once upfront and use CSS transforms or Canvas for buttery 60fps.

Why I Built the Image Duotone & Color Matrix Filter Generator Studio

I got tired of guessing values and testing browser quirks in DevTools, so I built this tool to tweak and preview values in real time with 1-click code export.

Open in Image Duotone & Color Matrix Filter Generator ↗

Frequently Asked Questions

Practical answers to common implementation questions, browser quirks, and performance tips.

Why use SVG feColorMatrix instead of CSS mix-blend-mode for duotones?

`mix-blend-mode` requires stacking multiple DOM layers and pseudo-elements over an image. SVG `feColorMatrix` operates directly on the image pixels in a single pass on the GPU, allowing dynamic application to `

What is the role of the 5th column in each row of the matrix?

The first 4 columns multiply the incoming R, G, B, and A channels. The 5th column is a constant offset (bias) added directly to that channel, ranging from -1.0 to +1.0.

Can SVG feColorMatrix filters be applied to live HTML5 video?

Yes! Applying `filter: url(#my-matrix)` to an HTML5 `

How do ITU-R BT.709 luminance coefficients work?

Human eyes are most sensitive to green, moderately sensitive to red, and least sensitive to blue. The formula `0.2126*R + 0.7152*G + 0.0722*B` calculates the true perceived brightness of a pixel.

Can I animate the matrix values using CSS transitions?

Direct CSS interpolation between SVG matrix values is not natively supported by all browsers. Instead, cross-fade between two elements, or interpolate `filter: url(#duotone)` to `filter: none`.

← Back to all blog guides Launch Generator Studio →