Ich konnte keine Dokumentation zum Bereich der L * A * B * -Werte finden, wenn ich ein Bild von RGB nach LAB in OpenCV (Python) konvertiere. Auf der Suche nach etwas Bestätigung, dass meine Einsicht richtig ist, da die Zahlen ziemlich eigenartig sind. Meine Ergebnisse für Leichtigkeit waren von 0-255, aber für a und b habe ich 42-226 bzw. 20-223 bekommen. Ich verstehe, dass diese Werte keinen vorgegebenen Bereich haben müssen, aber könnte irgendjemand einen Einblick in die Gründe geben, warum diese Bereiche ausgewählt wurden?Konvertieren von RGB nach LAB Colorspace - Einblick in den Bereich der L * A * B * -Werte?
Für was es wert ist, versuche ich, Farbhistogramme im LAB-Raum zu erstellen und musste den Bereich der Werte kennen, um bin-Werte auf eine raumeffiziente Weise zu speichern.
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
Vielen Dank!
Schnelle Google-Suche gab einen Online-Konverter mit Quellcode geliefert: http://colormine.org/convert/rgb-to-lab – M4rtini
Danke für den Link M4rtini. Ich hatte es vorher angeschaut, aber es ist nicht relevant für meine Frage. Ich suche nach dem Einblick, warum der Bereich in OpenCV so seltsam nummeriert ist. Der von Colormine berechnete Bereich erlaubt sowohl positive als auch negative Werte von a und b, was in OpenCV (Python) nicht der Fall ist. Trotzdem danke! –