我在任何Python库(最好是PIL)中都找不到一个易于使用的函数来将RGB转换为YUV。因为我必须转换许多图像,所以我不想自己实现它(如果没有LUT等等,代价会很高)。
当我做直觉的时候:
from PIL import Image
img = Image.open('test.jpeg')
img_yuv = img.convert('YUV')
我得到一个错误:
ValueError: conversion from RGB to YUV not supported
你知道为什么会这样吗?在python甚至是PIL中有没有什么高效的实现呢?
我不是计算机视觉专家,但我认为这个ocnversion在大多数库中都是标准的……
谢谢
罗马
发布于 2017-03-16 04:33:55
你可以试试'YCbCr‘而不是'YUV’。
from PIL import Image
img = Image.open('test.jpeg')
img_yuv = img.convert('YCbCr')
发布于 2017-02-22 15:42:21
你可以试试这个:
import cv2
img_yuv = cv2.cvtColor(img, cv2.COLOR_BGR2YUV)
发布于 2017-04-18 00:37:27
我知道现在可能很晚了,但是scikit-image
有rgb2yuv
函数
from PIL import Image
from skimage.color import rgb2yuv
img = Image.open('test.jpeg')
img_yuv = rgb2yuv(img)
https://stackoverflow.com/questions/37588047
复制相似问题