[Image-SIG] ImageStat median calculation off?
Bill Janssen
janssen at parc.com
Thu Apr 26 20:28:25 CEST 2007
I'm running the following program over a photo:
#!/usr/bin/env python
import sys, os, Image, ImageStat
im = Image.open(sys.argv[1])
im = im.convert("L")
h = im.histogram()
for i in range(len(h)):
print i, h[i]
s = ImageStat.Stat(h)
print s.mean, s.stddev, s.extrema, s.median
v = max(h)
l = len([x for x in h if (x == v)])
if l > 1:
print 'Multiple background colors found'
else:
print 'background gray shade is', h.index(v), '--', v, 'out of', sum(h)
I keep getting different values for "s.median" than I get for "h.index(v)".
Shouldn't they be the same value? Am I missing something?
This is PIL 1.1.5 with the system Python 2.3.5 on a G4 PowerPC OS X machine.
Bill
More information about the Image-SIG
mailing list