Percentage of color colors in an image

I have a 200x200px image with a circle divided into 4 different colors (, green, red, blue, yellow ). The background of this image is transparent, so I know that each color represents 25% or 1/4 of the total colors of the entire image.

How do I create a function that calculates the percentage of a certain color using Python + OpenCv?

CIRCULO

clustering.

  • k-means if you know k
  • meanshift if you don’t

or simple equality/inRange and counting, if you know the colors already.

…and use the HSV color space.