From 1f85ef7fbb3c03f1ec1b0658c9cd90655433ab78 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 16 Dec 2014 14:58:21 +0000 Subject: [PATCH] more convsep tests --- TODO | 12 ++++++++++-- test/test_convolution.py | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index eda52a4b..797bfee0 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,14 @@ -- something screwy in compass def? +- try: - $ python2 ./test_convolution.py TestConvolution.test_x + vips gaussmat m2.v 2 0.1 --separable + vips convsep k2.jpg x2.jpg m2.v + eog x2.jpg + + it's too bright ... because gaussmat makes a float mask by default, but + conv does an int convolution by default + + rather than an --integer switch on gaussmat, should it take --precision + instead, and default to INT, like conv? - configure should check for pygobject too diff --git a/test/test_convolution.py b/test/test_convolution.py index 9d2b031b..242aa636 100755 --- a/test/test_convolution.py +++ b/test/test_convolution.py @@ -142,5 +142,27 @@ class TestConvolution(unittest.TestCase): true = compass(im, msk, 24, 49, times, operator.add) self.assertAlmostEqualObjects(result, true) + def test_convsep(self): + for im in self.all_images: + for prec in [Vips.Precision.INTEGER, Vips.Precision.FLOAT]: + integer = prec == Vips.Precision.INTEGER + gmask = Vips.Image.gaussmat(2, 0.1, + integer = integer) + gmask_sep = Vips.Image.gaussmat(2, 0.1, + separable = True, + integer = integer) + + self.assertEqual(gmask.width, gmask.height) + self.assertEqual(gmask_sep.width, gmask.width) + self.assertEqual(gmask_sep.height, 1) + + a = im.conv(gmask, precision = prec) + b = im.convsep(gmask_sep, precision = prec) + + a_point = a.getpoint(25, 50) + b_point = b.getpoint(25, 50) + + self.assertAlmostEqualObjects(a_point, b_point, places = 1) + if __name__ == '__main__': unittest.main()