最近研究提取图片中指定颜色的物体,用到OpenCV
在网上找到的代码
hue_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV) low_range = np.array([139, 150, 160], np.uint8) high_range = np.array([153, 200, 200], np.uint8) #low_range = np.array([140, 0, 0]) #high_range = np.array([150, 255, 255]) th = cv2.inRange(hue_image, low_range, high_range)
# R:160 G:139 B:150
hue_image是图片实体,通过inRange函数可以通过RGB筛选区域
inRange Function:
Parameters
src first input array.
lowerb inclusive lower boundary array or a scalar.
upperb inclusive upper boundary array or a scalar.
lowerb和upperb参数,顺序是GBR
标签:150,函数,image,OpenCV,range,np,array,inRange From: https://www.cnblogs.com/z45281625/p/16873010.html