Skip to main content

Max Color Count

This rule checks that the image does not exceed the specified maximum number of colors.

Parameter table

paramunitrequireddescription
maxColorCountCountnoMaximum number of colors allowed in the image (maxColorCount).
masknoBinary image to define regions of interest

Detailed description

This rule checks that the image does not exceed a specified maximum number of colors.The checking process involves iterating through the pixels of the image to count unique colors.The validation ensures that the count does not exceed the specified maximum color count.

If a mask is provided, only the portion of the image corresponding to the white areas of the mask is considered.

Correction

The correction process involves color quantization using the K-means algorithm with K equal to the specified maximum color count. The image is transformed by reducing the number of distinct colors while preserving visual quality.

If a mask is provided, only the portion of the image corresponding to the white areas of the mask is corrected.

How to setup

This rule evaluates whether an image's color count conforms to the specified maximum limit. The only parameter is:

  • maxColorCount: Maximum number of colors allowed in the image.
  • mask: Binary image to define regions of interest.

Creator tips

To reduce the number of colors with greater flexibility, consider the following resources:

Examples

valuevalidmaxColorCountdescription
Mario & Luigi16The image should have a maximum of 16 colors.
Mario16The image should have a maximum of 16 colors.