Class HistogramEqualizationOp
java.lang.Object
cloud.opencode.base.image.histogram.HistogramEqualizationOp
Histogram Equalization Operations
直方图均衡化操作工具类
Provides histogram equalization for grayscale and color images. Grayscale equalization uses a CDF-based lookup table; color equalization converts to HSV and equalizes only the V (value/brightness) channel.
提供灰度图像和彩色图像的直方图均衡化。 灰度均衡化使用基于 CDF 的查找表;彩色均衡化转换为 HSV 并仅均衡 V(亮度)通道。
Features | 主要功能:
- Grayscale histogram equalization via LUT - 通过查找表实现灰度直方图均衡化
- Color histogram equalization via HSV V-channel - 通过 HSV V 通道实现彩色直方图均衡化
Usage Examples | 使用示例:
BufferedImage equalized = HistogramEqualizationOp.apply(grayImage);
BufferedImage colorEqualized = HistogramEqualizationOp.applyColor(colorImage);
Performance | 性能特性:
- Time complexity: O(w * h) - 时间复杂度: O(w * h)
- Space complexity: O(w * h) for output image - 空间复杂度: O(w * h) 输出图像
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) Apply histogram equalization to a grayscale image.static BufferedImageapplyColor(BufferedImage image) Apply histogram equalization to a color image via HSV V-channel.
-
Method Details
-
apply
Apply histogram equalization to a grayscale image. 对灰度图像应用直方图均衡化。Algorithm: compute histogram, build CDF, create LUT where LUT[i] = round(CDF[i] * 255 / totalPixels), then apply via LookupTableOp.
算法:计算直方图,构建 CDF,创建查找表 LUT[i] = round(CDF[i] * 255 / totalPixels),然后通过 LookupTableOp 应用。
- Parameters:
image- the source image | 源图像- Returns:
- the equalized image | 均衡化后的图像
- Throws:
NullPointerException- if image is null | 当图像为 null 时抛出
-
applyColor
Apply histogram equalization to a color image via HSV V-channel. 通过 HSV V 通道对彩色图像应用直方图均衡化。Algorithm: convert RGB to HSV, equalize the V channel histogram, convert HSV back to RGB. Hue and Saturation are preserved.
算法:将 RGB 转换为 HSV,均衡化 V 通道直方图, 将 HSV 转换回 RGB。色相和饱和度保持不变。
- Parameters:
image- the source color image | 源彩色图像- Returns:
- the equalized color image | 均衡化后的彩色图像
- Throws:
NullPointerException- if image is null | 当图像为 null 时抛出
-