org.jscience.media.pictures.filters
Class OctTreeQuantizer

java.lang.Object
  extended by org.jscience.media.pictures.filters.OctTreeQuantizer
All Implemented Interfaces:
Quantizer

public class OctTreeQuantizer
extends java.lang.Object
implements Quantizer

An image Quantizer based on the Octree algorithm. This is a very basic implementation at present and could be much improved by picking the nodes to reduce more carefully (i.e. not completely at random) when I get the time.


Constructor Summary
OctTreeQuantizer()
          Creates a new OctTreeQuantizer object.
 
Method Summary
 void addPixels(int[] pixels, int offset, int count)
          Add pixels to the quantizer.
 int[] buildColorTable()
          DOCUMENT ME!
 void buildColorTable(int[] inPixels, int[] table)
          A quick way to use the quantizer.
 int getIndexForColor(int rgb)
          DOCUMENT ME!
 void setup(int numColors)
          Initialize the quantizer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OctTreeQuantizer

public OctTreeQuantizer()
Creates a new OctTreeQuantizer object.

Method Detail

setup

public void setup(int numColors)
Initialize the quantizer. This should be called before adding any pixels.

Specified by:
setup in interface Quantizer
Parameters:
numColors - the number of colors we're quantizing to.

addPixels

public void addPixels(int[] pixels,
                      int offset,
                      int count)
Add pixels to the quantizer.

Specified by:
addPixels in interface Quantizer
Parameters:
pixels - the array of ARGB pixels
offset - the offset into the array
count - the count of pixels

getIndexForColor

public int getIndexForColor(int rgb)
DOCUMENT ME!

Specified by:
getIndexForColor in interface Quantizer
Parameters:
rgb - DOCUMENT ME!
Returns:
DOCUMENT ME!

buildColorTable

public int[] buildColorTable()
DOCUMENT ME!

Specified by:
buildColorTable in interface Quantizer
Returns:
DOCUMENT ME!

buildColorTable

public void buildColorTable(int[] inPixels,
                            int[] table)
A quick way to use the quantizer. Just create a table the right size and pass in the pixels.

Parameters:
inPixels - DOCUMENT ME!
table - DOCUMENT ME!