No conversion from RGB to YUV
I fail to find an easy-to-use function in any Python library (preferrably PIL) for conversion from RGB to YUV. Since I have to convert many images, I don't want to implement it myself (would be expensive without LUTs and so on).
When I do the intuitive:
from PIL import Image
img = Image.open('test.jpeg')
img_yuv = img.convert('YUV')
I get an error:
ValueError: conversion from RGB to YUV not supported
Do you know why this is the case? Is there any efficieint implementation of that in python and maybe even PIL?
I am no computer vision expert but I thought this ocnversion is standard in most of the libraries...
Thanks,
Roman
你可以尝试'YCbCr'而不是'YUV',即
from PIL import Image
img = Image.open('test.jpeg')
img_yuv = img.convert('YCbCr')
你可以试试这个:
import cv2
img_yuv = cv2.cvtColor(img, cv2.COLOR_BGR2YUV)
我知道它可能会迟到,但scikit-image
具有函数rgb2yuv
from PIL import Image
from skimage.color import rgb2yuv
img = Image.open('test.jpeg')
img_yuv = rgb2yuv(img)
链接地址: http://www.djcxy.com/p/65910.html
上一篇: JavaFX如何与WPF进行比较?
下一篇: 从RGB到YUV没有转换