title: I keep getting the following error with cv2 when I use a specific upper and lower limit
body: <p>So I have uploaded the code below. For example, if I set the <code>lower_limit = [0, 0, 0]</code> and <code>upper_limit = [50,255,255]</code>, I get no error whereas if I set the <code>lower_limit = [25, 0, 0]</code> and <code>upper_limit = [27.5,255,255]</code> (which is what I want), I keep getting the error—</p>
  <pre><code>Traceback (most recent call last):
    File &quot;c:\Users\Keerthan S\OneDrive\Desktop\blood51\code.py&quot;, line 27, in 
      masking = cv2.inRange(hsv_img, lower_pink, upper_pink)
  cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\core\src\arithm.cpp:1782: error: (-215:Assertion failed) lb.type() == ub.type() in function 'cv::inRange'
  </code></pre>
  <p>Code is below :</p>
  <pre><code>import cv2
  import numpy as np
  from PIL import Image
  
  saturation_pink = 0
  saturation_blue = 0
  
  brightness_pink = 0
  brightness_blue = 0
  
  img = cv2.imread(&quot;creat_tubes3.jpg&quot;)
  
  height = img.shape[0]
  width = img.shape[1]
  
  #img = img_cropless[200:900,200:900]
  
  
  result = cv2.fastNlMeansDenoisingColored(img,None,20,10,7,21)
  
  hsv_img = cv2.cvtColor(result, cv2.COLOR_BGR2HSV)
  #cv2.imshow(&quot;HSV Image&quot;, hsv_img)
  
  lower_pink = np.array([25, 0, 0])
  upper_pink = np.array([27.5, 255, 255])
  
  masking = cv2.inRange(hsv_img, lower_pink, upper_pink)
  #cv2.imshow(&quot;pink Color detection&quot;, masking)
  result_pink = cv2.bitwise_and(img, img, mask=masking)
  half_pink = cv2.resize(result_pink, (0, 0), fx = 0.1, fy = 0.1) #resizing the image
  cv2.imshow(&quot;Reacted area - pink&quot;, half_pink)
  
  for y in range(width):
     for x in range(height):
        saturation_pink = saturation_pink + result_pink[x][y][1] #*(100 - result1[y][x][0])
        brightness_pink = brightness_pink + result_pink[x][y][2]
  
  print(&quot;pink saturation : &quot;,saturation_pink)
  #print(&quot;pink brightness : &quot;,brightness_pink)
  
  
  cv2.waitKey(0)
  </code></pre>