Class ImageAnalysis
java.lang.Object
com.github.darksoulq.abyssallib.common.color.ImageAnalysis
A utility class for performing advanced color analysis on
BufferedImage instances.
This class provides methods for dominant color extraction using K-Means clustering, average color calculation, and histogram-based color quantization.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ColorPaletteextractDominantColors(BufferedImage image, int k) Extracts a palette of dominant colors from an image using the K-Means clustering algorithm.static org.bukkit.ColorgetAverageColor(BufferedImage image) Calculates the global average color of an image, ignoring fully transparent pixels.static ColorPalettegetHistogramPalette(BufferedImage image, int bins) Generates a color palette based on a color histogram with a specified number of bins.
-
Constructor Details
-
ImageAnalysis
public ImageAnalysis()
-
-
Method Details
-
extractDominantColors
Extracts a palette of dominant colors from an image using the K-Means clustering algorithm.- Parameters:
image- TheBufferedImageto analyze.k- The number of dominant colors to extract (the number of clusters).- Returns:
- A
ColorPalettecontaining the extracted dominant colors.
-
getAverageColor
Calculates the global average color of an image, ignoring fully transparent pixels.- Parameters:
image- TheBufferedImageto process.- Returns:
- The average
Colorof the image, orColor.WHITEif no non-transparent pixels exist.
-
getHistogramPalette
Generates a color palette based on a color histogram with a specified number of bins.This method quantizes image colors and selects the most frequent ones to build a palette.
- Parameters:
image- TheBufferedImageto analyze.bins- The number of bins to use for color quantization (determines color granularity).- Returns:
- A
ColorPalettecontaining up to 16 of the most frequent quantized colors.
-