Python中的魔杖统计()函数
统计效果类似于传播效果,唯一的区别是,它将每个像素替换为对相邻像素值执行的数学运算的结果。宽度和高度定义了相邻像素的大小或孔径。
统计操作的类型可以是以下任何一种:
- '坡度'
- '最大'
- '意思是'
- '中位数'
- '最低限度'
- '模式'
- “非高峰”
- 'root_mean_square'
- '标准偏差'
Syntax : wand.image.statistic(stat, width, height, channel)
Parameters:
Parameter | Input Type | Description |
---|---|---|
stat | basestring | The type of statistic to calculate. See STATISTIC_TYPES. |
width | numbers.Integral | The size of neighboring pixels on the X-axis. |
height | numbers.Integral | The size of neighboring pixels on the Y-axis. |
channel | basestring | Optional color channel to target. |
输入图像:
示例 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")
输出: