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
Raster blurred = GaussianBlurOp.apply(raster, 2.0);
// Explicit kernel size
Raster blurred = GaussianBlurOp.apply(raster, 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 Details
-
apply
Apply Gaussian blur to aRasterwith automatic kernel size computed fromsigma(radius =ceil(3 * sigma)). 对Raster应用高斯模糊,根据sigma自动选择核大小 (半径 =ceil(3 * sigma))。- Parameters:
raster- the source raster | 源 rastersigma- the Gaussian standard deviation (must be > 0) | 高斯标准差(必须大于 0)- Returns:
- the blurred raster | 模糊后的 raster
- Throws:
ImageOperationException- if raster is null or sigma is invalid | 参数无效时抛出- Since:
- opencode-base-image V1.0.4
-
apply
- Parameters:
raster- the source raster | 源 rastersigma- the Gaussian standard deviation (must be > 0) | 高斯标准差kernelSize- the kernel size (must be odd and >= 1) | 核大小(奇数且 >= 1)- Returns:
- the blurred raster | 模糊后的 raster
- Throws:
ImageOperationException- if parameters are invalid | 参数无效时抛出- Since:
- opencode-base-image V1.0.4
-