Find Common Colours in an Image
·
251 words
·
2 minutes read
This is part 1 of how to find the dominant colours within an image. You might spot this functionality around the internet, as it’s used to give images background colours before the image has loaded.
We use a package to do this - which manages much of the heavy lifting. The package, called prominentcolor, uses the Kmeans++
algorithm to work this out. By default, it will return us the three most popular colours after both cropping and resizing the image.
First, we load the image from file into an Image
type. This can them be passed in to be processed. Once we have our three colours, we simply print each one to screen.
|
|