# Calculating the standard deviation of all pixels for each band in an image using the Pillow library

PillowPythonServer Side ProgrammingProgramming

In this program, we will calculate the standard deviation of all the pixels in each channel using the Pillow library. There are total 3 channels in an image and therefore we will get a list of three values.

## Algorithm

Step 1: Import Image and ImageStat libraries.
Step 2: Open the image.
Step 3: Pass the image to the stat function of the imagestat class.
Step 4: Print the standard deviation of the pixels.

## Example Code

from PIL import Image, ImageStat

im = Image.open('image_test.jpg')
stat = ImageStat.Stat(im)
print(stat.stddev)

## Output

[72.25694839223894, 66.24724750077299, 65.50769196475312]
Published on 18-Mar-2021 07:17:12