add bandand() bandor() bandeor() to py
convenience funcs
This commit is contained in:
parent
cea1e29527
commit
36331739ab
@ -4,6 +4,7 @@
|
|||||||
- vipsthumbnail uses vips_resize() rather than its own code
|
- vipsthumbnail uses vips_resize() rather than its own code
|
||||||
- vipsthumbnail uses vips_premultiply() for better alpha quality
|
- vipsthumbnail uses vips_premultiply() for better alpha quality
|
||||||
- vips_copy() can turn 1xN or Nx1 M-band images into MxN one-band images
|
- vips_copy() can turn 1xN or Nx1 M-band images into MxN one-band images
|
||||||
|
- added bandand() bandor() bandeor() convenience funcs to Python
|
||||||
|
|
||||||
7/5/15 started 8.0.3
|
7/5/15 started 8.0.3
|
||||||
- dzsave and tif pyr write could fail for some image dimensions, thanks Jonas
|
- dzsave and tif pyr write could fail for some image dimensions, thanks Jonas
|
||||||
|
@ -840,6 +840,18 @@ class Image(Vips.Image):
|
|||||||
"""Return the nearest integral value."""
|
"""Return the nearest integral value."""
|
||||||
return self.round(Vips.OperationRound.RINT)
|
return self.round(Vips.OperationRound.RINT)
|
||||||
|
|
||||||
|
def bandand(self):
|
||||||
|
"""AND image bands together."""
|
||||||
|
return self.bandbool(Vips.OperationBoolean.AND)
|
||||||
|
|
||||||
|
def bandor(self):
|
||||||
|
"""OR image bands together."""
|
||||||
|
return self.bandbool(Vips.OperationBoolean.OR)
|
||||||
|
|
||||||
|
def bandeor(self):
|
||||||
|
"""EOR image bands together."""
|
||||||
|
return self.bandbool(Vips.OperationBoolean.EOR)
|
||||||
|
|
||||||
def bandsplit(self):
|
def bandsplit(self):
|
||||||
"""Split an n-band image into n separate images."""
|
"""Split an n-band image into n separate images."""
|
||||||
return [x for x in self]
|
return [x for x in self]
|
||||||
|
@ -146,7 +146,7 @@ class TestConversion(unittest.TestCase):
|
|||||||
def test_band_and(self):
|
def test_band_and(self):
|
||||||
def band_and(x):
|
def band_and(x):
|
||||||
if isinstance(x, Vips.Image):
|
if isinstance(x, Vips.Image):
|
||||||
return x.bandbool(Vips.OperationBoolean.AND)
|
return x.bandand()
|
||||||
else:
|
else:
|
||||||
return [reduce(lambda a, b: int(a) & int(b), x)]
|
return [reduce(lambda a, b: int(a) & int(b), x)]
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ class TestConversion(unittest.TestCase):
|
|||||||
def test_band_or(self):
|
def test_band_or(self):
|
||||||
def band_or(x):
|
def band_or(x):
|
||||||
if isinstance(x, Vips.Image):
|
if isinstance(x, Vips.Image):
|
||||||
return x.bandbool(Vips.OperationBoolean.OR)
|
return x.bandor()
|
||||||
else:
|
else:
|
||||||
return [reduce(lambda a, b: int(a) | int(b), x)]
|
return [reduce(lambda a, b: int(a) | int(b), x)]
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ class TestConversion(unittest.TestCase):
|
|||||||
def test_band_eor(self):
|
def test_band_eor(self):
|
||||||
def band_eor(x):
|
def band_eor(x):
|
||||||
if isinstance(x, Vips.Image):
|
if isinstance(x, Vips.Image):
|
||||||
return x.bandbool(Vips.OperationBoolean.EOR)
|
return x.bandeor()
|
||||||
else:
|
else:
|
||||||
return [reduce(lambda a, b: int(a) ^ int(b), x)]
|
return [reduce(lambda a, b: int(a) ^ int(b), x)]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user