| javax.media.jai.UntiledOpImage ca.forklabs.media.jai.opimage.KMeansOpImage
KMeansOpImage | public class KMeansOpImage extends UntiledOpImage (Code) | | Class
KMeansOpImage is the
OpImage for operator
kmeans.
author: Daniel Léonard version: $Revision: 1.2 $ |
Method Summary | |
protected double[] | calculateSquareDistances(double[] pixel, double[][] centers, double[] distances) Calculate the square of the distance of the pixel from each center pixel.
Parameters: pixel - the pixel. Parameters: centers - the center pixels. Parameters: distances - the arrays to store the square distances. | protected void | computeImage(Raster[] sources, WritableRaster sink, Rectangle bounds) Computes the k-means image. | protected int | findClosestCenter(double[] distances) Gets the position of the smallest distance.
Parameters: distances - the distances. | protected int | getClusters() Gets the desired number of clusters. | protected int[][] | getColorMap() Gets the color map. | protected KMeansDescriptor.EvaluationFunction | getEvaluationFunction() Gets the evaluation function. | protected int | getIterations() Gets the desired number of iterations. | protected String | getUnknownDataTypeErrorMessage(int type) Gets the error message telling that the raster data type is unknown.
Parameters: type - the bad type. | protected double[][] | initializeCenters(Raster source, Rectangle bounds, KMeansDescriptor.EvaluationFunction function) Initialize the new centers. | protected void | resetNewCenters(double[][] positions, double[] population) Resets the new center data structures. | protected void | setClusters(int clusters) Changes the number of clusters. | protected void | setColorMap(int[][] color_map) Changes the color map. | protected void | setEvaluationFunction(KMeansDescriptor.EvaluationFunction function) Changes the evaluation function. | protected void | setIterations(int iterations) Changes the number of iterations. | protected void | setup(int clusters, KMeansDescriptor.EvaluationFunction function, int iterations, int[][] color_map) Sets up this image. | protected void | sortCenters(double[][] centers) Performs a stable in-place sort of the center from smallest to greatest. |
clusters | protected int clusters(Code) | | The number of clusters to make.
|
color_map | protected int[][] color_map(Code) | | The color map of the segmented image.
|
iterations | protected int iterations(Code) | | The number of iteration to perform.
|
KMeansOpImage | public KMeansOpImage(RenderedImage source, int clusters, KMeansDescriptor.EvaluationFunction function, int iterations, int[][] color_map, Map, ?> hints, ImageLayout layout)(Code) | | Constructor.
Parameters: source - the image to segment. Parameters: clusters - the number of desired clusters. Parameters: function - the evaluation function. Parameters: iterations - the maximum number of iterations. Parameters: color_map - the color_map of the segmented image. Parameters: hints - rendering hints. Parameters: layout - image layout. |
calculateSquareDistances | protected double[] calculateSquareDistances(double[] pixel, double[][] centers, double[] distances)(Code) | | Calculate the square of the distance of the pixel from each center pixel.
Parameters: pixel - the pixel. Parameters: centers - the center pixels. Parameters: distances - the arrays to store the square distances. distances . |
computeImage | protected void computeImage(Raster[] sources, WritableRaster sink, Rectangle bounds)(Code) | | Computes the k-means image.
Parameters: sources - the source rasters. Parameters: sink - the sink raster. Parameters: the - bounds to work within. |
findClosestCenter | protected int findClosestCenter(double[] distances)(Code) | | Gets the position of the smallest distance.
Parameters: distances - the distances. the position. |
getClusters | protected int getClusters()(Code) | | Gets the desired number of clusters.
the number of clusters. |
getColorMap | protected int[][] getColorMap()(Code) | | Gets the color map.
the color map. |
getIterations | protected int getIterations()(Code) | | Gets the desired number of iterations.
the number of iterations. |
getUnknownDataTypeErrorMessage | protected String getUnknownDataTypeErrorMessage(int type)(Code) | | Gets the error message telling that the raster data type is unknown.
Parameters: type - the bad type. the formatted error message. |
initializeCenters | protected double[][] initializeCenters(Raster source, Rectangle bounds, KMeansDescriptor.EvaluationFunction function)(Code) | | Initialize the new centers. It tries to have different values for centers,
but is not always capable of doing so, especially if there are less
segments than clusters.
Parameters: source - the source. Parameters: bounds - the source boundaries. Parameters: function - the evaluation function. the initial centers. |
resetNewCenters | protected void resetNewCenters(double[][] positions, double[] population)(Code) | | Resets the new center data structures.
Parameters: positions - the position of the new centers. Parameters: population - the population of each new center. |
setClusters | protected void setClusters(int clusters)(Code) | | Changes the number of clusters.
Parameters: clusters - the new number of clusters. |
setColorMap | protected void setColorMap(int[][] color_map)(Code) | | Changes the color map.
Parameters: color_map - the new color map. |
setIterations | protected void setIterations(int iterations)(Code) | | Changes the number of iterations.
Parameters: iterations - the new number of iterations. |
setup | protected void setup(int clusters, KMeansDescriptor.EvaluationFunction function, int iterations, int[][] color_map)(Code) | | Sets up this image.
Parameters: clusters - the number of desired clusters. Parameters: function - the evaluation function. Parameters: iterations - the number of desired iterations. Parameters: color_map - the color map. |
sortCenters | protected void sortCenters(double[][] centers)(Code) | | Performs a stable in-place sort of the center from smallest to greatest. A
center is smaller if its square distance from the origin is smaller then
another square distance.
Parameters: centers - the center to sort. |
|
|