Class SharpenOp
java.lang.Object
cloud.opencode.base.image.filter.SharpenOp
Unsharp Mask Sharpening Filter
非锐化掩模锐化滤波器
Enhances image edges using unsharp masking: result = src + amount * (src - blur).
The blur is computed via GaussianBlurOp with a configurable sigma.
使用非锐化掩模增强图像边缘:result = src + amount * (src - blur)。
模糊通过 GaussianBlurOp 以可配置的 sigma 计算。
Features | 主要功能:
- Unsharp mask sharpening with configurable amount and sigma - 可配置强度和 sigma 的非锐化掩模锐化
- Default parameters: amount=1.0, sigma=1.0 - 默认参数:amount=1.0, sigma=1.0
- Per-channel processing with clamping to [0, 255] - 逐通道处理并钳制到 [0, 255]
- Alpha channel preservation - Alpha 通道保持不变
Usage Examples | 使用示例:
// Default sharpening (amount=1.0, sigma=1.0)
BufferedImage sharpened = SharpenOp.apply(image);
// Custom amount
BufferedImage sharpened = SharpenOp.apply(image, 1.5);
// Custom amount and sigma
BufferedImage sharpened = SharpenOp.apply(image, 2.0, 2.0);
Performance | 性能特性:
- Time: O(w * h * k) dominated by Gaussian blur - 时间: 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) Apply unsharp mask sharpening with default parameters (amount=1.0, sigma=1.0).static BufferedImageapply(BufferedImage image, double amount) Apply unsharp mask sharpening with custom amount and default sigma=1.0.static BufferedImageapply(BufferedImage image, double amount, double sigma) Apply unsharp mask sharpening with custom amount and sigma.
-
Method Details
-
apply
Apply unsharp mask sharpening with default parameters (amount=1.0, sigma=1.0). 使用默认参数(amount=1.0, sigma=1.0)应用非锐化掩模锐化。- Parameters:
image- the source image | 源图像- Returns:
- the sharpened image | 锐化后的图像
- Throws:
NullPointerException- if image is null | 当图像为 null 时抛出
-
apply
Apply unsharp mask sharpening with custom amount and default sigma=1.0. 使用自定义强度和默认 sigma=1.0 应用非锐化掩模锐化。- Parameters:
image- the source image | 源图像amount- the sharpening amount (must be >= 0) | 锐化强度(必须 >= 0)- Returns:
- the sharpened image | 锐化后的图像
- Throws:
NullPointerException- if image is null | 当图像为 null 时抛出ImageOperationException- if amount is negative, NaN, or infinite | 当 amount 为负数、NaN 或无穷时抛出
-
apply
Apply unsharp mask sharpening with custom amount and sigma. 使用自定义强度和 sigma 应用非锐化掩模锐化。The algorithm computes:
result = clamp(src + amount * (src - blur)), whereblur = GaussianBlurOp.apply(image, sigma).算法计算:
result = clamp(src + amount * (src - blur)), 其中blur = GaussianBlurOp.apply(image, sigma)。- Parameters:
image- the source image | 源图像amount- the sharpening amount (must be >= 0) | 锐化强度(必须 >= 0)sigma- the Gaussian blur sigma (must be > 0) | 高斯模糊 sigma(必须大于 0)- Returns:
- the sharpened image | 锐化后的图像
- Throws:
NullPointerException- if image is null | 当图像为 null 时抛出ImageOperationException- if amount is negative or sigma is not positive | 当 amount 为负数或 sigma 不为正数时抛出
-