We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.

The ImageStat Module

The ImageStat module calculates global statistics for an image, or for a region of an image.

Functions

Stat

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.

Attributes

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.

extrema

stat.extrema

(Attribute). Get min/max values for each band in the image.

count

stat.count

(Attribute). Get total number of pixels.

sum

stat.sum

(Attribute). Get sum of all pixels.

sum2

stat.sum2

(Attribute). Squared sum of all pixels.

pixel

stat.mean

(Attribute). Average pixel level.

median

stat.median

(Attribute). Median pixel level.

rms

stat.rms

(Attribute). RMS (root-mean-square).

var

stat.var

(Attribute). Variance.

stddev

stat.stddev

(Attribute). Standard deviation.