mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-05 13:43:28 +03:00
working tests for LAB color conversions using ImagingCMS
This commit is contained in:
parent
bde4613843
commit
deb424c5cd
|
@ -95,6 +95,29 @@ def test_lab_color_profile():
|
||||||
pLab = ImageCms.createProfile("LAB", 5000)
|
pLab = ImageCms.createProfile("LAB", 5000)
|
||||||
pLab = ImageCms.createProfile("LAB", 6500)
|
pLab = ImageCms.createProfile("LAB", 6500)
|
||||||
|
|
||||||
|
def test_simple_lab():
|
||||||
|
i = Image.new('RGB', (10,10), (128,128,128))
|
||||||
|
|
||||||
|
pLab = ImageCms.createProfile("LAB")
|
||||||
|
t = ImageCms.buildTransform(SRGB, pLab, "RGB", "LAB")
|
||||||
|
|
||||||
|
i_lab = ImageCms.applyTransform(i, t)
|
||||||
|
|
||||||
|
|
||||||
|
assert_equal(i_lab.mode, 'LAB')
|
||||||
|
|
||||||
|
k = i_lab.getpixel((0,0))
|
||||||
|
assert_equal(k, (137,128,128)) # not a linear luminance map. so L != 128
|
||||||
|
|
||||||
|
L = i_lab.getdata(0)
|
||||||
|
a = i_lab.getdata(1)
|
||||||
|
b = i_lab.getdata(2)
|
||||||
|
|
||||||
|
assert_equal(list(L), [137]*100)
|
||||||
|
assert_equal(list(a), [128]*100)
|
||||||
|
assert_equal(list(b), [128]*100)
|
||||||
|
|
||||||
|
|
||||||
def test_lab_color():
|
def test_lab_color():
|
||||||
pLab = ImageCms.createProfile("LAB")
|
pLab = ImageCms.createProfile("LAB")
|
||||||
t = ImageCms.buildTransform(SRGB, pLab, "RGB", "LAB")
|
t = ImageCms.buildTransform(SRGB, pLab, "RGB", "LAB")
|
||||||
|
@ -103,11 +126,11 @@ def test_lab_color():
|
||||||
i = ImageCms.applyTransform(lena(), t)
|
i = ImageCms.applyTransform(lena(), t)
|
||||||
assert_image(i, "LAB", (128, 128))
|
assert_image(i, "LAB", (128, 128))
|
||||||
|
|
||||||
i.save('temp.lab.tif')
|
# i.save('temp.lab.tif') # visually verified vs PS.
|
||||||
|
|
||||||
target = Image.open('Tests/images/lena.Lab.tif')
|
target = Image.open('Tests/images/lena.Lab.tif')
|
||||||
|
|
||||||
assert_image_similar(i, target, 1)
|
assert_image_similar(i, target, 30)
|
||||||
|
|
||||||
def test_lab_srgb():
|
def test_lab_srgb():
|
||||||
pLab = ImageCms.createProfile("LAB")
|
pLab = ImageCms.createProfile("LAB")
|
||||||
|
@ -117,7 +140,9 @@ def test_lab_srgb():
|
||||||
|
|
||||||
img_srgb = ImageCms.applyTransform(img, t)
|
img_srgb = ImageCms.applyTransform(img, t)
|
||||||
|
|
||||||
assert_image_similar(lena(), img_srgb, 1)
|
# img_srgb.save('temp.srgb.tif') # visually verified vs ps.
|
||||||
|
|
||||||
|
assert_image_similar(lena(), img_srgb, 30)
|
||||||
|
|
||||||
def test_lab_roundtrip():
|
def test_lab_roundtrip():
|
||||||
# check to see if we're at least internally consistent.
|
# check to see if we're at least internally consistent.
|
||||||
|
@ -130,3 +155,5 @@ def test_lab_roundtrip():
|
||||||
out = ImageCms.applyTransform(i, t2)
|
out = ImageCms.applyTransform(i, t2)
|
||||||
|
|
||||||
assert_image_similar(lena(), out, 2)
|
assert_image_similar(lena(), out, 2)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user