Class BoxBlurOp
java.lang.Object
cloud.opencode.base.image.filter.BoxBlurOp
Box Blur Filter
均值模糊滤波器
Applies box blur (averaging filter) to images using integral images, achieving O(1) per-pixel computation regardless of kernel size.
使用积分图对图像应用均值模糊(均值滤波器), 无论核大小如何,每像素计算复杂度均为 O(1)。
Features | 主要功能:
- O(1) per-pixel box blur via integral image - 通过积分图实现 O(1) 每像素均值模糊
- Independent R/G/B channel processing - 独立 R/G/B 通道处理
- Alpha channel preservation - Alpha 通道保持不变
- Efficient for large kernel sizes - 对大核尺寸高效
Usage Examples | 使用示例:
// Mild blur with 3x3 kernel
BufferedImage blurred = BoxBlurOp.apply(image, 3);
// Strong blur with 31x31 kernel
BufferedImage blurred = BoxBlurOp.apply(image, 31);
Performance | 性能特性:
- Time: O(W * H) regardless of kernel size - 时间: O(W * H) 与核大小无关
- Space: O(W * H) for integral image per channel - 空间: 每通道 O(W * H) 用于积分图
Security | 安全性:
- Thread-safe: Yes (stateless) - 线程安全: 是(无状态)
- Since:
- JDK 25, opencode-base-image V2.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImageapply(BufferedImage image, int kernelSize) Apply box blur to an image using integral images.
-
Method Details
-
apply
Apply box blur to an image using integral images. 使用积分图对图像应用均值模糊。- Parameters:
image- the source image | 源图像kernelSize- the kernel size (must be odd and >= 1) | 核大小(必须为奇数且 >= 1)- Returns:
- the blurred image | 模糊后的图像
- Throws:
ImageOperationException- if image is null or kernelSize is invalid | 当图像为 null 或核大小无效时抛出
-