使用 Pillow 庫計算影像中每個波段所有畫素的均方根
在本程式中,我們將使用 Pillow 庫計算每個通道中所有畫素的均方根 (rms)。影像中總共有三個通道,因此,我們將得到一個包含三個值列表。
原始影像

演算法
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 root mean square of the pixels.
示例程式碼
from PIL import Image, ImageStat
im = Image.open('image_test.jpg')
stat = ImageStat.Stat(im)
print(stat.rms)輸出
[104.86876722259062, 96.13661429330132, 91.8480515464677]
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言
C++
C#
MongoDB
MySQL
Javascript
PHP