Class MedianBlurOp
java.lang.Object
cloud.opencode.base.image.filter.MedianBlurOp
Median Blur Filter
中值模糊滤波器
Applies median filtering to images using the Huang sliding histogram algorithm, achieving O(W*H*K) time complexity instead of the naive O(W*H*K^2).
使用 Huang 滑动直方图算法对图像进行中值滤波, 时间复杂度为 O(W*H*K),优于朴素算法的 O(W*H*K^2)。
Features | 主要功能:
- Effective salt-and-pepper noise removal - 有效去除椒盐噪声
- Edge-preserving smoothing - 保边平滑
- Huang sliding histogram for efficient computation - Huang 滑动直方图高效计算
- Independent R/G/B channel processing with alpha preservation - 独立 R/G/B 通道处理,Alpha 通道保持不变
Usage Examples | 使用示例:
// Remove salt-and-pepper noise with 3x3 median filter
Raster filtered = MedianBlurOp.apply(noisyRaster, 3);
// Stronger filtering with 5x5 kernel
Raster filtered = MedianBlurOp.apply(noisyRaster, 5);
Performance | 性能特性:
- Time: O(W * H * K) via Huang sliding histogram - 时间: O(W * H * K) 通过 Huang 滑动直方图
- Space: O(W * H) + O(256) histogram - 空间: O(W * H) + O(256) 直方图
Security | 安全性:
- Thread-safe: Yes (stateless) - 线程安全: 是(无状态)
- Since:
- JDK 25, opencode-base-image V2.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
-
Method Details
-
apply
- Parameters:
raster- the source raster | 源 rasterkernelSize- the kernel size (must be odd and >= 3) | 核大小(奇数且 >= 3)- Returns:
- the filtered raster | 滤波后的 raster
- Throws:
ImageOperationException- if raster is null or kernelSize is invalid | 参数无效时抛出- Since:
- opencode-base-image V1.0.4
-
apply
Apply median filter to aRasterwith optional caller-provided output buffer. Output format isRGBA_8when the source has alpha, otherwiseRGB_8. 对Raster应用中值滤波,可指定输出缓冲。 源含 alpha 时输出RGBA_8,否则RGB_8。- Parameters:
raster- the source raster | 源 rasterkernelSize- the kernel size (must be odd and >= 3) | 核大小(奇数且 >= 3)dst- optional output raster, may be null | 可选输出 raster,可为 null- Returns:
- the filtered raster | 滤波后的 raster
- Throws:
ImageOperationException- if raster is null or kernelSize is invalid | 参数无效时抛出- Since:
- opencode-base-image V1.0.4
-