November 2017
Intermediate to advanced
1035 pages
11h 31m
English
In the previous sections, we used clustering to explore the structure of a dataset. Now let's apply it to a different problem. Image quantization is a lossy compression method that replaces a range of similar colors in an image with a single color. Quantization reduces the size of the image file since fewer bits are required to represent the colors. In the following example, we will use clustering to discover a compressed palette for an image that contains its most important colors. We will then rebuild the image using the compressed palette. This example requires the mahotas image processing library, which can be installed using pip install mahotas:
>>> import numpy as np >>> import matplotlib.pyplot as plt >>> from sklearn.cluster ...
Read now
Unlock full access