Compare the images in LAB space

This commit is contained in:
Steven Silvester
2015-02-01 10:05:52 -06:00
parent d8f6a6697b
commit d9f5aa9104
+9 -5
View File
@@ -18,6 +18,7 @@ from PIL import Image
from .._plugins.pil_plugin import (
pil_to_ndarray, ndarray_to_pil, _palette_is_grayscale)
from ...measure import structural_similarity as ssim
from ...color import rgb2lab
def setup():
@@ -196,13 +197,16 @@ def test_cmyk():
img.save(fname)
img.close()
new = imread(fname)[:, :, :3]
new = imread(fname)
ref_lab = rgb2lab(ref)
new_lab = rgb2lab(new)
for i in range(3):
newi = np.ascontiguousarray(new[:, :, i])
refi = np.ascontiguousarray(ref[:, :, i])
newi = np.ascontiguousarray(new_lab[:, :, i])
refi = np.ascontiguousarray(ref_lab[:, :, i])
sim = ssim(refi, newi, dynamic_range=refi.max() - refi.min())
assert sim > 0.85
assert sim > 0.99
class TestSaveTIF:
@@ -227,4 +231,4 @@ class TestSaveTIF:
yield self.roundtrip, dtype, x
if __name__ == "__main__":
run_module_suite()
run_module_suite()