Class SaturationOp

java.lang.Object
cloud.opencode.base.image.color.SaturationOp

public final class SaturationOp extends Object
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 | 使用示例:

Raster vivid = SaturationOp.apply(raster, 1.5);
Raster gray = SaturationOp.apply(raster, 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 Details

    • apply

      public static Raster apply(Raster raster, double factor)
      Adjust the saturation of a Raster. 调整 Raster 的饱和度。

      A factor of 0.0 produces a grayscale raster, 1.0 leaves the raster unchanged, and values greater than 1.0 increase saturation. Returns a freshly allocated RGBA_8 raster preserving the source alpha channel.

      因子为 0.0 时产生灰度,1.0 不变,大于 1.0 时增加饱和度。返回新分配的 RGBA_8 raster,保留源 alpha 通道。

      Parameters:
      raster - the source raster | 源 raster
      factor - the saturation factor (must be >= 0) | 饱和度因子(必须 >= 0)
      Returns:
      the saturation-adjusted RGBA_8 raster | 饱和度调整后的 RGBA_8 raster
      Throws:
      NullPointerException - if raster is null | 当 raster 为 null 时抛出
      ImageOperationException - if factor is negative, NaN, or infinite | 当因子非法时抛出
      Since:
      opencode-base-image V1.0.4