Class IndexImage.Cube
- java.lang.Object
-
- org.apache.batik.ext.awt.image.rendered.IndexImage.Cube
-
- Enclosing class:
- IndexImage
private static class IndexImage.Cube extends java.lang.Object
Used to define a cube of the colorspace. The cube can be split approximagely in half to generate two cubes.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
BLU
(package private) IndexImage.Counter[][]
colors
the colors-array is not modified - in fact, all cubes use the same colors-array.(package private) int
count
the number of color-points in this cube.(package private) boolean
done
(package private) static int
GRN
(package private) int[]
max
(package private) int[]
min
(package private) static int
RED
(package private) static byte[]
RGB_BLACK
-
Constructor Summary
Constructors Constructor Description Cube(IndexImage.Counter[][] colors, int count)
Define a new cube.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
averageColor()
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.java.lang.String
toString()
convert the cube-content to String-representation for logging.
-
-
-
Field Detail
-
RGB_BLACK
static final byte[] RGB_BLACK
-
min
int[] min
-
max
int[] max
-
done
boolean done
-
colors
final IndexImage.Counter[][] 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 count
the number of color-points in this cube.
-
RED
static final int RED
- See Also:
- Constant Field Values
-
GRN
static final int GRN
- See Also:
- Constant Field Values
-
BLU
static final int BLU
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
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
IndexImage.Cube splitChannel(int splitChannel, int c0, int c1)
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
public java.lang.String toString()
convert the cube-content to String-representation for logging.- Overrides:
toString
in classjava.lang.Object
- Returns:
- the min/max-boundarys of the rgb-channels and pixel-count of this Cube.
-
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
-
-