Class GaussianBlurOp
java.lang.Object
cloud.opencode.base.image.filter.GaussianBlurOp
Gaussian Blur Filter
高斯模糊滤波器
Applies Gaussian blur to images using a separable 1D kernel convolution, which is mathematically equivalent to a 2D Gaussian kernel but significantly faster.
使用可分离一维核卷积对图像进行高斯模糊处理, 数学上等效于二维高斯核但速度显著更快。
Features | 主要功能:
- Gaussian blur with automatic kernel size from sigma - 根据 sigma 自动计算核大小的高斯模糊
- Gaussian blur with explicit kernel size - 显式指定核大小的高斯模糊
- Separable convolution for O(w*h*k) performance - 可分离卷积实现 O(w*h*k) 性能
- Alpha channel preservation - Alpha 通道保持不变
Usage Examples | 使用示例:
// Auto kernel size from sigma
BufferedImage blurred = GaussianBlurOp.apply(image, 2.0);
// Explicit kernel size
BufferedImage blurred = GaussianBlurOp.apply(image, 1.5, 7);
Performance | 性能特性:
- Time: O(w * h * k) via separable convolution - 时间: O(w * h * k) 通过可分离卷积
- Space: O(w * h) - 空间: 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, double sigma) Apply Gaussian blur with automatic kernel size computed from sigma.static BufferedImageapply(BufferedImage image, double sigma, int kernelSize) Apply Gaussian blur with explicit kernel size.
-
Method Details
-
apply
Apply Gaussian blur with automatic kernel size computed from sigma. 使用根据 sigma 自动计算的核大小应用高斯模糊。The kernel size is computed as
ceil(3 * sigma) * 2 + 1, ensuring the kernel captures at least 3 standard deviations.核大小计算公式为
ceil(3 * sigma) * 2 + 1, 确保核至少覆盖 3 个标准差。- Parameters:
image- the source image | 源图像sigma- the Gaussian standard deviation (must be > 0) | 高斯标准差(必须大于 0)- Returns:
- the blurred image | 模糊后的图像
- Throws:
ImageOperationException- if image is null or sigma is not positive | 当图像为 null 或 sigma 不为正数时抛出
-
apply
Apply Gaussian blur with explicit kernel size. 使用显式指定的核大小应用高斯模糊。- Parameters:
image- the source image | 源图像sigma- the Gaussian standard deviation (must be > 0) | 高斯标准差(必须大于 0)kernelSize- the kernel size (must be odd and >= 1) | 核大小(必须为奇数且 >= 1)- Returns:
- the blurred image | 模糊后的图像
- Throws:
ImageOperationException- if parameters are invalid | 当参数无效时抛出
-