JIU 0.12.0 Homepage

net.sourceforge.jiu.color.quantization
Class OctreeNode

java.lang.Object
  extended bynet.sourceforge.jiu.color.quantization.OctreeNode
All Implemented Interfaces:
ComparatorInterface, RGBIndex

public class OctreeNode
extends Object
implements ComparatorInterface, RGBIndex

A single node in an octree.

Since:
0.6.0
Author:
Marco Schmidt
See Also:
OctreeColorQuantizer

Field Summary
 
Fields inherited from interface net.sourceforge.jiu.data.RGBIndex
INDEX_BLUE, INDEX_GREEN, INDEX_RED
 
Constructor Summary
OctreeNode()
           
 
Method Summary
static boolean add(OctreeNode root, int red, int green, int blue, int bitsPerSample)
          Add a color red-green-blue to the octree, given by its root node.
 int compare(Object o1, Object o2)
          Compares the two argument objects and returns their relation.
 void copyChildSums()
          Adds the sums for red, green and blue values and the pixel count values of all child nodes and stores the results in this node.
 void determineRepresentativeColor()
           
 int getBlue()
           
 OctreeNode[] getChildren()
           
 int getGreen()
           
 int getNumChildren()
           
 int getPaletteIndex()
           
 int getRed()
           
 boolean isLeaf()
           
 int map(int[] origRgb, int[] quantizedRgb)
          Returns the index of the best match for origRgb in the palette or -1 if the best match could not be determined.
 void setChildren(OctreeNode[] newChildren)
           
 void setPaletteIndex(int index)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OctreeNode

public OctreeNode()
Method Detail

add

public static boolean add(OctreeNode root,
                          int red,
                          int green,
                          int blue,
                          int bitsPerSample)
Add a color red-green-blue to the octree, given by its root node. This methods follows the octree down to the bitsPerSample'th level, creating nodes as necessary. Increases the pixelCount of a leaf node (if the node already exists) or initializes a newly-created leaf.

Parameters:
root - root node of the octree
red - the red intensity value of the color to be added
green - the green intensity value of the color to be added
blue - the blue intensity value of the color to be added
bitsPerSample -

compare

public int compare(Object o1,
                   Object o2)
Description copied from interface: ComparatorInterface
Compares the two argument objects and returns their relation. Returns

Specified by:
compare in interface ComparatorInterface

copyChildSums

public void copyChildSums()
Adds the sums for red, green and blue values and the pixel count values of all child nodes and stores the results in this node. Does nothing if this is a leaf. Otherwise, recursively calls itself with all non-null child nodes and adds their sums for red, green and blue and the number of pixel values. Then stores these values in this node. They will be used when the octree is pruned to have a certain number of leaves.


determineRepresentativeColor

public void determineRepresentativeColor()

getBlue

public int getBlue()

getChildren

public OctreeNode[] getChildren()

getGreen

public int getGreen()

getNumChildren

public int getNumChildren()

getPaletteIndex

public int getPaletteIndex()

getRed

public int getRed()

isLeaf

public boolean isLeaf()

map

public int map(int[] origRgb,
               int[] quantizedRgb)
Returns the index of the best match for origRgb in the palette or -1 if the best match could not be determined. If there was a best match, quantizedRgb is filled with the quantized color's RGB values.


setChildren

public void setChildren(OctreeNode[] newChildren)

setPaletteIndex

public void setPaletteIndex(int index)

JIU 0.12.0 Homepage

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