com.jhlabs.image
Class OctTreeQuantizer
java.lang.Objectcom.jhlabs.image.OctTreeQuantizer
- Quantizer
public class OctTreeQuantizer
extends java.lang.Object
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.
void | addPixels(int[] pixels, int offset, int count)- Add pixels to the quantizer.
|
int[] | buildColorTable()- Build the color table.
|
void | buildColorTable(int[] inPixels, int[] table)- A quick way to use the quantizer.
|
int | getIndexForColor(int rgb)- Get the color table index for a color.
|
void | setup(int numColors)- Initialize the quantizer.
|
OctTreeQuantizer
public OctTreeQuantizer()
addPixels
public void addPixels(int[] pixels,
int offset,
int count) Add pixels to the quantizer.
- addPixels in interface Quantizer
pixels - the array of ARGB pixelsoffset - the offset into the arraycount - the count of pixels
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.
inPixels - the input colorstable - the output color table
getIndexForColor
public int getIndexForColor(int rgb)
Get the color table index for a color.
- getIndexForColor in interface Quantizer
setup
public void setup(int numColors)
Initialize the quantizer. This should be called before adding any pixels.
- setup in interface Quantizer
numColors - the number of colors we're quantizing to.