From e04cc64a963f3031c0c15277f9b8aed501a8570f Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Wed, 24 Jun 2020 18:13:25 +0200 Subject: Move tests into the Colour fork. --- gsoc_common.py | 2 -- test_colorchecker.py | 25 ------------------------- test_diff.py | 51 --------------------------------------------------- test_interpolator.py | 28 ---------------------------- 4 files changed, 106 deletions(-) delete mode 100644 test_colorchecker.py delete mode 100644 test_diff.py delete mode 100644 test_interpolator.py diff --git a/gsoc_common.py b/gsoc_common.py index 695edc6..c235375 100644 --- a/gsoc_common.py +++ b/gsoc_common.py @@ -3,13 +3,11 @@ from colour import * from colour.difference import delta_E_CIE1976 from colour.colorimetry import * from colour.plotting import * -from colour.models import RGB_COLOURSPACES from matplotlib import pyplot as plt D65_xy = ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"] D65 = SpectralDistribution(ILLUMINANT_SDS["D65"]) -colourspace = RGB_COLOURSPACES["ProPhoto RGB"] # The same wavelength grid is used throughout wvl = SpectralShape(360, 830, 5) diff --git a/test_colorchecker.py b/test_colorchecker.py deleted file mode 100644 index 1503874..0000000 --- a/test_colorchecker.py +++ /dev/null @@ -1,25 +0,0 @@ -import numpy as np -from colour import * -from colour.recovery import RGB_to_sd_Jakob2019 -from gsoc_common import * - - -# This demo goes through SDs in a color checker -if __name__ == "__main__": - for name, sd in COLOURCHECKER_SDS['ColorChecker N Ohta'].items(): - XYZ = sd_to_XYZ(sd, illuminant=D65) / 100 - - RGB = XYZ_to_RGB( - XYZ, - D65_xy, - colourspace.whitepoint, - colourspace.XYZ_to_RGB_matrix, - ) - - recovered_sd, error = RGB_to_sd_Jakob2019( - RGB, - colourspace, - return_error=True - ) - - plot_comparison(sd, recovered_sd, name, error, D65) diff --git a/test_diff.py b/test_diff.py deleted file mode 100644 index 4429894..0000000 --- a/test_diff.py +++ /dev/null @@ -1,51 +0,0 @@ -import numpy as np -from scipy.optimize import minimize -from colour import * -from colour.recovery import error_function_Jakob2019 -from matplotlib import pyplot as plt -from gsoc_common import plot_comparison - - -# This test checks if derivatives are calculated correctly by comparing them -# to finite differences. -if __name__ == "__main__": - shape = SpectralShape(360, 830, 1) - cmfs = STANDARD_OBSERVER_CMFS["CIE 1931 2 Degree Standard Observer"].align(shape) - - illuminant = SpectralDistribution(ILLUMINANT_SDS["D65"]).align(shape) - illuminant_XYZ = sd_to_XYZ(illuminant) / 100 - - target = np.array([50, -20, 30]) # Some arbitrary Lab colour - xs = np.linspace(-10, 10, 500) - h = xs[1] - xs[0] - - # Vary one coefficient at a time - for c_index in range(3): - errors = np.empty(len(xs)) - derrors = np.empty(len(xs)) - - for i, x in enumerate(xs): - c = np.array([1.0, 1, 1]) - c[c_index] = x - - error, derror_dc = error_function_Jakob2019( - c, target, shape, cmfs, illuminant, illuminant_XYZ - ) - - errors[i] = error - derrors[i] = derror_dc[c_index] - - - plt.subplot(2, 3, 1 + c_index) - plt.xlabel("c%d" % c_index) - plt.ylabel("ΔE") - plt.plot(xs, errors) - - plt.subplot(2, 3, 4 + c_index) - plt.xlabel("c%d" % c_index) - plt.ylabel("dΔE/dc%d" % c_index) - - plt.plot(xs, derrors, "k-") - plt.plot(xs[:-1] + h / 2, np.diff(errors) / h, "r:") - - plt.show() diff --git a/test_interpolator.py b/test_interpolator.py deleted file mode 100644 index ba476da..0000000 --- a/test_interpolator.py +++ /dev/null @@ -1,28 +0,0 @@ -import numpy as np, struct -from colour import * -from colour.difference import delta_E_CIE1976 -from colour.models import eotf_inverse_sRGB -from colour.recovery import Jakob2019Interpolator -from gsoc_common import * - - -# This script tests if the interpolator correctly handles multi-dimensional -# inputs. -if __name__ == "__main__": - interp = Jakob2019Interpolator() - interp.from_file("data/srgb.coeff") - - RGBs = np.random.random((7, 6, 5, 4, 3)) - ccs = interp.coefficients(RGBs) - - RGB = eotf_inverse_sRGB(RGBs[0, 0, 0, 0, :]) - XYZ = sRGB_to_XYZ(RGB) - Lab = XYZ_to_Lab(XYZ, D65_xy) - cc = ccs[0, 0, 0, 0, :] - - matched_sd = model_sd(cc, primed=False) - matched_XYZ = sd_to_XYZ(matched_sd, illuminant=D65) / 100 - matched_Lab = XYZ_to_Lab(matched_XYZ, D65_xy) - error = delta_E_CIE1976(Lab, matched_Lab) - - plot_comparison(XYZ, matched_sd, "Model", error, D65) -- cgit