This script takes two pictures as input and swaps their n most prominent characteristic colours.
The operations done to achieve this are
- Definition of the input pictures, and the parameter for the number of colours.
- Clustering of the colors on each picture with K-Means. It takes as input the color information of all pixels and finds the ones that can be grouped together.
- Rank the clusters by size and for each one calculate a representative RGB value.
- Swap the RGB values of the clusters in the two images.
- Smoothen the resulting image with a gaussian filter