我在比较skImage HSV颜色空间和OpenCV HSV颜色颜色空间转换方法之间的差异时,发现了以下我不理解的差异:
from PIL import Image
from skimage import io
import numpy as np
import cv2
image = PIL.Image.open("112.jpg")
data = np.asarray(image) #Feeding the same RGB array
y1=cv2.cvtColor(np.float32(data),cv2.COLOR_RGB2HSV)
y1 = y1.astype(np.uint8)
y2= color.rgb2hsv(data) #skimage conversion
我使用PIL来确保我正在馈送RGB阵列。在这里,当我打印图像时,我得到了以下输出。
y1
>>> array([[[ 52, 0, 252],
[ 52, 0, 252],
[ 52, 0, 252],
...,
[ 59, 0, 186],
[ 59, 0, 186],
[ 59, 0, 186]],
[[ 52, 0, 252],
[ 52, 0, 252],
[ 52, 0, 252],
...,
[ 59, 0, 186],
[ 59, 0, 186],
[ 59, 0, 186]],
[[ 52, 0, 252],
[ 52, 0, 252],
[ 52, 0, 252],
...,
[ 59, 0, 187],
[ 59, 0, 187],
[ 59, 0, 187]],
...,
y2
>>> array([[[0.14465409, 0.21031746, 0.98823529],
[0.14465409, 0.21031746, 0.98823529],
[0.14465409, 0.21031746, 0.98823529],
...,
[0.16515152, 0.59139785, 0.72941176],
[0.16515152, 0.59139785, 0.72941176],
[0.16515152, 0.59139785, 0.72941176]],
[[0.14465409, 0.21031746, 0.98823529],
[0.14465409, 0.21031746, 0.98823529],
[0.14465409, 0.21031746, 0.98823529],
...,
[0.16515152, 0.59139785, 0.72941176],
[0.16515152, 0.59139785, 0.72941176],
[0.16515152, 0.59139785, 0.72941176]],
[[0.14465409, 0.21031746, 0.98823529],
[0.14465409, 0.21031746, 0.98823529],
[0.14465409, 0.21031746, 0.98823529],
...,
[0.16515152, 0.58823529, 0.73333333],
[0.16515152, 0.58823529, 0.73333333],
[0.16515152, 0.58823529, 0.73333333]],
...,
为什么我的y1和y2数组不同?skimage和opencv对于同一个颜色空间遵循不同的转换公式吗?
这是将RGB图像转换为HSV图像的标准和最遵循的方式:;cvtColor(…RGB2HSV(-cv2〃;或";rgbtohsv((-skimage"?
提前感谢:(
转换为HSV时,CV2和Skimage使用不同的比例。对于CV2,HSV值在0和255的范围内,而对于撇渣,HSV数值在0和1的范围内。只需将skimage中的HSV值相乘并将其转换为整数,即可获得CV2和skimage的相同值。