def figures_gamma_245 (): '''Adjust the gamma correction to a power law gamma = 2.45 and create samples.''' colormodels.init() colormodels.init_gamma_correction ( display_from_linear_function = colormodels.simple_gamma_invert, linear_from_display_function = colormodels.simple_gamma_correct, gamma = 2.45) figures()
def test_gamma_srgb(self, verbose=False): ''' Test default sRGB component (cannot supply exponent). ''' msg = 'Testing sRGB gamma:' if verbose: print (msg) colormodels.init_gamma_correction ( display_from_linear_function = colormodels.srgb_gamma_invert, linear_from_display_function = colormodels.srgb_gamma_correct) self.check_gamma_correction(verbose)
def test_gamma_srgb(self, verbose=False): ''' Test default sRGB component (cannot supply exponent). ''' msg = 'Testing sRGB gamma:' if verbose: print(msg) colormodels.init_gamma_correction( display_from_linear_function=colormodels.srgb_gamma_invert, linear_from_display_function=colormodels.srgb_gamma_correct) self.check_gamma_correction(verbose)
def test_gamma_power(self, verbose=False): ''' Test simple power law gamma (can supply exponent). ''' gamma_set = [0.1, 0.5, 1.0, 1.1, 1.5, 2.0, 2.2, 2.5, 10.0] for gamma in gamma_set: msg = 'Testing power-law gamma: %g' % (gamma) if verbose: print (msg) colormodels.init_gamma_correction ( display_from_linear_function = colormodels.simple_gamma_invert, linear_from_display_function = colormodels.simple_gamma_correct, gamma = gamma) self.check_gamma_correction(verbose)
def test_gamma_power(self, verbose=False): ''' Test simple power law gamma (can supply exponent). ''' gamma_set = [0.1, 0.5, 1.0, 1.1, 1.5, 2.0, 2.2, 2.5, 10.0] for gamma in gamma_set: msg = 'Testing power-law gamma: %g' % (gamma) if verbose: print(msg) colormodels.init_gamma_correction( display_from_linear_function=colormodels.simple_gamma_invert, linear_from_display_function=colormodels.simple_gamma_correct, gamma=gamma) self.check_gamma_correction(verbose)
def test_gamma(verbose=1): if verbose >= 1: print('Testing gamma corrections...') def test_gamma_corrections(): # test individual component gamma for i in xrange(0, 100): x = 10.0 * (2.0 * random.random() - 1.0) a = colormodels.linear_from_display_component(x) b = colormodels.display_from_linear_component(a) c = colormodels.linear_from_display_component(b) # check err1 = math.fabs(b - x) rel1 = math.fabs(err1 / (b + x)) err2 = math.fabs(c - a) rel2 = math.fabs(err2 / (c + a)) #print 'x = %g, b = %g, err = %g, rel = %g' % (x, b, err1, rel1) #print 'a = %g, c = %g, err = %g, rel = %g' % (a, c, err2, rel2) tolerance = 1.0e-14 if rel1 > tolerance: raise ValueError if rel2 > tolerance: raise ValueError # test default sRGB component (cannot supply exponent) if verbose >= 1: print('testing sRGB gamma') colormodels.init_gamma_correction( display_from_linear_function=colormodels.srgb_gamma_invert, linear_from_display_function=colormodels.srgb_gamma_correct) test_gamma_corrections() # test simple power law gamma (can supply exponent) gamma_set = [0.1, 0.5, 1.0, 1.1, 1.5, 2.0, 2.2, 2.5, 10.0] for gamma in gamma_set: if verbose >= 1: print('testing gamma', gamma) colormodels.init_gamma_correction( display_from_linear_function=colormodels.simple_gamma_invert, linear_from_display_function=colormodels.simple_gamma_correct, gamma=gamma) test_gamma_corrections() print('Passed test_gamma()')
def test_gamma (verbose=1): if verbose >= 1: print 'Testing gamma corrections...' def test_gamma_corrections (): # test individual component gamma for i in xrange (0, 100): x = 10.0 * (2.0 * random.random() - 1.0) a = colormodels.linear_from_display_component (x) b = colormodels.display_from_linear_component (a) c = colormodels.linear_from_display_component (b) # check err1 = math.fabs (b - x) rel1 = math.fabs (err1 / (b + x)) err2 = math.fabs (c - a) rel2 = math.fabs (err2 / (c + a)) #print 'x = %g, b = %g, err = %g, rel = %g' % (x, b, err1, rel1) #print 'a = %g, c = %g, err = %g, rel = %g' % (a, c, err2, rel2) tolerance = 1.0e-14 if rel1 > tolerance: raise ValueError if rel2 > tolerance: raise ValueError # test default sRGB component (cannot supply exponent) if verbose >= 1: print 'testing sRGB gamma' colormodels.init_gamma_correction ( display_from_linear_function = colormodels.srgb_gamma_invert, linear_from_display_function = colormodels.srgb_gamma_correct) test_gamma_corrections() # test simple power law gamma (can supply exponent) gamma_set = [0.1, 0.5, 1.0, 1.1, 1.5, 2.0, 2.2, 2.5, 10.0] for gamma in gamma_set: if verbose >= 1: print 'testing gamma', gamma colormodels.init_gamma_correction ( display_from_linear_function = colormodels.simple_gamma_invert, linear_from_display_function = colormodels.simple_gamma_correct, gamma = gamma) test_gamma_corrections() print 'Passed test_gamma()'