Python 在openCV中屏蔽和按位_和
所以我刚开始学习openCV,我正在学习加入和屏蔽图像。因此,在实际操作时,我遇到了以下代码的两个问题Python 在openCV中屏蔽和按位_和,python,python-3.x,opencv,computer-vision,mask,Python,Python 3.x,Opencv,Computer Vision,Mask,所以我刚开始学习openCV,我正在学习加入和屏蔽图像。因此,在实际操作时,我遇到了以下代码的两个问题 ... # HSV values lower_bounds = numpy.array([h_min, s_min, v_min]) upper_bounds = numpy.array([h_max, s_max, v_max]) # Generating a mask mask = cv2.inRange(img_hsv, lower_bo
...
# HSV values
lower_bounds = numpy.array([h_min, s_min, v_min])
upper_bounds = numpy.array([h_max, s_max, v_max])
# Generating a mask
mask = cv2.inRange(img_hsv, lower_bounds, upper_bounds)
# Using this to convert the image into a 3 channel image so as to
# join it with other images below using the hstack and stack
# **Line 1**
th_mask = cv2.cvtColor(mask, cv2.COLOR_GRAY2BGR)
# Using bitwise_and with img as src1 and three channel mask as src2
# **Line 2**
result = cv2.bitwise_and(img, th_mask)
horizontal_stack_1 = numpy.hstack((img, img_hsv))
horizontal_stack_2 = numpy.hstack((th_mask, result))
vertical_stack = numpy.vstack((horizontal_stack_1, horizontal_stack_2))
...
所以我的问题是:
result=cv2.bitwise_和(img,img,mask=mask)
之间有什么区别,如果我只需要提取特定的颜色,哪种方法看起来更好