title: Trying to "manually" convert to hsv a bgr image in opencv-python
body: <p>The algorithm I'm using is:</p>
  
  <pre><code>def rgb2hsv(r, g, b):
      r, g, b = r/255.0, g/255.0, b/255.0
      mx = max(r, g, b)
      mn = min(r, g, b)
      df = mx-mn
      if mx == mn:
          h = 0
      elif mx == r:
          h = (60 * ((g-b)/df) + 360) % 360
      elif mx == g:
          h = (60 * ((b-r)/df) + 120) % 360
      elif mx == b:
          h = (60 * ((r-g)/df) + 240) % 360
      if mx == 0:
          s = 0
      else:
          s = df/mx
      v = mx
      return h, s, v
  
  
  
  def my_bgr_to_hsv(bgr_image):
      height, width, c = bgr_image.shape
  
      hsv_image = np.zeros(shape = bgr_image.shape)
  
      #The R,G,B values are divided by 255 to change the range from 0..255 to 0..1:
  
      for h in range(height):
          for w in range(width):
              b,g,r = bgr_image[h,w]
              hsv_image[h,w] = rgb2hsv(r,g,b)      
  
      return hsv_image
  </code></pre>
  
  <p>The problem that I'm getting is that when I want to display the image, I get only a black screen.</p>
  
  <p>This is how I'm trying to display the image:</p>
  
  <pre><code>cv.imshow("hello", cv.cvtColor(np.uint8(hsv_image), cv.COLOR_HSV2BGR))
  </code></pre>
  
  <p>As you can see I convert it back to bgr in order to use cv.imshow, as it only uses bgr.</p>
  
  <p>I don't think I understand enough of opencv or numpy to debug it.</p>
  
  <p>Simply using imshow, shows the original picture in the wrong colors, which makes me think it can't be completely wrong.</p>