title: why does finding percentage of pixels of pink color in an image not but black does in this code?
body: <p>I have written a code to detect the black and pink pixel percentage in a given image, which seems to work for black but always gives 0.0% for pink, even if the image contains pink. Could someone tell me how I can fix this? Here is the code:</p>
  <pre><code>import cv2 as cv
  import numpy as np
  import os
  
  for i in os.listdir(&quot;C:\\Users\\vikas\\Documents\\PyTest&quot;):
      img = cv.cvtColor(cv.imread(f&quot;C:\\Users\\vikas\\Documents\\PyTest\\{i}&quot;), cv.COLOR_BGR2RGB)
  
      black = [0,0,0]
      pink = [255, 192, 203]
  
      diff_black = 20
      diff_pink = 20
  
      boundaries_black = [([ black[0], black[1], black[2] ],[ black[0]+diff_black, black[1]+diff_black, black[2]+diff_black ])]
      boundaries_pink = [([ pink[0]-diff_pink, pink[1]-diff_pink, pink[2]-diff_pink ],[ pink[0]+diff_pink, pink[1]+diff_pink, pink[2]+diff_pink ])]
  
      scale = 0.3
      height = int(img.shape[0]*scale)
      width = int(img.shape[1]*scale)
      newSize = (width, height)
  
      img = cv.resize(img, newSize, None, None, None, cv.INTER_AREA)
  
      for (lower, upper) in boundaries_black:
          lower = np.array(lower, dtype=np.uint8)
          upper = np.array(upper, dtype=np.uint8)
  
          mask = cv.inRange(img, lower, upper)
  
          ratio_black = cv.countNonZero(mask)/(img.size/3)
          colorPercent = (ratio_black*100)/scale
  
          print(f&quot;black pixel percentage: {np.round(colorPercent, 2)}&quot;)
  
      for (lower, upper) in boundaries_pink:
          lower = np.array(lower, dtype=np.uint8)
          upper = np.array(upper, dtype=np.uint8)
  
          mask = cv.inRange(img, lower, upper)
  
          ratio_pink = cv.countNonZero(mask)/(img.size/3)
          colorPercent = (ratio_pink*100)/scale
  
          print(f&quot;pink pixel percentage: {np.round(colorPercent, 2)}&quot;)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/zeFHB.png" rel="nofollow noreferrer">The output when I print [255, 192, 203] RGB value</a></p>