public class ColorClustering extends java.lang.Object implements Clustering
| Constructor and Description |
|---|
ColorClustering(ColorCluster[] clusters,
int k)
Builds a new clustering from a given set of clusters.
|
| Modifier and Type | Method and Description |
|---|---|
void |
drawMeans(processing.core.PApplet parent,
float x,
float y,
float w,
float h)
Draws the cluster means with horizontal striped within the given
rectangular area.
|
void |
drawMeans(processing.core.PGraphics g,
float x,
float y,
float w,
float h)
Draws the cluster means with horizontal striped within the given
rectangular area.
|
void |
drawMembers(processing.core.PApplet parent,
float x,
float y,
float w,
float h)
Draws the cluster members with horizontal striped within the given
rectangular area.
|
void |
drawMembers(processing.core.PGraphics g,
float x,
float y,
float w,
float h)
Draws the cluster members with horizontal striped within the given
rectangular area.
|
ColorCluster |
get(int index)
Returns the cluster with the given index.
|
ColorCluster |
getCluster(int c)
Returns the cluster which is the most similar to the given color.
|
ColorCluster |
getCluster(java.lang.Object c)
Returns the cluster which is the most similar to the given parameter.
|
ColorCluster |
getCluster(RColor c)
Returns the cluster which is the most similar to the given color.
|
int |
getClusterIndex(int c)
Returns the index of the cluster which is the most similar to the input
color.
|
int |
getClusterIndex(java.lang.Object c)
Returns the index of the cluster which is the most similar to the input
color.
|
int |
getClusterIndex(RColor c)
Returns the index of the cluster which is the most similar to the input
color.
|
ColorCluster[] |
getClusters()
Returns all clusters of this clustering.
|
ColorDifferenceMeasure |
getColorDifferenceMeasure()
Returns the ColorDifferenceMeasure which is used to calculate the most
similar cluster to a given color within the getCluster() and
getClusterIndex() methods.
|
int |
getK()
The number of clusters to this clustering. k might differ from the
getClusters().length, when empty clusters (clusters with no members) are
automatically removed.
|
java.lang.Float |
getLoss()
Returns the loss of the clustering (= mean loss of all clusters).
|
java.lang.Float |
getMaxLuminance()
Returns the maximal luminance of this clustering.
|
RColor[] |
getMeans()
Returns all cluster means.
|
RColor[] |
getMembers()
Returns a set of colors which contains all members of all clusters of
this clustering.
|
java.lang.Float |
getMinLuminance()
Returns the minimal luminance of this clustering.
|
int |
size()
The number of clusters for this clustering.
|
ColorPalette |
toColorPalette()
Builds a color palette from this clustering.
|
ColorPalette |
toColorPalette(boolean useMeans)
Builds a color palette from this clustering.
|
public ColorClustering(ColorCluster[] clusters, int k)
clusters - The clusters with set means and cluster members. All clusters
should uses the same ColorDifferenceMeasure.k - The number of clusters of this clustering. k might differ from
the clusters.length, when empty clusters (clusters with no
members) are automatically removed.public java.lang.Float getLoss()
ClusteringgetLoss in interface Clusteringpublic int getK()
ClusteringgetK in interface Clusteringpublic java.lang.Float getMinLuminance()
public java.lang.Float getMaxLuminance()
public ColorPalette toColorPalette()
public ColorPalette toColorPalette(boolean useMeans)
useMeans - A parameter which defines if the palette should consist of
cluster means or a representative.public RColor[] getMeans()
public RColor[] getMembers()
public int size()
for (int i = 0; i < myClustering.size(); i++) {
myClustering.get(i); // The cluster with index i
}
public ColorCluster get(int index)
for (int i = 0; i < myClustering.size(); i++) {
myClustering.get(i); // The cluster with index i
}
index - The index of the cluster.public int getClusterIndex(java.lang.Object c)
c - A color.public int getClusterIndex(int c)
c - A color (e.g 0xFFFF0000).public int getClusterIndex(RColor c)
c - A color object.public ColorCluster getCluster(java.lang.Object c)
ClusteringgetCluster in interface Clusteringc - An element.public ColorCluster getCluster(int c)
c - A color (e.g 0xFFFF0000).public ColorCluster getCluster(RColor c)
c - A color.public ColorDifferenceMeasure getColorDifferenceMeasure()
public ColorCluster[] getClusters()
ClusteringgetClusters in interface Clusteringpublic void drawMembers(processing.core.PGraphics g,
float x,
float y,
float w,
float h)
g - A recorder.x - The x-position (top left corner) of the rectangle.y - The y-position (top left corner) of the rectangle.w - The width of the rectangle.h - The height of the rectangle.public void drawMembers(processing.core.PApplet parent,
float x,
float y,
float w,
float h)
parent - A recorder.x - The x-position (top left corner) of the rectangle.y - The y-position (top left corner) of the rectangle.w - The width of the rectangle.h - The height of the rectangle.public void drawMeans(processing.core.PGraphics g,
float x,
float y,
float w,
float h)
g - A recorder or null.x - The x-position (top left corner) of the rectangle.y - The y-position (top left corner) of the rectangle.w - The width of the rectangle.h - The height of the rectangle.public void drawMeans(processing.core.PApplet parent,
float x,
float y,
float w,
float h)
parent - A recorder or null.x - The x-position (top left corner) of the rectangle.y - The y-position (top left corner) of the rectangle.w - The width of the rectangle.h - The height of the rectangle.