Answers.Body: <p>You can find an explanation <a href="https://github.com/googleapis/google-cloud-node/issues/1324#issuecomment-250733976" rel="nofollow noreferrer">here</a> (github of the googleapi):</p>
  <blockquote>
  <p>My current understanding of a color's score is a combination of two things:</p>
  <ul>
  <li>What is the focus of the image?</li>
  <li>What is the color of that focus?</li>
  </ul>
  </blockquote>
  <blockquote>
  <p>For example, given the following image:</p>
  </blockquote>
  <blockquote>
  <p><a href="https://i.sstatic.net/V7faF.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/V7faF.png" alt="enter image description here" /></a></p>
  </blockquote>
  <blockquote>
  <p>The focus is clearly the cat, and therefore the color annotation for this image with the highest score (0.15) will be RGB = (232, 183, 135) which is the beige color:</p>
  </blockquote>
  <blockquote>
  <p><a href="https://i.sstatic.net/e3fv7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/e3fv7.png" alt="enter image description here" /></a></p>
  </blockquote>
  <blockquote>
  <p>The green of the grass (despite having more pixels in the image dedicated to it) has a much lower score by virtue of the algorithm's detection that it's the background and not the focus of the image.</p>
  </blockquote>
  <blockquote>
  <p>In other words, higher &quot;scores&quot; means higher confidence that the color in question is prominent in the central focus of the image.</p>
  </blockquote>
  <p>It is analogous to your case. Therefore, using a background removal this can help to find the focus of the image, and then make the histogram of the remaining objects' color. An example of the background removal using deep learning can be found in <a href="https://towardsdatascience.com/background-removal-with-deep-learning-c4f2104b3157" rel="nofollow noreferrer">this post</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-17T23:53:47.050Z
Answers.LastActivityDate: 2020-11-17T23:53:47.050Z
Answers.UserDisplayName: OmG
Body: <p>I was trying Google Cloud's Vision API, and how the dominant colors part shows. I uploaded a sample image, and here is the results for the dominant colors. I realized it doesn't simply count pixel colors and cluster them. The background has many gray pixels which are not included.</p>
  <p>How does it perform dominant colors? How can I do something similar?</p>
  <p><a href="https://i.sstatic.net/wjXTJ.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/wjXTJ.jpg" alt="enter image description here" /></a></p>
  
Tags: <machine-learning><computer-vision><object-detection><image-processing><google-cloud>
Title: How to compute dominant colors in an image?
UserDisplayName: Mary
ThreadText: # How to compute dominant colors in an image?
  
  (Asked by: username_0 on 2020-11-16)
  
  I was trying Google Cloud's Vision API, and how the dominant colors part shows. I uploaded a sample image, and here is the results for the dominant colors. I realized it doesn't simply count pixel colors and cluster them. The background has many gray pixels which are not included.
  
  How does it perform dominant colors? How can I do something similar?
  
  [![enter image description here](https://i.sstatic.net/wjXTJ.jpg)](https://i.sstatic.net/wjXTJ.jpg)
  
  **Tags:** machine-learning, computer-vision, object-detection, image-processing, google-cloud
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-11-17. Score: 1 | Accepted answer
  
  You can find an explanation [here](https://github.com/googleapis/google-cloud-node/issues/1324#issuecomment-250733976) (github of the googleapi):
  
  > My current understanding of a color's score is a combination of two things:
  >
  > * What is the focus of the image?
  > * What is the color of that focus?
  
  > For example, given the following image:
  
  > [![enter image description here](https://i.sstatic.net/V7faF.png)](https://i.sstatic.net/V7faF.png)
  
  > The focus is clearly the cat, and therefore the color annotation for this image with the highest score (0.15) will be RGB = (232, 183, 135) which is the beige color:
  
  > [![enter image description here](https://i.sstatic.net/e3fv7.png)](https://i.sstatic.net/e3fv7.png)
  
  > The green of the grass (despite having more pixels in the image dedicated to it) has a much lower score by virtue of the algorithm's detection that it's the background and not the focus of the image.
  
  > In other words, higher "scores" means higher confidence that the color in question is prominent in the central focus of the image.
  
  It is analogous to your case. Therefore, using a background removal this can help to find the focus of the image, and then make the histogram of the remaining objects' color. An example of the background removal using deep learning can be found in [this post](https://towardsdatascience.com/background-removal-with-deep-learning-c4f2104b3157).
  
  
  ---
  
  