我无法在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 2013, 13:48:49) \n[GCC 4.8.1]
# Load an image that contains all possible colors.
request = urllib.urlopen('http://www.brucelindbloom.com/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
谢谢!