Class GaussianBlurOp

java.lang.Object
cloud.opencode.base.image.filter.GaussianBlurOp

public final class GaussianBlurOp extends Object
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

      public static Raster apply(Raster raster, double sigma)
      Apply Gaussian blur to a Raster with automatic kernel size computed from sigma (radius = ceil(3 * sigma)). 对 Raster 应用高斯模糊,根据 sigma 自动选择核大小 (半径 = ceil(3 * sigma))。
      Parameters:
      raster - the source raster | 源 raster
      sigma - 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

      public static Raster apply(Raster raster, double sigma, int kernelSize)
      Apply Gaussian blur to a Raster with explicit kernel size. 对 Raster 应用高斯模糊(显式核大小)。
      Parameters:
      raster - the source raster | 源 raster
      sigma - 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