I am getting the below error for the following code to detect a particular color

88 Views Asked by At
import cv2
import numpy as np 


# Load our input image
image = cv2.imread('./images/domino.png')
cv2.imshow('Original',image)

# We use cvtColor, to convert to grayscale
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

#Getting the original image dimension
height,width= gray.shape[:2]

#Creating a threshold image with same size as that of original image
threshold = np.zeros((height,width,3), np.uint8)

#BGR Threshold value 
Min=np.array([255,255,255],dtype = "uint8")
Max=np.array([255,255,255],dtype = "uint8")

#Creating the output image on the basis of RGB thresholds   
threshold = cv2.inRange(gray,Min,Max)

#Displaying the output image
cv2.imshow('Threshold', threshold)

#Saving the output image 
cv2.imwrite('output.jpg', threshold)

cv2.waitKey(0)
cv2.destroyAllWindows()

Hi I am trying to mask out a particular value of BGR in an image but i am getting the below error for the code above .

error Traceback (most recent call last) in () 25 #Creating the output image on the basis of RGB thresholds 26 ---> 27 threshold = cv2.inRange(gray,Min,Max) 28 29

error: ........\opencv\modules\core\src\arithm.cpp:2703: error: (-209) The lower bounary is neither an array of the same size and same type as src, nor a scalar in function cv::inRange

0

There are 0 best solutions below