diff --git a/ChangeLog b/ChangeLog index 25a2ac29..7dfc96ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/TODO b/TODO index c0c870c7..2ecfeb7b 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/python/Vips.py b/python/Vips.py index 81ddc03b..8f286923 100644 --- a/python/Vips.py +++ b/python/Vips.py @@ -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", diff --git a/python/find_class_methods.py b/python/find_class_methods.py index 902291cf..9fc31e3f 100755 --- a/python/find_class_methods.py +++ b/python/find_class_methods.py @@ -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() diff --git a/test/test_conversion.py b/test/test_conversion.py index 5302f327..b7d095a7 100755 --- a/test/test_conversion.py +++ b/test/test_conversion.py @@ -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):