Class BilateralFilterOp
java.lang.Object
cloud.opencode.base.image.filter.BilateralFilterOp
Bilateral Filter
双边滤波器
Edge-preserving smoothing filter that averages nearby pixels weighted by both spatial proximity and intensity similarity. Flat regions are smoothed while edges are preserved.
保边平滑滤波器,通过空间距离和强度相似度的联合加权来平均邻近像素。 平坦区域被平滑,而边缘被保留。
Features | 主要功能:
- Edge-preserving smoothing via bilateral weighting - 通过双边加权实现保边平滑
- Configurable spatial and range sigma - 可配置的空间和范围 sigma
- Independent R, G, B channel processing - 独立处理 R、G、B 通道
- Alpha channel preservation - Alpha 通道保持不变
Usage Examples | 使用示例:
// Default bilateral filter (kernelSize=9, sigmaColor=75, sigmaSpace=75)
Raster smoothed = BilateralFilterOp.apply(raster);
// Custom parameters
Raster smoothed = BilateralFilterOp.apply(raster, 5, 50.0, 50.0);
Performance | 性能特性:
- Time: O(W * H * K^2) where K is kernel size - 时间: O(W * H * K^2) 其中 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 RasterApply bilateral filter to aRasterwith default parameters (kernelSize=9, sigmaColor=75, sigmaSpace=75).static RasterApply bilateral filter to aRasterwith custom parameters.static RasterApply bilateral filter to aRasterwith optional output buffer.
-
Method Details
-
apply
Apply bilateral filter to aRasterwith default parameters (kernelSize=9, sigmaColor=75, sigmaSpace=75). 使用默认参数对Raster应用双边滤波。- Parameters:
raster- the source raster | 源 raster- Returns:
- the filtered raster | 滤波后的 raster
- Throws:
NullPointerException- if raster is null | 当 raster 为 null 时抛出- Since:
- opencode-base-image V1.0.4
-
apply
Apply bilateral filter to aRasterwith custom parameters. 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)sigmaColor- the range sigma | 范围 sigmasigmaSpace- the spatial sigma | 空间 sigma- Returns:
- the filtered raster | 滤波后的 raster
- Throws:
ImageOperationException- if parameters are invalid | 参数无效时抛出- Since:
- opencode-base-image V1.0.4
-
apply
public static Raster apply(Raster raster, int kernelSize, double sigmaColor, double sigmaSpace, Raster dst) - Parameters:
raster- the source raster | 源 rasterkernelSize- the kernel size (must be odd and >= 3) | 核大小(奇数且 >= 3)sigmaColor- the range sigma | 范围 sigmasigmaSpace- the spatial sigma | 空间 sigmadst- optional output raster, may be null | 可选输出 raster,可为 null- Returns:
- the filtered raster | 滤波后的 raster
- Throws:
ImageOperationException- if parameters are invalid | 参数无效时抛出- Since:
- opencode-base-image V1.0.4
-