使用 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 mean of the pixels.
示例程式碼
from PIL import Image, ImageStat
im = Image.open('image_test.jpg')
stat = ImageStat.Stat(im)
print(stat.mean)輸出
[76.00257724463832, 69.6674300254453, 64.38017448200654]
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP