title: color percentage in image python opencv using histogram
body: <p>I am beginner in python and image processing. I want to find the percentage of brown color from an image using histogram function.</p>
  
  <p>I did the histogram function but I do not know how to find the percentage of the brown color in the image. </p>
  
  <p>this is my python code </p>
  
  <pre><code>import cv2
  import numpy as np
  from matplotlib import pyplot as plt
  
  img = cv2.imread('C:\Users\MainUser\Desktop\histogram\dates.jpg', -1)
  cv2.imshow('GoldenGate',img)
  
  color = ('b','g','r')
  for channel,col in enumerate(color):
      histr = cv2.calcHist([img],[channel],None,[256],[0,256])
      plt.plot(histr,color = col)
      plt.xlim([0,256])
  plt.title('Histogram for color scale picture')
  plt.show()
  
  while True:
      k = cv2.waitKey(0) &amp; 0xFF     
      if k == 27: break             # ESC key to exit 
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>the image that I use</p>
  
  <p><a href="https://i.stack.imgur.com/J9MbW.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/J9MbW.jpg" alt="the image that I use "></a></p>
  
  <p>I have this output of the code
  <a href="https://i.stack.imgur.com/oP2EM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/oP2EM.png" alt="enter image description here"></a></p>