hit a snag
This commit is contained in:
parent
0dde4f5e53
commit
e6bf970911
18
TODO
18
TODO
@ -1,6 +1,20 @@
|
||||
- tests for convasep ... just check it matches convsep +/- some small amount
|
||||
- try edge.mat:
|
||||
|
||||
- tests for conva
|
||||
3 3 1 0
|
||||
1 1 1
|
||||
-2 -2 -2
|
||||
1 1 1
|
||||
|
||||
then
|
||||
|
||||
$ vips conva k2.jpg x.v edge.mat
|
||||
Floating point exception (core dumped)
|
||||
|
||||
because area == 0, so we get /0
|
||||
|
||||
probably a problem for convasep too
|
||||
|
||||
- tests for convasep ... just check it matches convsep +/- some small amount
|
||||
|
||||
- try this blur.mat
|
||||
|
||||
|
@ -79,9 +79,9 @@ $ vips im_max abs.v
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
#define DEBUG
|
||||
#define VIPS_DEBUG
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
@ -909,17 +909,17 @@ vips_conva_hgenerate( VipsRegion *or, void *vseq,
|
||||
for( y = 0; y < r->height; y++ ) {
|
||||
switch( in->BandFmt ) {
|
||||
case VIPS_FORMAT_UCHAR:
|
||||
if( conva->max_line > 256 )
|
||||
HCONV( unsigned char, unsigned int );
|
||||
else
|
||||
if( conva->max_line < 256 )
|
||||
HCONV( unsigned char, unsigned short );
|
||||
else
|
||||
HCONV( unsigned char, unsigned int );
|
||||
break;
|
||||
|
||||
case VIPS_FORMAT_CHAR:
|
||||
if( conva->max_line > 256 )
|
||||
HCONV( signed char, signed int );
|
||||
else
|
||||
if( conva->max_line < 256 )
|
||||
HCONV( signed char, signed short );
|
||||
else
|
||||
HCONV( signed char, signed int );
|
||||
break;
|
||||
|
||||
case VIPS_FORMAT_USHORT:
|
||||
@ -1132,21 +1132,21 @@ vips_conva_vgenerate( VipsRegion *or, void *vseq,
|
||||
|
||||
switch( convolution->in->BandFmt ) {
|
||||
case VIPS_FORMAT_UCHAR:
|
||||
if( conva->max_line > 256 )
|
||||
VCONV( unsigned int, \
|
||||
unsigned int, unsigned char, CLIP_UCHAR );
|
||||
else
|
||||
if( conva->max_line < 256 )
|
||||
VCONV( unsigned int, \
|
||||
unsigned short, unsigned char, CLIP_UCHAR );
|
||||
else
|
||||
VCONV( unsigned int, \
|
||||
unsigned int, unsigned char, CLIP_UCHAR );
|
||||
break;
|
||||
|
||||
case VIPS_FORMAT_CHAR:
|
||||
if( conva->max_line > 256 )
|
||||
VCONV( signed int, \
|
||||
signed int, signed char, CLIP_CHAR );
|
||||
else
|
||||
if( conva->max_line < 256 )
|
||||
VCONV( signed int, \
|
||||
signed short, signed char, CLIP_CHAR );
|
||||
else
|
||||
VCONV( signed int, \
|
||||
signed int, signed char, CLIP_CHAR );
|
||||
break;
|
||||
|
||||
case VIPS_FORMAT_USHORT:
|
||||
|
@ -96,6 +96,12 @@ class TestConvolution(unittest.TestCase):
|
||||
for x, y in zip_expand(a, b):
|
||||
self.assertAlmostEqual(x, y, places = places, msg = msg)
|
||||
|
||||
# test a pair of things which can be lists for difference less than a
|
||||
# threshold
|
||||
def assertLessThreshold(self, a, b, diff):
|
||||
for x, y in zip_expand(a, b):
|
||||
self.assertLess(abs(x - y), diff)
|
||||
|
||||
def setUp(self):
|
||||
im = Vips.Image.mask_ideal(100, 100, 0.5, reject = True, optical = True)
|
||||
self.colour = im * [1, 2, 3] + [2, 3, 4]
|
||||
@ -125,12 +131,32 @@ class TestConvolution(unittest.TestCase):
|
||||
|
||||
result = convolved(25, 50)
|
||||
true = conv(im, msk, 24, 49)
|
||||
print('result = %g, true = %g\n' % (result, true))
|
||||
self.assertAlmostEqualObjects(result, true)
|
||||
|
||||
result = convolved(50, 50)
|
||||
true = conv(im, msk, 49, 49)
|
||||
self.assertAlmostEqualObjects(result, true)
|
||||
|
||||
def test_conva(self):
|
||||
for im in self.all_images:
|
||||
for msk in self.all_masks:
|
||||
print("msk:")
|
||||
msk.matrixprint()
|
||||
print("im.bands = %s" % im.bands)
|
||||
|
||||
convolved = im.conv(msk, precision = Vips.Precision.APPROXIMATE)
|
||||
|
||||
result = convolved(25, 50)
|
||||
true = conv(im, msk, 24, 49)
|
||||
print("result = %s, true = %s" % (result, true))
|
||||
self.assertLessThreshold(result, true, 5)
|
||||
|
||||
result = convolved(50, 50)
|
||||
true = conv(im, msk, 49, 49)
|
||||
print("result = %s, true = %s" % (result, true))
|
||||
self.assertLessThreshold(result, true, 5)
|
||||
|
||||
def test_compass(self):
|
||||
for im in self.all_images:
|
||||
for msk in self.all_masks:
|
||||
|
Loading…
Reference in New Issue
Block a user