統計效果與Spread效果相似,唯一的區別在於,它會通過對相鄰像素值執行數學運算的結果來替換每個像素。寬度和高度定義了相鄰像素的大小或孔徑。
統計操作的類型可以是以下任意一種:
- ‘gradient’
- ‘maximum’
- ‘mean’
- ‘median’
- ‘minimum’
- ‘mode’
- ‘nonpeak’
- ‘root_mean_square’
- ‘standard_deviation’
用法: wand.image.statistic(stat, width, height, channel)
參數:
參數 | 輸入類型 | 描述 |
---|---|---|
stat | basestring | 要計算的統計信息的類型。參見STATISTIC_TYPES。 |
width | numbers.Integral | X軸上相鄰像素的大小。 |
height | numbers.Integral | Y軸上相鄰像素的大小。 |
channel | basestring | 目標的可選顏色通道。 |
輸入圖片:
範例1:
# Import Image from wand.image module
from wand.image import Image
# Read image using Image function
with Image(filename ="koala.jpeg") as img:
img.statistic("median", width = 8, height = 5)
img.save(filename ="kl-statistic.jpeg")
輸出:
輸入圖片:
範例2:
# Import Image from wand.image module
from wand.image import Image
# Read image using Image function
with Image(filename ="road.jpeg") as img:
img.statistic("median", width = 8, height = 5)
img.save(filename ="rd-statistic.jpg")
輸出:
相關用法
- Python Wand function()用法及代碼示例
- Python Wand gaussian_blur()用法及代碼示例
- Python Wand transform()用法及代碼示例
- Python Wand crop()用法及代碼示例
- Python Wand rotational_blur()用法及代碼示例
- Python Wand Image()用法及代碼示例
- Python Wand shade()用法及代碼示例
- Python Wand sharpen()用法及代碼示例
- Python Wand adaptive_sharpen()用法及代碼示例
- Python Wand noise()用法及代碼示例
- Python Wand blue_shift()用法及代碼示例
- Python Wand color_matrix()用法及代碼示例
注:本文由純淨天空篩選整理自RahulSabharwal大神的英文原創作品 Wand statistic() function in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。