Class Clusterer
java.lang.Object
dev.lukebemish.dynamicassetgenerator.api.colors.clustering.Clusterer
A tool for grouping colors by agglomerative clustering. Groups are represented by
Clusters.-
Constructor Summary
ConstructorsConstructorDescriptionClusterer(double cutoff) Creates a new palette clusterer with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCluster(Cluster cluster) Adds the provided cluster to this clusterer.booleanareCategoriesEquivalent(int colorA, int colorB) static doubleaverageSpacing(Collection<Integer> integers) intintgetCategory(int v) static doublemaximumSpacing(Collection<Integer> integers) static doubleminimumSpacing(Collection<Integer> integers) voidrun()Until there are no more clusters to merge, merges the closest two clusters whose minimum distance is below the cutoff.
-
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
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
-1if it is not in any cluster
-
minimumSpacing
- Returns:
- the minimum CIELAB distance between any two RGB colors in the provided collection
-
maximumSpacing
- Returns:
- the maximum CIELAB distance between any two RGB colors in the provided collection
-
averageSpacing
- Returns:
- the average CIELAB distance between any two RGB colors in the provided collection
-