0

I was looking for the answer and I find this code for calc the centroid coordinates:

from skimage.measure import regionprops

regions = regionprops(segments)
for props in regions:
    cx, cy = props.centroid  # centroid coordinat

So, what I need to do with this centroids to calc the dominant color in python? In other hand, I was thinking about use K-means with Opencv to obtain it but I'm confusing...

My intention is representing the dominat color feature from each superpixel for each color channels like b,g,r, h,s,v, l,a,b, l,u,v...

I'd like to have some help to resolve it. Thanks a lot

  • Does [this post](https://stackoverflow.com/questions/43111029/how-to-find-the-average-colour-of-an-image-in-python-with-opencv/43111221#43111221) help? – Tonechas Apr 07 '21 at 08:21
  • 1
    Does this answer your question? [How to find the average colour of an image in Python with OpenCV?](https://stackoverflow.com/questions/43111029/how-to-find-the-average-colour-of-an-image-in-python-with-opencv) – Kevin Apr 07 '21 at 21:58
  • Thanks! You guys helped me a lot!I have one more question.I am doing a segmentation process and the input of this algorithm to find the dominant color is related to a super pixel of 1 color channel.So the value of k = 1?Another problem I am having is with my entry. How can I adjust this size so that the algorithm works?I currently have the following error: File "C:\Users\felip\Desktop\Projetos\main-ms-python-testes\features.py", line 204, in get_dominantcolor img = img.reshape((img.shape[0] * img.shape[1], 3)) ValueError: cannot reshape array of size 83200 into shape (83200,3) – Felipe Assunção Apr 09 '21 at 12:56

0 Answers0