Python Imaging Library Handbook |
The ImageStat module calculates global statistics for an image, or for a region of an image.
ImageStat.Stat(image) => Stat instance
ImageStat.Stat(image, mask) => Stat instance
Calculates statistics for the give image. If a mask is included, only the regions covered by that mask are included in the statistics.
ImageStat.Stat(list) => Stat instance
Same as above, but calculates statistics for a previously calculated histogram.
The following attributes contain a sequence with one element for each layer in the image. All attributes are lazily evaluated; if you don't need a value, it won't be calculated.
stat.extrema
(Attribute). Get min/max values for each band in the image.
stat.count
(Attribute). Get total number of pixels.
stat.sum
(Attribute). Get sum of all pixels.
stat.sum2
(Attribute). Squared sum of all pixels.
stat.mean
(Attribute). Average pixel level.
stat.median
(Attribute). Median pixel level.
stat.rms
(Attribute). RMS (root-mean-square).
stat.var
(Attribute). Variance.
stat.stddev
(Attribute). Standard deviation.