(English version first. 中文版在後面。)
Color Quantization and De-dithering
Submit one Jupyter Notebook (.ipynb). The notebook must contain your code, the outputs (figures and tables) and your written answers. See "What your notebook must contain" at the end for the exact checklist.
This homework has two parts:
Sampling is required. To keep running time short, you must fit on randomly sampled pixels wherever this homework says so. With the required sampling, the whole notebook runs in about 3 minutes on a 2-core CPU (e.g. free Google Colab). If your notebook takes much longer, check your sampling first.
A full-color image can use up to 16.7 million colors. Old displays, GIF files and many embedded devices can only show a palette of a few colors, for example 256. Color quantization chooses a good palette and replaces every pixel with the nearest palette color.
Treat every pixel as a point in 3D color space (R, G, B). Then choosing a palette of 256 colors is a clustering problem: group the pixels into 256 clusters and use one representative color per cluster.
Read these pages before you write code:
KMeans, MiniBatchKMeans, BisectingKMeans, AgglomerativeClustering, Birch.GaussianMixture).Answer these questions in your own words. Short answers are fine.