Class SaturationOp
java.lang.Object
cloud.opencode.base.image.color.SaturationOp
Saturation Adjustment Operation
饱和度调整操作工具类
Adjusts image saturation by converting to HSV color space, scaling the saturation channel, and converting back to RGB.
通过转换为 HSV 颜色空间、缩放饱和度通道并转回 RGB 来调整图像饱和度。
Features | 主要功能:
- Saturation adjustment via HSV color space - 通过 HSV 颜色空间调整饱和度
- Factor 0.0 produces grayscale, 1.0 is unchanged, 2.0 doubles saturation - 因子 0.0 产生灰度图,1.0 不变,2.0 双倍饱和度
Usage Examples | 使用示例:
BufferedImage vivid = SaturationOp.apply(image, 1.5);
BufferedImage gray = SaturationOp.apply(image, 0.0);
Performance | 性能特性:
- Time: O(n) where n = pixel count - 时间: O(n),n 为像素数量
- Space: O(n) for intermediate HSV arrays - 空间: O(n) 用于中间 HSV 数组
Security | 安全性:
- Thread-safe: Yes (stateless) - 线程安全: 是(无状态)
- Null-safe: No - 空值安全: 否
- 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, double factor) Adjust the saturation of an image.
-
Method Details
-
apply
Adjust the saturation of an image. 调整图像的饱和度。A factor of 0.0 produces a grayscale image, 1.0 leaves the image unchanged, and values greater than 1.0 increase saturation.
因子为 0.0 时产生灰度图像,1.0 时图像不变,大于 1.0 时增加饱和度。
- Parameters:
image- the source image | 源图像factor- the saturation factor (must be >= 0) | 饱和度因子(必须 >= 0)- Returns:
- the saturation-adjusted image | 饱和度调整后的图像
- Throws:
ImageOperationException- if image is null or factor is negative | 当图像为 null 或因子为负时抛出
-