for i in range(0, len(temp)):
temp[i] = cv2.cvtColor(temp[i], cv2.COLOR_BGR2HSV)
for k in range(0, len(temp)):
for i in range(0, len(temp[k])):
for j in range(0, len(temp[k][i])):
if(temp[k][i][j][0] > 50 and temp[k][i][j][0] < 65 and temp[k][i][j][2] > 150):
temp1[k][i][j][0] = 0
temp1[k][i][j][1] = 0
temp1[k][i][j][2] = 0
else:
temp1[k][i][j][0] = 255
temp1[k][i][j][1] = 255
temp1[k][i][j][2] = 255
temp是我的HSV数组,而temp1是我正在创建的蒙版
答案 0 :(得分:0)
不是cv2
专家,但是如果它像numpy
数组那样工作,则。 。 。
for i in range(0, len(temp)):
temp[i] = cv2.cvtColor(temp[i], cv2.COLOR_BGR2HSV)
temp1[i] = (1 - cv2.inRange(temp[i], (50, 0, 150), (65, 255, 255)).astype(int)) * 255