opencv打卡70: 色彩追踪(Color Tracking)
程序员文章站
2022-07-07 11:19:37
...
1、介绍
2、代码
import cv2
import numpy as np
import matplotlib.pyplot as plt
def get_mask(hsv):
mask = np.zeros_like(hsv[..., 0])
mask[np.logical_and((hsv[..., 0] > 180), (hsv[..., 0] < 260))] = 255
return mask
img = cv2.imread('imori.jpg').astype(np.float32)
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
mask=get_mask(hsv)
cv2.imshow('res',mask)
cv2.waitKey(0)
cv2.destroyAllWindows()
3、结果
4、知识点
np.logical_and()