Can I identify the main colors in an image?

Hi.

I like to use - as I thought possibly – a Core ML model to identify the main clouts of an image. The idea is to detect used colors in fashion images to get a kind of a "color trend" in a set of images.

I found this question in the forum already, but it never got an answers (as questions to the questions did not get answered by the initial poster):

https://developer.apple.com/forums/thread/94324

Maybe, Core Models are not the way to do this (are there more about objects and texts)? Any hint to other techniques are welcome, too.

The only approach I do not want to follow is to use online services as images have to get delivered to them – and usually are kept there. I want to realize an on-premise approach.

Thanks for any hints!

The questions asked in the other post https://developer.apple.com/forums/thread/94324 do apply to yours.

Do you want to have a statistics of colors used, if so Core ML is not the right way to go, or detect shapes and find their dominant colors (here a combination of Core ML and stats would be appropriate).

However a basic stats on colors may not be very efficient (too many colors).

What you could try:

  • analyse the image colors, point per point
  • map it in a 3D space (x for red, y for green, z for blue)
  • That will give a cloud of points
  • Then you could try to perform some cluster analysis to find the main color clusters. Core ML could be used :

h t t p s : / / medium.com/nerd-for-tech/core-ml-e840938a55d9

and open source to do it:

h t t p s : / / awesomeopensource.com/project/eheitfield/SwiftCluster?categoryPage=41

Finding dominant colors of an image using k-means clustering

DominantColor

Can I identify the main colors in an image?
 
 
Q