Median Cut Color Quantization (MMCQ)¶
Median Cut Color Quantization is an algorithm used to reduce the number of colors in an image while preserving visual similarity. It is widely used in image processing and color palette extraction.
Overview¶
The algorithm works by recursively dividing the RGB color space into smaller „boxes” and selecting representative colors.
Steps¶
Collect all pixels from the image.
Place them into a single 3D RGB box.
Find the color channel (R, G, or B) with the largest range.
Sort pixels along that channel.
Split the box at the median point.
Repeat until the desired number of colors is reached.
Compute the average color of each box to form the palette.
Advantages¶
Simple and efficient
Produces visually good palettes
Widely used