I wrote:
> I'll into this for 1.1.6
make that "I'll look into this for 1.1.6".
> (patches are welcome).
I've attached a (preliminary) patch.
</F>
Index: PIL/ImageOps.py
===================================================================
--- PIL/ImageOps.py (revision 2382)
+++ PIL/ImageOps.py (working copy)
@@ -207,13 +207,15 @@
h = image.histogram(mask)
lut = []
for b in range(0, len(h), 256):
- step = reduce(operator.add, h[b:b+256]) / 255
- if step == 0:
- step = 1
- n = 0
- for i in range(256):
- lut.append(n / step)
- n = n + h[i+b]
+ histo = filter(None, h[b:b+256])
+ if len(histo) <= 1:
+ lut.append(range(256))
+ else:
+ step = (reduce(operator.add, histo) - histo[-1]) / 255
+ n = step / 2
+ for i in range(256):
+ lut.append(n / step)
+ n = n + h[i+b]
return _lut(image, lut)
##
_______________________________________________
Image-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/image-sig