Assignment 2 Sol
Assignment 2 Sol
M541
Assignment #2
Briefly explain why we need to have less than 24-bit color and what do we
need to do to adaptively transform 24-bit color values to 8-bit ones?
We need less than 24-bit color for memory e?iciency with 8-bit color using less memory
(256 colors), improved performance in low-fidelity applications, and compatibility with
older systems that only support 8-bit color.
To adaptively transform 24-bit color values to 8-bit ones, we can use the median-cut
algorithm as follows:
1. Find the Color Box: Identify the smallest box that contains all colors in the image.
2. Sort and Split: Sort the colors along the longest dimension of the box and split it at the
median value, creating two regions.
3. Iterate: Repeat the sorting and splitting process until the color space is divided into 256
regions.
4. Calculate Representative Colors: For each region, compute the mean RGB values to
determine the representative (center) color.
5. Assign Colors: For each pixel, calculate the Euclidean distance to each representative
color and assign the pixel to the closest one.
6. Create Lookup Table: Replace the pixel color with an index from a lookup table that
corresponds to the representative colors, storing these indices in the new color-quantized
image.
This method focuses on distributing color information e?ectively, concentrating bits where
color di?erences are most noticeable, and helps minimize visual artifacts in the resulting
image.