An instance of this node class represents a cuboid part
of the color cube representing the three-dimensional RGB color space.
canBeSplit
public boolean canBeSplit()
Returns if this node can be split into two.
This is true if and only if this is a leaf and if the color
list index values represent an interval of at least length 2.
- if this node can be split into two nodes
computeRgbDistance
public double computeRgbDistance(MedianCutNode node)
Computes the distance in RGB color space between the representative color of this node and the
argument node and returns it as non-negative value.
determineMiddleIndex
private void determineMiddleIndex()
Computes the middle index value of this node.
It uses the index values given to this node's constructor, index1 and index2.
getAxisOfLargestDistribution
public int getAxisOfLargestDistribution()
Returns the axis of the channel whose samples are most widely
distributed among the colors that belong to this node.
- index of axis, one of the
RGBIndex
constants
getDifferenceOfLargestDistribution
public int getDifferenceOfLargestDistribution()
getLeftIndex
public int getLeftIndex()
getLeftSuccessor
public MedianCutNode getLeftSuccessor()
Returns left successor node (or null if this node is a leaf).
getMaxColorSample
public int getMaxColorSample(int index)
getMedianValue
public int getMedianValue()
getMiddleIndex
public int getMiddleIndex()
getMinColorSample
public int getMinColorSample(int index)
getNumColors
public int getNumColors()
getPaletteIndex
public int getPaletteIndex()
getParentNode
public MedianCutNode getParentNode()
Returns parent node (or null if this node is the root node).
getRepresentativeColor
public int[] getRepresentativeColor()
getRightIndex
public int getRightIndex()
getRightSuccessor
public MedianCutNode getRightSuccessor()
Returns right successor node (or null if this node is a leaf).
isAxisDetermined
public boolean isAxisDetermined()
isLeaf
public boolean isLeaf()
Returns if this node is a leaf by checking if both successors are null.
Note that the case of one successor being null and the other non-null
should never happen.
- if this node is a leaf (true)
setLargestDistribution
public void setLargestDistribution(int newAxis,
int newDifference)
setMaxColor
public void setMaxColor(int red,
int green,
int blue)
setMaxColorSample
public void setMaxColorSample(int index,
int value)
setMedianValue
public void setMedianValue(int newMedianValue)
setMinColor
public void setMinColor(int red,
int green,
int blue)
setMinColorSample
public void setMinColorSample(int index,
int value)
setPaletteIndex
public void setPaletteIndex(int newPaletteIndex)
setRepresentativeColor
public void setRepresentativeColor(int[] aRepresentativeColor)
setSuccessors
public void setSuccessors(MedianCutNode left,
MedianCutNode right)
Sets the successor nodes for this node.
The successors must be either both null or both initialized.
They must not be equal.
left
- the left successor noderight
- the left successor node