public class ColorClusteringBuilder extends java.lang.Object implements ImageUpdateObserver
| Constructor and Description |
|---|
ColorClusteringBuilder(processing.core.PApplet parent)
Builds a new ColorClusteringBuilder with minK=2, maxK=30 and RGBEuclidean
as ColorDifferenceMeasure.
|
ColorClusteringBuilder(processing.core.PApplet parent,
ColorDifferenceMeasure m)
Builds a new ColorClusteringBuilder with minK=2, maxK=30 and m as
ColorDifferenceMeasure.
|
| Modifier and Type | Method and Description |
|---|---|
void |
drawAllClusterings(float x,
float y,
float w,
float h)
Draws all clusterings from minK to maxK with all cluster mean colors and
all cluster members for each cluster within a rectangular area.
|
void |
drawAllClusterings(processing.core.PGraphics g,
float x,
float y,
float w,
float h)
Draws all clusterings from minK to maxK with all cluster mean colors and
all cluster members for each cluster within a rectangular area.
|
void |
drawAllClusteringsMeans(float x,
float y,
float w,
float h)
Draws all clusterings from minK to maxK with all cluster mean colors for
each clustering within a rectangular area.
|
void |
drawAllClusteringsMeans(processing.core.PGraphics g,
float x,
float y,
float w,
float h)
Draws all clusterings from minK to maxK with all cluster mean colors for
each clustering within a rectangular area.
|
void |
drawAllClusteringsMembers(float x,
float y,
float w,
float h)
Draws all members of all clusters of all clusterings from minK to maxK
(sorted by clustering and cluster) within a rectangular area.
|
void |
drawAllClusteringsMembers(processing.core.PGraphics g,
float x,
float y,
float w,
float h)
Draws all members of all clusters of all clusterings from minK to maxK
(sorted by clustering and cluster) within a rectangular area.
|
void |
drawClustering(float x,
float y,
float w,
float h,
int k)
Draws the clustering (all cluster mean colors) with vertical stripes for
the clustering with k clusters within a rectangular area.
|
void |
drawClustering(processing.core.PGraphics g,
float x,
float y,
float w,
float h,
int k)
Draws the clustering (all cluster mean colors) with vertical stripes for
the clustering with k clusters within a rectangular area.
|
void |
drawImage(float x,
float y,
float w,
float h)
Draws the input image centered in the given rectangular area.
|
void |
drawImage(processing.core.PGraphics g,
float x,
float y,
float w,
float h)
Draws the input image centered in the given rectangular area.
|
void |
drawImageWithClustering(float x,
float y,
float w,
float h,
int k)
Draws the input image with an overlay of the clustering with k
colors / clusters.
|
void |
drawImageWithClustering(processing.core.PGraphics g,
float x,
float y,
float w,
float h,
int k)
Draws the input image with an overlay of the clustering with k
colors / clusters.
|
void |
drawInputColors(float x,
float y,
float w,
float h) |
void |
drawInputColors(processing.core.PGraphics g,
float x,
float y,
float w,
float h) |
void |
drawLoss(float x,
float y,
float w,
float h)
Draws the the loss graph for minK to maxK within a rectangular area.
|
void |
drawLoss(float x,
float y,
float w,
float h,
int highlight)
Draws the the loss graph for minK to maxK within a rectangular area.
|
void |
drawLoss(processing.core.PGraphics g,
float x,
float y,
float w,
float h,
int highlight)
Draws the the loss graph for minK to maxK within a rectangular area.
|
void |
drawQuantizedImage(float x,
float y,
float w,
float h,
int k)
Draws the quantized image for the given k centered in the given
rectangular area.
|
void |
drawQuantizedImage(processing.core.PGraphics g,
float x,
float y,
float w,
float h,
int k)
Draws the quantized image for the given k centered in the given
rectangular area.
|
void |
export(int k,
java.lang.String fileName)
Exports the current clustering with k clusters with 6 sample
representations.
|
ColorClustering |
get(int index)
Returns the clustering with the given index (the index doesn't equal to k
- the number of clusters).
|
ColorClustering |
getClustering()
Returns the clustering with optimal number of clusters for the given
data.
|
ColorClustering |
getClustering(int k)
Returns the clustering with k number of clusters.
|
ColorDifferenceMeasure |
getColorDifferenceMeasure()
Returns the ColorDifferenceMeasure which defines the distance measure for
the clustering process.
|
RColor[] |
getColors()
Returns the source for the clusterings - the training colors.
|
processing.core.PImage |
getInputImg()
Returns the source for the clusterings (colors will be sampled from this
image) or null if no image is set.
|
int |
getMaxK()
Returns the maximal number of clusters for any clustering of this
builder.
|
int |
getMinK()
Returns the minimal number of clusters for any clustering of this
builder.
|
int |
getOptimalK()
Calculates the optimal k for the given input data (optimal number of
clusters that represent the input).
|
processing.core.PImage |
getQuantizedImage()
Creates a quantized image to the given inputImage image.
|
processing.core.PImage |
getQuantizedImage(int k)
Creates a quantized image to the given inputImage image.
|
processing.core.PImage |
getQuantizedImageFull()
Creates a quantized image to the given inputImg image (source of
clustering).
|
processing.core.PImage |
getQuantizedImageFull(int k)
Creates a quantized image to the given inputImg image (source of
clustering).
|
processing.core.PImage |
getQuantizedImagePreview()
Creates a quantized image to the given inputImg image (source of
clustering).
|
processing.core.PImage |
getQuantizedImagePreview(int k)
Creates a quantized image to the given inputImg image (source of
clustering).
|
void |
setColorDifferenceMeasure(ColorDifferenceMeasure m)
Sets a new ColorDifferenceMeasure.
|
void |
setColors(RColor[] inputColors)
Sets the source for the clusterings (colors will be sampled from this
colors).
|
void |
setImage(processing.core.PImage inputImg)
Sets the source for the clusterings (colors will be sampled from this
image).
|
ColorClusteringBuilder |
setMaxK(int k)
Sets the maximal number of clusters for any clustering of this builder.
|
ColorClusteringBuilder |
setTrainingSize(int trainingSize)
Sets the number of colors which will be used to learn the clusterings.
|
int |
size()
Returns the number of clusterings for this builder.
|
void |
update()
Creates new clusterings for the given range of k.
|
public ColorClusteringBuilder(processing.core.PApplet parent)
parent - The PApplet object.public ColorClusteringBuilder(processing.core.PApplet parent,
ColorDifferenceMeasure m)
parent - The PApplet object.public ColorClusteringBuilder setTrainingSize(int trainingSize)
trainingSize - The number of colors used for learning the clusterings.public ColorClusteringBuilder setMaxK(int k)
k - The maximal number of clusters.public int size()
for (int i = 0; i < myBuilder.size(); i++) {
ColorClustering clustering = myBuilder.get(i);
}
public ColorClustering get(int index)
for (int i = 0; i < myBuilder.size(); i++) {
ColorClustering clustering = myBuilder.get(i);
}
index - The index of the clustering [0, size()).public ColorClustering getClustering()
public ColorClustering getClustering(int k)
for (int k = myBuilder.getMinK(); k <= myBuilder.getMaxK(); k++) {
myBuilder.getClustering(k);
}
k - The number of clusters which maps to the desired clustering.public ColorDifferenceMeasure getColorDifferenceMeasure()
public processing.core.PImage getInputImg()
public RColor[] getColors()
public int getMaxK()
public int getMinK()
public int getOptimalK()
public void setImage(processing.core.PImage inputImg)
setImage in interface ImageUpdateObserverinputImg - The source for the clusterings.public void setColors(RColor[] inputColors)
inputColors - The source for the clusterings.public processing.core.PImage getQuantizedImage()
k - The number of clusters / colors which will be used to build
the quantized image. Make sure is within range of [minK,
maxK].public processing.core.PImage getQuantizedImage(int k)
k - The number of clusters / colors which will be used to build
the quantized image. Make sure is within range of [minK,
maxK].public processing.core.PImage getQuantizedImageFull()
public processing.core.PImage getQuantizedImageFull(int k)
k - The number of clusters / colors which will be used to build
the quantized image. Make sure is within range of [minK,
maxK].public processing.core.PImage getQuantizedImagePreview()
public processing.core.PImage getQuantizedImagePreview(int k)
k - The number of clusters / colors which will be used to build
the quantized image. Make sure is within range of [minK,
maxK].public void update()
public void setColorDifferenceMeasure(ColorDifferenceMeasure m)
m - The new ColorDifferenceMeasure.public void export(int k,
java.lang.String fileName)
k - The number of clusters / colors which will be used to build
the quantized image. Make sure is within range of [minK,
maxK].fileName - The (base) name of the images which will be exported.public void drawQuantizedImage(float x,
float y,
float w,
float h,
int k)
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.k - The number of clusters / colors which will be used to build
the quantized image. Make sure is within range of [minK,
maxK].public void drawQuantizedImage(processing.core.PGraphics g,
float x,
float y,
float w,
float h,
int k)
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.k - The number of clusters / colors which will be used to build
the quantized image. Make sure is within range of [minK,
maxK].public void drawImage(float x,
float y,
float w,
float h)
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 drawImage(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 drawLoss(float x,
float y,
float w,
float h)
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 drawLoss(float x,
float y,
float w,
float h,
int highlight)
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.highlight - The k which defines which loss will be highlighted.
highlight should be in range of [minK, maxK] or out of
range if no loss should be highlighted.public void drawLoss(processing.core.PGraphics g,
float x,
float y,
float w,
float h,
int highlight)
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.highlight - The k which defines which loss will be highlighted.
highlight should be in range of [minK, maxK] or out of
range if no loss should be highlighted.public void drawClustering(float x,
float y,
float w,
float h,
int k)
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.k - The number of clusters / colors which defines which clustering
will be drawn. Make sure is within range of [minK, maxK].public void drawClustering(processing.core.PGraphics g,
float x,
float y,
float w,
float h,
int k)
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.k - The number of clusters / colors which defines which clustering
will be drawn. Make sure is within range of [minK, maxK].public void drawImageWithClustering(float x,
float y,
float w,
float h,
int k)
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.k - The number of clusters / colors which defines which clustering
will be drawn. Make sure is within range of [minK, maxK].public void drawImageWithClustering(processing.core.PGraphics g,
float x,
float y,
float w,
float h,
int k)
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.k - The number of clusters / colors which defines which clustering
will be drawn. Make sure is within range of [minK, maxK].public void drawAllClusteringsMeans(float x,
float y,
float w,
float h)
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 drawAllClusteringsMeans(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 drawAllClusterings(float x,
float y,
float w,
float h)
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 drawAllClusterings(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 drawAllClusteringsMembers(float x,
float y,
float w,
float h)
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 drawAllClusteringsMembers(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 drawInputColors(float x,
float y,
float w,
float h)
x - y - w - h - public void drawInputColors(processing.core.PGraphics g,
float x,
float y,
float w,
float h)
g - x - y - w - h -