ImageStat ModuleΒΆ

doc:http://pillow.readthedocs.io/en/4.1.x/reference/ImageStat.html, http://effbot.org/imagingbook/imagestat.htm

Note

All source images in this document are derived from https://www.pexels.com (CC0 License).

>>> from PIL import Image, ImageStat
>>> img = Image.open("data/srcimg01.jpg")
>>> stat = ImageStat.Stat(img)
>>> print("""
... * Min/max values for each band in the image:
...     {.extrema}
...
... * Total number of pixels for each band in the image:
...     {.count}
...
... * Sum of all pixels for each band in the image:
...     {.sum}
...
... * Squared sum of all pixels for each band in the image:
...     {.sum2}
...
... * Average (arithmetic mean) pixel level for each band in the image:
...     {.mean}
...
... * Median pixel level for each band in the image:
...     {.median}
...
... * RMS (root-mean-square) for each band in the image:
...     {.rms}
...
... * Variance for each band in the image:
...     {.var}
...
... * Standard deviation for each band in the image:
...     {.stddev}
... """.format(*((stat, ) * 9)))

* Min/max values for each band in the image:
    [(0, 255), (0, 255), (0, 255)]

* Total number of pixels for each band in the image:
    [298150, 298150, 298150]

* Sum of all pixels for each band in the image:
    [62725024.0, 62043489.0, 62318645.0]

* Squared sum of all pixels for each band in the image:
    [14090956572.0, 14026187561.0, 14253197929.0]

* Average (arithmetic mean) pixel level for each band in the image:
    [210.38076136173066, 208.09488177092067, 209.01775951702163]

* Median pixel level for each band in the image:
    [238, 241, 247]

* RMS (root-mean-square) for each band in the image:
    [217.39664193095905, 216.89643518395044, 218.64459769365556]

* Variance for each band in the image:
    [3001.2351717161505, 3740.5837762521605, 4117.036307105007]

* Standard deviation for each band in the image:
    [54.78353011367696, 61.160312100676535, 64.16413567644317]