ImageStat Module

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

class PIL.ImageStat.Stat(image_or_list, mask=None)

Calculate statistics for the given image. If a mask is included, only the regions covered by that mask are included in the statistics. You can also pass in a previously calculated histogram.

Parameters:
  • image – A PIL image, or a precalculated histogram.
  • mask – An optional mask.
extrema

Min/max values for each band in the image.

count

Total number of pixels.

sum

Sum of all pixels.

sum2

Squared sum of all pixels.

pixel

Average pixel level.

median

Median pixel level.

rms

RMS (root-mean-square).

var

Variance.

stddev

Standard deviation.

This Page

Need help?

You can seek realtime assistance via IRC at irc://irc.freenode.net#pil. You can also post to the Image-SIG mailing list. And, of course, there's Stack Overflow.

If you've discovered a bug, you can open an issue on Github.