Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我似乎无法在新的 OpenCV python API (cv2) 中将 RGB 转换为 YCrCb。当我运行此代码时:
img = cv2.imread('img1.jpg') imgYCC = cv2.cvtColor(img, cv2.COLOR_RGB2YCrCb)
,我得到这个错误:
AttributeError: 'module' object has no attribute 'COLOR_RGB2YCrCb'
我究竟做错了什么?
属性名称COLOR_RGB2YCR_CB用于 RGB 排序。
COLOR_RGB2YCR_CB
请记住,OpenCV 本身使用 BGR 颜色排序,而不是 RGB,在这种情况下属性是COLOR_BGR2YCR_CB. 因此,您可能需要修改您的代码:
COLOR_BGR2YCR_CB
img = cv2.imread('img1.jpg') imgYCC = cv2.cvtColor(img, cv2.COLOR_BGR2YCR_CB)