使用 Pillow 库计算图像中每个波段所有像素的标准偏差


在本程序中,我们将使用 Pillow 库计算每个通道中所有像素的标准偏差。图像中共有 3 个通道,因此我们将获得三个值的列表。

原始图像

算法

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.

示例代码

from PIL import Image, ImageStat

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

输出

[72.25694839223894, 66.24724750077299, 65.50769196475312]

更新时间:2021 年 3 月 18 日

1K+ 次浏览

开启你的 职业生涯

完成课程获取认证

开始
广告
© . All rights reserved.