test extra band handling in dE
This commit is contained in:
parent
0a327af138
commit
fd9300750d
@ -11,6 +11,7 @@
|
||||
for consistency
|
||||
- python vips8 binding
|
||||
- python vips8 test suite: test_arithmetic.py
|
||||
- better extra band handling by colour, again
|
||||
|
||||
8/9/14 started 7.40.9
|
||||
- support jfif resunit "none"
|
||||
|
@ -80,7 +80,7 @@ vips_process_n( const char *domain, VipsImage *in, VipsImage **out,
|
||||
if( in->Bands > n ) {
|
||||
VipsImage *scope = vips_image_new();
|
||||
VipsImage **t = (VipsImage **)
|
||||
vips_object_local_array( VIPS_OBJECT( scope ), 3 );
|
||||
vips_object_local_array( VIPS_OBJECT( scope ), 4 );
|
||||
|
||||
if( vips_extract_band( in, &t[0], 0,
|
||||
"n", n,
|
||||
@ -89,7 +89,8 @@ vips_process_n( const char *domain, VipsImage *in, VipsImage **out,
|
||||
"n", in->Bands - n,
|
||||
NULL ) ||
|
||||
fn( t[0], &t[2], NULL ) ||
|
||||
vips_bandjoin2( t[2], t[1], out, NULL ) ) {
|
||||
vips_cast( t[1], &t[3], t[2]->BandFmt, NULL ) ||
|
||||
vips_bandjoin2( t[2], t[3], out, NULL ) ) {
|
||||
g_object_unref( scope );
|
||||
return( -1 );
|
||||
}
|
||||
|
@ -152,37 +152,42 @@ class TestColour(unittest.TestCase):
|
||||
# http://www.brucelindbloom.com
|
||||
|
||||
def test_dE00(self):
|
||||
reference = Vips.Image.black(100, 100) + [50, 10, 20]
|
||||
# put 42 in the extra band, it should be copied unmodified
|
||||
reference = Vips.Image.black(100, 100) + [50, 10, 20, 42]
|
||||
reference = reference.copy(interpretation = Vips.Interpretation.LAB)
|
||||
sample = Vips.Image.black(100, 100) + [40, -20, 10]
|
||||
sample = sample.copy(interpretation = Vips.Interpretation.LAB)
|
||||
|
||||
difference = reference.dE00(sample)
|
||||
result = difference.getpoint(10, 10)
|
||||
self.assertAlmostEqualObjects(result, [30.238], places = 3)
|
||||
result, alpha = difference.getpoint(10, 10)
|
||||
self.assertAlmostEqual(result, 30.238, places = 3)
|
||||
self.assertAlmostEqual(alpha, 42.0, places = 3)
|
||||
|
||||
def test_dE76(self):
|
||||
reference = Vips.Image.black(100, 100) + [50, 10, 20]
|
||||
# put 42 in the extra band, it should be copied unmodified
|
||||
reference = Vips.Image.black(100, 100) + [50, 10, 20, 42]
|
||||
reference = reference.copy(interpretation = Vips.Interpretation.LAB)
|
||||
sample = Vips.Image.black(100, 100) + [40, -20, 10]
|
||||
sample = sample.copy(interpretation = Vips.Interpretation.LAB)
|
||||
|
||||
difference = reference.dE76(sample)
|
||||
result = difference.getpoint(10, 10)
|
||||
self.assertAlmostEqualObjects(result, [33.166], places = 3)
|
||||
result, alpha = difference.getpoint(10, 10)
|
||||
self.assertAlmostEqual(result, 33.166, places = 3)
|
||||
self.assertAlmostEqual(alpha, 42.0, places = 3)
|
||||
|
||||
# the vips CMC calculation is based on distance in a colorspace derived from
|
||||
# the CMC formula, so it won't match exactly ... see vips_LCh2CMC() for
|
||||
# details
|
||||
def test_dECMC(self):
|
||||
reference = Vips.Image.black(100, 100) + [50, 10, 20]
|
||||
reference = Vips.Image.black(100, 100) + [50, 10, 20, 42]
|
||||
reference = reference.copy(interpretation = Vips.Interpretation.LAB)
|
||||
sample = Vips.Image.black(100, 100) + [55, 11, 23]
|
||||
sample = sample.copy(interpretation = Vips.Interpretation.LAB)
|
||||
|
||||
difference = reference.dECMC(sample)
|
||||
[result] = difference.getpoint(10, 10)
|
||||
result, alpha = difference.getpoint(10, 10)
|
||||
self.assertLess(abs(result - 4.97), 0.5)
|
||||
self.assertAlmostEqual(alpha, 42.0, places = 3)
|
||||
|
||||
# hard to test ICC stuff without including test images
|
||||
# rely on the nip2 test suite for this
|
||||
|
Loading…
x
Reference in New Issue
Block a user