Name
mean_image — Smooth by averaging.通过平均来平滑
Signature签名
mean_image(Image : ImageMean : MaskWidth, MaskHeight : )
Description描述
mean_image算子对所有输入图像(图像)的灰度值进行线性平滑。滤波器矩阵由1组成(相等计算),大小为MaskHeight x MaskWidth。卷积的结果除以MaskHeight x MaskWidth。对于边界处理,灰度值反映在图像的边缘。
对于mean_image,使用SIMD技术实现了特殊的优化。这些特殊优化的实际应用由系统参数'mmx_enable'控制(参见set_system)。如果` mmx_enable `设置为` true `(并且SIMD指令集可用),则使用SIMD技术执行内部计算。请注意,SIMD技术在大而紧凑的输入区域上表现最好。根据输入区域和硬件的能力,使用SIMD技术执行mean_image甚至可能比没有SIMD技术时花费更多的时间。
无论如何,选择图像的输入区域,避免任何边界处理,有利于mean_image的性能。
有关平滑滤波器概念的解释,请参阅“滤波器/平滑”一章的介绍。
Attention 注意
如果MaskHeight或MaskWidth的值是偶数而不是奇数,则例程使用下一个更大的奇数值(这样始终确定过滤器掩码的中心)。
如果MaskHeight小于Image高度的两倍,则可以在OpenCL设备上对byte、int2、uint2、int4和真实图像执行mean_image。对于OpenCL,均值滤波值在内部使用32位有符号整数(适用于所有整数图像类型)或单精度浮点数(适用于真实图像)计算。如果Image是int4或真实图像,并且使用了完整的动态范围,则可能导致溢出(从而导致错误的结果)。此外,为了提高性能,如果MaskWidth大于9,则计算每行图像的全扫描(仍然使用32位整数或单精度浮点运算)。即使byte、int2或uint2类型的图像非常宽,也会导致溢出。在这种情况下,应该使用mean_image的CPU版本。
注意,如果使用缩小域的图像作为输入,过滤器运算符可能会返回意想不到的结果。请参阅过滤器章节。
Parameters参数
Image (input_object) (multichannel-)image(-array) → object (byte* / int2* / uint2* / int4* / int8 / real* / vector_field) *allowed for compute devices
Image to be smoothed. 要平滑的图像
输出参数
ImageMean (output_object) (multichannel-)image(-array) → object (byte / int2 / uint2 / int4 / int8 / real / vector_field)
Smoothed image. 平滑后的图像。
MaskWidth (input_control) extent.x → (integer)
Width of filter mask. 滤镜遮罩宽度
Default value: 9
建议值: 3, 5, 7, 9, 11, 15, 23, 31, 43, 61, 101
Typical range of values: 1 ≤ MaskWidth ≤ 501
Minimum increment: 2
Recommended increment: 2
Restriction: odd(MaskWidth)
MaskHeight (input_control) extent.y → (integer)
Height of filter mask. 滤光罩的高度。
Default value: 9
建议值: 3, 5, 7, 9, 11, 15, 23, 31, 43, 61, 101
Typical range of values: 1 ≤ MaskHeight ≤ 501
Minimum increment: 2
Recommended increment: 2
Restriction: odd(MaskHeight)