Class WhiteBalanceOp

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

public final class WhiteBalanceOp extends Object
Gray World White Balance Operation 灰度世界白平衡操作工具类

Implements the Gray World assumption for automatic white balance correction. Each color channel is scaled so that its mean equals the overall gray mean.

实现灰度世界假设的自动白平衡校正。 将每个颜色通道进行缩放,使其均值等于总体灰度均值。

Features | 主要功能:

  • Gray World automatic white balance - 灰度世界自动白平衡
  • Per-channel mean normalization - 逐通道均值归一化

Usage Examples | 使用示例:

Raster balanced = WhiteBalanceOp.apply(raster);

Performance | 性能特性:

  • Time: O(n) where n = pixel count (two passes) - 时间: O(n),n 为像素数量(两次遍历)
  • Space: O(n) for output image - 空间: O(n) 用于输出图像

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)
      Apply Gray World white balance correction to a Raster. 对 Raster 应用灰度世界白平衡校正。

      Computes the mean of each RGB channel, then scales each channel so that its mean equals the overall gray mean (average of the three means). Returns a freshly allocated RGBA_8 raster preserving the source alpha channel.

      计算每个 RGB 通道的均值,缩放每个通道使其均值等于总体灰度均值(三个均值 的平均值)。返回新分配的 RGBA_8 raster,保留源 alpha 通道。

      Parameters:
      raster - the source raster | 源 raster
      Returns:
      the white-balanced RGBA_8 raster | 白平衡校正后的 RGBA_8 raster
      Throws:
      NullPointerException - if raster is null | 当 raster 为 null 时抛出
      Since:
      opencode-base-image V1.0.4