Quantize Color

Quantize Color icon {width="200px"}

In: Filters > Adjustments

Description

Reduces the amount of colors in a color image, effectively flattening gradients.

In addition to the processed image, the node also extracts the following:

  • palette  of the remaining colors, which may be used to colorize other images
  • An  ID map  of the quantized areas, which may be used to recolorize the processed image using a different palette
  • The  amount  of remaining colors as a raw integer value

If the ‘Ignore alpha’ parameter is set to ‘False’, the alpha channel of the original image is used to select the areas of the image from which the colors should be extracted for the quantization process, while colors in transparent areas are ignored.

This effectively provides some control over the extracted colors.

This node may be used in combination with the following nodes: Create Color Palette, Apply Color Palette, Modify Color Palette, View Color Palette.

Output connectors

Parameters

Input connectors

Input Color PRIMARY
The color image which should be quantized.

Output connectors

Output Color
The quantized color image.
ID Grayscale

A map where each quantized color is assigned a unique integer identifier.   This may be used to:

Palette Color
The palette extracted from the image, holding the remaining colors after quantization.   The image is an ordered list of RGB colors encoded as a row of pixels, and can hold a maximum of 256 colors.   The palette may be visualized with the View Color Palette node.
Palette color amount Integer
The amount of colors stored in the palette.

Parameters

Max. color amount Integer
The maximum amount of colors which should be used in the quantized image.   This amount is the same used in the Palette extracted from the image.   ‘Maximum’ means this amount may not be met, because of the quantization technique being used. Check the ‘Palette Color Amount’ output for the actual amount of extracted colors.
Contour smoothing Float
Controls the radius of a smoothing effect applied to the input image, used to simplify the quantized image into more solid, cohesive shapes.   Note: This smoothing requires intensive computations thus raising this value noticeably increases the node’s computation time.
Dithering Float
Applies a dithering pattern in order to recreate the gradients and color blends in the original image, while still only using the colors remaining after the quantization.   Make sure to use a ‘Contour Smoothing’ value of 0 to produce the expected dithering effect.
Dithering pattern Integer

The dithering pattern used to recreate the gradients and color blends in the original image:

  • Blue noise
  • Bayer
Ignore alpha Boolean
By default, the alpha channel of the original image is used to select the areas of the image from which the colors should be extracted for the quantization process, while colors in transparent areas are ignored. This effectively provides some control over the extracted colors.   Indeed, you may wish to only use the colors in the visible parts of the image for the quantization process.   This toggle lets you disable this masking and use the  full  image regardless of transparency.
Distance color space Integer

Colors are arranged in a  cube  which width, height and depth are a gradient where each component of a color increases from 0 to 1 (E.g. red, green and blue in RGB).   The quantization process involves selecting the  defining colors  in an image, then finding the colors closest to them in the cube and replacing them with that defining color.   This parameter lets you select the color space used to distribute colors in the cube, which changes the result of the quantization by changing the criteria for detecting a defining color and rearranging neighbouring colors.   You may select the color space which fits your use case:

  • Lab (Color): A standardized perceptual color space, which distributes colors in such a way that colors that ‘feel’ close are actually close in the cube. This is appropriate for image which may be visualised on displays
  • RGB (Data): Color is split into Red, Green and Blue and distributed straight along those axis, disregarding human perception. This is appropriate for images holding raw data, such as normal maps
ID sort mode Integer

Colors are arranged in a  cube  where width, height and depth are a gradient where each component of a color increases from 0 to 1 (E.g. red, green and blue in RGB).   This parameter selects the method used to order the list of colors in the extracted palette, and the indexes in the areas of the extracted ID map:

  • Z-curve: colors are sorted by next found in the color cube using a Z-curve, from white to black
  • Hue: colors are sorted by closest hue
  • Representativity: colors are sorted from most to least used in the quantized image
Downscale filtering Integer

The color quantization process involves computing a histogram of an image at a reduced size (I.e. downscaled), in order to sort its colors by importance. This parameter controls the method of filtering the downscaled image before computing its histogram:

  • Bilinear: applies bilinear filtering to the image, resulting in a histogram with interpolated colors which may not be part of the original image, diluting some of the original colors. This helps with images using lots of colors.
  • Nearest: samples the color of the nearest pixel with no filtering, resulting in a histogram using colors from the original image exclusively. This is appropriate for images using few colors.

Examples

quantize_color_example_6_before
Before
quantize_color_example_6_after
After
quantize_color_example_2_before
Before
quantize_color_example_2_after
After
quantize_color_example_3_before
Before
quantize_color_example_3_after
After
quantize_color_example_4_before
Before
quantize_color_example_4_after
After
quantize_color_example_5_before
Before
quantize_color_example_5_after
After
recommendation-more-help
dd48abc6-e399-43d2-9777-578ec70c5a23