100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > python中颜色空间lab直方图_python – 从RGB转换为LAB色彩空间 – 对L * A *

python中颜色空间lab直方图_python – 从RGB转换为LAB色彩空间 – 对L * A *

时间:2020-07-18 20:50:32

相关推荐

python中颜色空间lab直方图_python – 从RGB转换为LAB色彩空间 – 对L * A *

在OpenCV(

Python)中将图像从RGB转换为LAB时,我无法找到有关L * A * B *值范围的文档.寻找一些确认我的洞察力是正确的,因为数字是相当奇特的.我的亮度结果是0-255,但对于a和b我分别得到42-226和20-223.我知道这些值不需要有预定的范围,但任何人都可以了解为什么选择这些范围?

我试图在LAB空间中创建颜色直方图,并且需要知道以空间有效的方式存储bin值的值范围.

import cv2

import numpy as np

import sys

import urllib

print cv2.__version__ # 2.4.7

print sys.version # 2.7.5+ (default, Sep 19 , 13:48:49) \n[GCC 4.8.1]

# Load an image that contains all possible colors.

request = urllib.urlopen('/downloads/RGB16Million.png')

image_array = np.asarray(bytearray(request.read()), dtype=np.uint8)

image = cv2.imdecode(image_array, cv2.CV_LOAD_IMAGE_COLOR)

# I was uncertain if it was BGR or RGB but in this case it doesn't matter because

# of my input image.

lab_image = cv2.cvtColor(image, cv2.COLOR_BGR2LAB)

l_channel,a_channel,b_channel = cv2.split(lab_image)

# Print the minimum and maximum of lightness.

print np.min(l_channel) # 0

print np.max(l_channel) # 255

# Print the minimum and maximum of a.

print np.min(a_channel) # 42

print np.max(a_channel) # 226

# Print the minimum and maximum of b.

print np.min(b_channel) # 20

print np.max(b_channel) # 223

谢谢!

python中颜色空间lab直方图_python – 从RGB转换为LAB色彩空间 – 对L * A * B *值范围的任何了解?...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。