find_indexed wasn't banning complex images
This commit is contained in:
parent
133e2f94e9
commit
24ff40e9be
@ -157,6 +157,10 @@ vips_hist_find_indexed_build( VipsObject *object )
|
||||
indexed->index_ready = t[0];
|
||||
}
|
||||
|
||||
if( statistic->in )
|
||||
if( vips_check_noncomplex( class->nickname, statistic->in ) )
|
||||
return( -1 );
|
||||
|
||||
if( VIPS_OBJECT_CLASS( vips_hist_find_indexed_parent_class )->
|
||||
build( object ) )
|
||||
return( -1 );
|
||||
@ -407,13 +411,13 @@ vips_hist_find_indexed_init( VipsHistFindIndexed *hist_find )
|
||||
* words, element zero in @out contains the sum of all the pixels in @in
|
||||
* whose corresponding pixel in @index is zero.
|
||||
*
|
||||
* @index must have just one band and be u8 or u16. @value must be
|
||||
* non-complex. @out always has the same size and format as @value.
|
||||
* @index must have just one band and be u8 or u16. @in must be
|
||||
* non-complex. @out always has the same size and format as @in.
|
||||
*
|
||||
* This operation is useful in conjunction with im_label_regions(). You can
|
||||
* This operation is useful in conjunction with vips_labelregions(). You can
|
||||
* use it to find the centre of gravity of blobs in an image, for example.
|
||||
*
|
||||
* See also: vips_hist_find(), im_label_regions().
|
||||
* See also: vips_hist_find(), vips_labelregions().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
|
@ -307,26 +307,40 @@ class TestArithmetic(unittest.TestCase):
|
||||
|
||||
def test_histfind(self):
|
||||
im = Vips.Image.black(50, 100)
|
||||
test = im.insert(im + 100, 50, 0, expand = True)
|
||||
test = im.insert(im + 10, 50, 0, expand = True)
|
||||
|
||||
for fmt in all_formats:
|
||||
hist = test.cast(fmt).hist_find()
|
||||
self.assertAlmostEqualObjects(hist.getpoint(0,0), [5000])
|
||||
self.assertAlmostEqualObjects(hist.getpoint(100,0), [5000])
|
||||
self.assertAlmostEqualObjects(hist.getpoint(12,0), [0])
|
||||
self.assertAlmostEqualObjects(hist.getpoint(10,0), [5000])
|
||||
self.assertAlmostEqualObjects(hist.getpoint(5,0), [0])
|
||||
|
||||
test = test * [1, 2, 3]
|
||||
|
||||
for fmt in all_formats:
|
||||
hist = test.cast(fmt).hist_find(band = 0)
|
||||
self.assertAlmostEqualObjects(hist.getpoint(0,0), [5000])
|
||||
self.assertAlmostEqualObjects(hist.getpoint(100,0), [5000])
|
||||
self.assertAlmostEqualObjects(hist.getpoint(12,0), [0])
|
||||
self.assertAlmostEqualObjects(hist.getpoint(10,0), [5000])
|
||||
self.assertAlmostEqualObjects(hist.getpoint(5,0), [0])
|
||||
|
||||
hist = test.cast(fmt).hist_find(band = 1)
|
||||
self.assertAlmostEqualObjects(hist.getpoint(0,0), [5000])
|
||||
self.assertAlmostEqualObjects(hist.getpoint(200,0), [5000])
|
||||
self.assertAlmostEqualObjects(hist.getpoint(12,0), [0])
|
||||
self.assertAlmostEqualObjects(hist.getpoint(20,0), [5000])
|
||||
self.assertAlmostEqualObjects(hist.getpoint(5,0), [0])
|
||||
|
||||
def test_histfind_indexed(self):
|
||||
im = Vips.Image.black(50, 100)
|
||||
test = im.insert(im + 10, 50, 0, expand = True)
|
||||
index = test / 10
|
||||
|
||||
for x in noncomplex_formats:
|
||||
for y in [Vips.BandFormat.UCHAR, Vips.BandFormat.USHORT]:
|
||||
a = test.cast(x)
|
||||
b = index.cast(y)
|
||||
hist = a.hist_find_indexed(b)
|
||||
|
||||
self.assertAlmostEqualObjects(hist.getpoint(0,0), [0])
|
||||
self.assertAlmostEqualObjects(hist.getpoint(1,0), [50000])
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user