more convsep tests

This commit is contained in:
John Cupitt 2014-12-16 14:58:21 +00:00
parent d62bec6ecc
commit 1f85ef7fbb
2 changed files with 32 additions and 2 deletions

12
TODO
View File

@ -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

View File

@ -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()