title: Plotting HSV channel histograms from a BGR image Opencv
body: <p>I have B,G,R histograms that look like the following:
  <a href="https://i.stack.imgur.com/X8vFP.png" rel="nofollow noreferrer">Image Histogram for B channel of an image</a></p>
  <p>Description: On the X axis, I have the values from 0-255, that each pixel ranges from, and on Y axis, I have the number of pixels that have that particular X value.<br />
  My code for the same is:</p>
  <pre><code>hist1 = cv2.calcHist([image],[0],None,[256],[0,256])
  plt.plot(hist1, color='b')
  plt.xlabel(&quot;Value (blue)&quot;)
  plt.ylabel(&quot;Number of pixels&quot;)
  plt.title('Image Histogram For Blue Channel')
  plt.show()
  </code></pre>
  <p>My question is, that I need to get the same plot - X axis with values, and Y axis with number of pixels, for HSV channels. Basically, instead of B, G, and R plots, I need the same histogram, but one that gets H, S, I.</p>
  <p>I got the following code:</p>
  <pre><code>img2 = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
  h, s, v = img2[:,:,0], img2[:,:,1], img2[:,:,2]
  hist_h = cv2.calcHist([h],[0],None,[256],[0,256])
  #hist_s = cv2.calcHist([s],[0],None,[256],[0,256])
  #hist_v = cv2.calcHist([v],[0],None,[256],[0,256])
  plt.plot(hist_h, color='r', label=&quot;hue&quot;)
  </code></pre>
  <p>Which gives me the following plot: <a href="https://i.stack.imgur.com/gnNXl.png" rel="nofollow noreferrer">Hue plot for an image</a></p>
  <p>But from what I've read so far, BGR and HSV are different color spaces. So, I want to know, that when I'm using the calcHist function after converting to HSV, and then splitting into three channels, those channels by default are H,S and V? It's not that they're actually only BGR, but just simply mislabelled H, S and V? I just want to verify how both the methods are practically the same, but BGR and HSV are different color spaces.</p>
  <p>Edit: Here's the source image
  <a href="https://i.stack.imgur.com/WAqo5.jpg" rel="nofollow noreferrer">Image</a></p>