This projects contains a Python script for reducing the number of colors in an image and transforming it into a pixelated version using predefined tile colors. This project uses KMeans clustering to identify dominant colors in the image and maps them to a set of predefined colors.
The image is pixelated to 25×25 pixels by downscaling using the PIL resize function.
The image is reduced to 4 colors using KMeans clustering to find the dominant colors in the image.
The four found colors are remapped to a set of predefined colors - red, white, black, and gray.
This is accomplished by calculating the Euclidean distances in RGB space between the found and predefined colors.