2009/8/4 Guy K. Kloss <g.kl...@massey.ac.nz> > On Mon, 27 Jul 2009 19:08:16 Gary Capell wrote: > > I get this problem (with python2.6, PIL 1.1.6, numpy 1.3.0 ) > > > > >>> from PIL import Image > > >>> import numpy > > >>> i = Image.open('chart_bl.tif') > > >>> a = numpy.asarray(i) > > >>> o.size, a.shape > > ((13228, 18710), (18710, 13228)) > > >>> o.size, a.shape, a.dtype > > ((13228, 18710), (18710, 13228), dtype('bool')) > > >>> numpy.histogram(a) > > Segmentation fault > > I'm assuming your image is a binary (black and white only) image. In that > case > histogramming doesn't make much sense. If you want the numbers of ones and > zeros, just do something like that: > > ones = a.sum() > zeros = a.shape[0] * a.shape[1] - ones > > I'm OK with the operation not making much sense, I'm not OK with python dying with a segmentation fault.
For what it's worth, I also get a segfault with a.sum(): >>> i = Image.open('/tmp/chart_bl.tif') >>> a = numpy.asarray(i) >>> a.sum() Segmentation fault
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig