java.lang.Object
dev.lukebemish.dynamicassetgenerator.api.colors.clustering.Clusterer

public class Clusterer extends Object
A tool for grouping colors by agglomerative clustering. Groups are represented by Clusters.
  • Constructor Details

    • Clusterer

      public Clusterer(double cutoff)
      Creates a new palette clusterer with the given parameters.
      Parameters:
      cutoff - if two clusters are within this distance, they will be merged, Use negative values to represent any distance.
  • Method Details

    • addCluster

      public void addCluster(Cluster cluster)
      Adds the provided cluster to this clusterer.
    • run

      public void run()
      Until there are no more clusters to merge, merges the closest two clusters whose minimum distance is below the cutoff.
    • clusterCount

      public int clusterCount()
      Returns:
      the number of clusters present in the clusterer
    • areCategoriesEquivalent

      public boolean areCategoriesEquivalent(int colorA, int colorB)
      Returns:
      whether the two provided colors are in the same cluster. If neither are present, returns false
    • getCategory

      public int getCategory(int v)
      Returns:
      an integer index identifying the cluster the provided color can be found in, or -1 if it is not in any cluster
    • minimumSpacing

      public static double minimumSpacing(Collection<Integer> integers)
      Returns:
      the minimum CIELAB distance between any two RGB colors in the provided collection
    • maximumSpacing

      public static double maximumSpacing(Collection<Integer> integers)
      Returns:
      the maximum CIELAB distance between any two RGB colors in the provided collection
    • averageSpacing

      public static double averageSpacing(Collection<Integer> integers)
      Returns:
      the average CIELAB distance between any two RGB colors in the provided collection