I would like to generate a histogram from a 16 bit greyscale image with Python. When I run the following code, I get a buffer overflow.
#!/usr/bin/python
from PIL import Image
import numpy as np
i = Image.open('t.tif')
a = i.histogram()
print a
Error message (shortened)
tdettmer@thinkpad:~/code/histogram$ ./h.py
*** buffer overflow detected ***: /usr/bin/python terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x37)[0x7f3f33ed6007]
/lib/x86_64-linux-gnu/libc.so.6(+0x107f00)[0x7f3f33ed4f00]
/usr/lib/python2.7/dist-packages/PIL/_imaging.so(ImagingHistogramNew+0x33)
Now, I can totally see that generating a histogram from a 16 bit image uses a lot of resources, but can I somehow circumvent this problem?