使用 Pillow 库计算图像中每个波段所有像素的方差
在这个程序中,我们将使用 Pillow 库计算每个通道中所有像素的方差。图像中总共有三个通道,因此,我们将得到一个三个值的列表。
原图

算法
Step 1: Import the 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 variance of the pixels.
示例代码
from PIL import Image, ImageStat
im = Image.open('image_test.jpg')
stat = ImageStat.Stat(im)
print(stat.var)输出
[5221.066590958682, 4388.697801428673, 4291.257706548981]
广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP