JIU 0.12.0 Homepage

net.sourceforge.jiu.color.quantization
Class MedianCutNode

java.lang.Object
  extended bynet.sourceforge.jiu.color.quantization.MedianCutNode
All Implemented Interfaces:
RGBIndex

public class MedianCutNode
extends Object
implements RGBIndex

An instance of this node class represents a cuboid part of the color cube representing the three-dimensional RGB color space.

Author:
Marco Schmidt
See Also:
MedianCutQuantizer

Field Summary
 
Fields inherited from interface net.sourceforge.jiu.data.RGBIndex
INDEX_BLUE, INDEX_GREEN, INDEX_RED
 
Constructor Summary
MedianCutNode(MedianCutNode parent, int index1, int index2)
          Creates a node for a Median Cut tree of nodes with index values for some external color array and the parent node.
 
Method Summary
 boolean canBeSplit()
          Returns if this node can be split into two.
 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.
 int getAxisOfLargestDistribution()
          Returns the axis of the channel whose samples are most widely distributed among the colors that belong to this node.
 int getDifferenceOfLargestDistribution()
           
 int getLeftIndex()
           
 MedianCutNode getLeftSuccessor()
          Returns left successor node (or null if this node is a leaf).
 int getMaxColorSample(int index)
           
 int getMedianValue()
           
 int getMiddleIndex()
           
 int getMinColorSample(int index)
           
 int getNumColors()
           
 int getPaletteIndex()
           
 MedianCutNode getParentNode()
          Returns parent node (or null if this node is the root node).
 int[] getRepresentativeColor()
           
 int getRightIndex()
           
 MedianCutNode getRightSuccessor()
          Returns right successor node (or null if this node is a leaf).
 MedianCutNode getSuccessor(int[] rgb)
           
 boolean isAxisDetermined()
           
 boolean isLeaf()
          Returns if this node is a leaf by checking if both successors are null.
 void setLargestDistribution(int newAxis, int newDifference)
           
 void setMaxColor(int red, int green, int blue)
           
 void setMaxColorSample(int index, int value)
           
 void setMedianValue(int newMedianValue)
           
 void setMinColor(int red, int green, int blue)
           
 void setMinColorSample(int index, int value)
           
 void setPaletteIndex(int newPaletteIndex)
           
 void setRepresentativeColor(int[] aRepresentativeColor)
           
 void setSuccessors(MedianCutNode left, MedianCutNode right)
          Sets the successor nodes for this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MedianCutNode

public MedianCutNode(MedianCutNode parent,
                     int index1,
                     int index2)
Creates a node for a Median Cut tree of nodes with index values for some external color array and the parent node. This parent is null for the root node.

Parameters:
parent - the parent node of this new node, should be null only for the root node
index1 - the index value of the first element of colors in the color list
index2 - the index value of the last element of colors in the color list; must be larger than or equal to index1
Throws:
IllegalArgumentException - if index1 is larger than index2
Method Detail

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.

Returns:
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.


getAxisOfLargestDistribution

public int getAxisOfLargestDistribution()
Returns the axis of the channel whose samples are most widely distributed among the colors that belong to this node.

Returns:
index of axis, one of the RGBIndex constants
Throws:
IllegalArgumentException - if that axis has not been determined

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).


getSuccessor

public MedianCutNode getSuccessor(int[] rgb)

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.

Returns:
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.

Parameters:
left - the left successor node
right - the left successor node

JIU 0.12.0 Homepage

Copyright © 2000, 2001, 2002, 2003, 2004 Marco Schmidt