Class IndexImage.Cube
java.lang.Object
org.apache.batik.ext.awt.image.rendered.IndexImage.Cube
- Enclosing class:
IndexImage
Used to define a cube of the colorspace. The cube can be split
approximagely in half to generate two cubes.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int
(package private) final IndexImage.Counter[][]
the colors-array is not modified - in fact, all cubes use the same colors-array.(package private) int
the number of color-points in this cube.(package private) boolean
(package private) static final int
(package private) int[]
(package private) int[]
(package private) static final int
(package private) static final byte[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the average color for this cube (no alpha).byte[]
averageColorRGB
(byte[] rgb) Returns the average color for this cubeprivate int[]
computeCounts
(int splitChannel, int c0, int c1) create an array, which contains the number of pixels for each point along the splitChannel (between min and max of this cube).private boolean
contains
(int[] val) check, if the color defined by val[] is inside this cube.boolean
isDone()
If this returns true then the cube can not be subdivided any furtherprivate void
normalize
(int splitChannel, int[] counts) Adjust (normalize) min/max of this cube so that they span the actual content.(package private) IndexImage.Cube
split()
Splits the cube into two parts.(package private) IndexImage.Cube
splitChannel
(int splitChannel, int c0, int c1) Splits the image according to the parameters.toString()
convert the cube-content to String-representation for logging.
-
Field Details
-
RGB_BLACK
static final byte[] RGB_BLACK -
min
int[] min -
max
int[] max -
done
boolean done -
colors
the colors-array is not modified - in fact, all cubes use the same colors-array. The Counter contains the rgb-color-code and the count of pixels with this color. -
count
int countthe number of color-points in this cube. -
RED
static final int RED- See Also:
-
GRN
static final int GRN- See Also:
-
BLU
static final int BLU- See Also:
-
-
Constructor Details
-
Cube
Cube(IndexImage.Counter[][] colors, int count) Define a new cube.- Parameters:
colors
- contains the 3D color histogram to be subdividedcount
- the total number of pixels in the 3D histogram.
-
-
Method Details
-
isDone
public boolean isDone()If this returns true then the cube can not be subdivided any further -
contains
private boolean contains(int[] val) check, if the color defined by val[] is inside this cube.- Parameters:
val
- int[ 3 ] containing r,g,b-values- Returns:
- true when color is inside this cube
-
split
IndexImage.Cube split()Splits the cube into two parts. This cube is changed to be one half and the returned cube is the other half. This tries to pick the right channel to split on. -
normalize
private void normalize(int splitChannel, int[] counts) Adjust (normalize) min/max of this cube so that they span the actual content. This method is called on the two cubes resulting from a split.
We search the counts[] from min to max for the leftmost non-null entry. That is the new min. Then we search counts[] from max to min for the rightmost non-null entry. That is the new max.
This requires, thatcomputeCounts(int, int, int)
really computes all counts-values (and does not stop after the necessary number of points for a split is found, as it was done in the previous version of this class).- Parameters:
splitChannel
- the color used for the last splitcounts
- contains the number of points along the splitChannel - only counts[ min .. max ] is valid.
-
splitChannel
Splits the image according to the parameters. It tries to find a location where half the pixels are on one side and half the pixels are on the other. -
computeCounts
private int[] computeCounts(int splitChannel, int c0, int c1) create an array, which contains the number of pixels for each point along the splitChannel (between min and max of this cube).- Parameters:
splitChannel
- one of RED | GRN | BLUc0
- one of the other channelsc1
- the third channel- Returns:
- an int[ 255 ] where only int[ min .. max ] contain valid counts.
-
toString
convert the cube-content to String-representation for logging. -
averageColor
public int averageColor()Returns the average color for this cube (no alpha). -
averageColorRGB
public byte[] averageColorRGB(byte[] rgb) Returns the average color for this cube
-