Member-only story

How to Get the Most Dominant Color of an Image

Get the name of the most dominant color of an image to use it as a feature in a machine learning model

George Pipis
Better Programming
Person carrying basket and color breakdown of the image
Photo by Predictive Hacks.

When we build machine learning models on images, apart from the image labels, we also want to get their color names — usually as categorical variables. For that reason, we need to convert the RGB pixels into color labels.

How to Get the Name of the Most Dominant Colors

The logic is to iterate over all image pixels and to get their labels. Then, based on the frequency, we will get the n most frequent color names.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

No responses yet

Write a response