All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.jhlabs.image.QuantizeFilter

java.lang.Object
   |
   +----java.awt.image.ImageFilter
           |
           +----com.jhlabs.image.WholeImageFilter
                   |
                   +----com.jhlabs.image.QuantizeFilter

public class QuantizeFilter
extends com.jhlabs.image.WholeImageFilter
implements java.io.Serializable
A filter which quantizes an image to a set number of colors - useful for producing images which are to be encoded using an index color model. The filter can perform Floyd-Steinberg error-diffusion dithering if required. At present, the quantization is done using an octtree algorithm but I eventually hope to add more quantization methods such as median cut. Note: at present, the filter produces an image which uses the RGB color model (because the application it was written for required it). I hope to extend it to produce an IndexColorModel by request.


Variable Index

 o matrix
Floyd-Steinberg ditherin gmatrix.

Constructor Index

 o QuantizeFilter()

Method Index

 o getDither()
Return the dithering setting
 o getNumColors()
Get the number of colors to quantize to.
 o getSerpentine()
Return the serpentine setting
 o imageComplete(int)
 o quantize(int[], int[], int, int, int, boolean, boolean)
 o setDither(boolean)
Set whether to use dithering or not.
 o setNumColors(int)
Set the number of colors to quantize to.
 o setSerpentine(boolean)
Set whether to use a serpentine pattern for return or not.
 o toString()

Variables

 o matrix
 protected static final int matrix[]
Floyd-Steinberg ditherin gmatrix.

Constructors

 o QuantizeFilter
 public QuantizeFilter()

Methods

 o setNumColors
 public void setNumColors(int numColors)
Set the number of colors to quantize to.

Parameters:
numColors - the number of colors. The default is 256.
 o getNumColors
 public int getNumColors()
Get the number of colors to quantize to.

Returns:
the number of colors.
 o setDither
 public void setDither(boolean dither)
Set whether to use dithering or not. If not, the image is posterized.

Parameters:
dither - true to use dithering
 o getDither
 public boolean getDither()
Return the dithering setting

Returns:
the current setting
 o setSerpentine
 public void setSerpentine(boolean serpentine)
Set whether to use a serpentine pattern for return or not. This can reduce 'avalanche' artifacts in the output.

Parameters:
serpentine - true to use serpentine pattern
 o getSerpentine
 public boolean getSerpentine()
Return the serpentine setting

Returns:
the current setting
 o quantize
 public void quantize(int inPixels[],
                      int outPixels[],
                      int width,
                      int height,
                      int numColors,
                      boolean dither,
                      boolean serpentine)
 o imageComplete
 public void imageComplete(int status)
Overrides:
imageComplete in class java.awt.image.ImageFilter
 o toString
 public java.lang.String toString()
Overrides:
toString in class java.lang.Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index