make python bandrank() work like bandjoin()

we had a custom wrapper for bandjoin(), but bandrank(), a function with
an almost identical interface, did not ... this was confusing

bandrank() now has a custom wrapper too ... this breaks API
unfortunately, but hopefully very few people were using this thing and
it's better to make this change as soon as possible
This commit is contained in:
John Cupitt 2016-03-01 12:12:51 +00:00
parent 25c3c49d1c
commit 2ea5c5f7e5
5 changed files with 17 additions and 37 deletions

View File

@ -17,6 +17,7 @@
- vipsthumbnail knows about webp shrink-on-load
- more vips_resize() tuning, a bit quicker now
- better behaviour for vips_cast() shift of non-int types (thanks apacheark)
- python .bandrank() now works like .bandjoin()
27/1/16 started 8.2.3
- fix a crash with SPARC byte-order labq vips images

32
TODO
View File

@ -1,34 +1,8 @@
better handling of cast+shift for non-int formats
before, im.cast(uchar, shift = true) where im was float and tagged as
rgb16 would not shift the image, since it's unclear how much to shift a float
type by
now we do two casts: first, we guess the numeric range from the
interpretation, so rgb16 would be ushort, so we cast float->ushort;
second, we cast to the target type and do the shift on the way
- python bandrank should work like bandjoin
- try SEQ_UNBUFFERED on jpg source, get out of order error?
- could load pdf thumbnails?
- new vips_reduce:
affine
$ time vipsthumbnail wtc.tif -o x.tif -s 7000
real 0m2.325s
user 0m8.316s
sys 0m0.256s
reduce
$ time vipsthumbnail wtc.tif -o x.tif -s 7000
real 0m1.677s
user 0m5.996s
sys 0m0.300s
- get some brightly coloured spots with nohalo / vsqbs on wobble.ws ... very
odd, the interpolation shouldn't change between bands
@ -36,12 +10,6 @@ second, we cast to the target type and do the shift on the way
- still not happy about float->int mask conversion in im_vips2mask.c
- need to follow up on
https://github.com/jcupitt/libvips/issues/347
trying new shrinker, also try resize change, should be fixed
- colour needs to split _build() into preprocess / process / postprocess
phases

View File

@ -930,6 +930,13 @@ class Image(Vips.Image):
else:
return _call_base("bandjoin", [[self] + other], {})
def bandrank(self, other, **kwargs):
"""Band-wise rank filter a set of images."""
if not isinstance(other, list):
other = [other]
return _call_base("bandrank", [[self] + other], kwargs)
def maxpos(self):
"""Return the coordinates of the image maximum."""
v, opts = self.max(x = True, y = True)
@ -1055,14 +1062,13 @@ class Image(Vips.Image):
# use find_class_methods.py to generate this list
# don't include "bandjoin", this needs to be wrapped by hand, see
# above
# don't include "bandjoin" or "bandrank", they need to be wrapped by hand,
# see above
class_methods = [
"system",
"sum",
"arrayjoin",
"bandrank",
"black",
"gaussnoise",
"text",

View File

@ -49,7 +49,7 @@ print 'found class methods:'
names = find_class_methods(vips_type_operation)
# filter out things we know we should not wrap
names -= set(["bandjoin"])
names -= set(["bandjoin", "bandrank"])
names = list(names)
names.sort()

View File

@ -208,12 +208,17 @@ class TestConversion(unittest.TestCase):
def bandrank(x, y):
if isinstance(x, Vips.Image) and isinstance(y, Vips.Image):
return Vips.Image.bandrank([x, y])
return x.bandrank([y])
else:
return median(x, y)
self.run_binary(self.all_images, bandrank, fmt = noncomplex_formats)
# we can mix images and constants, and set the index arg
a = self.mono.bandrank([2], index = 0)
b = (self.mono < 2).ifthenelse(self.mono, 2)
self.assertEqual((a - b).abs().min(), 0)
def test_cache(self):
def cache(x):
if isinstance(x, Vips.Image):