Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 views
in Technique[技术] by (71.8m points)

python 3.x - HSV colorspace conversion between opencv vs skimage

I was comparing the difference between skImage HSV color space and OpenCV hsv colourspace conversion methods, I found the below difference which I didn't understand:

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

I used PIL to make sure I am feeding RGB array. Here, when I printed the images I got the following outputs.

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]],

   ...,
  1. why are my y1 and y2 arrays different? do skimage and opencv follow different conversion formulas for the same colorspace?

  2. Which is the standard and the most followed way to convert an RGB image to HSV image: "cvtColor(....RGB2HSV) -cv2" or "rgbtohsv() -skimage"?

Thank you in advance :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...