我想用 Python 从 16 位灰度图像生成直方图。当我运行以下代码时,出现缓冲区溢出。
#!/usr/bin/python
from PIL import Image
import numpy as np
i = Image.open('t.tif')
a = i.histogram()
print a
错误消息(缩短)
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)
现在,我完全可以看到从 16 位图像生成直方图会占用大量资源,但我能以某种方式规避这个问题吗?