org.plant.kzpif.filters.dithering
Class Stucki

java.lang.Object
  extended by org.plant.kzpif.basic.AbstractFilter
      extended by org.plant.kzpif.filters.dithering.Stucki

public class Stucki
extends AbstractFilter

The Stucki class implements Stucki dithering algorithm.

Dithering is a technique used in computer graphics to create the illusion of color depth in images with a limited color palette (color quantization). In a dithered image, colors not available in the palette are approximated by a diffusion of colored pixels from within the available palette. The human eye perceives the diffusion as a mixture of the colors within it (see color vision). Dithering is analogous to the halftone technique used in printing. Dithered images, particularly those with relatively few colors, can often be distinguished by a characteristic graininess, or speckled appearance.

Stucki filter is an error diffusion filter.

Error diffusion is very simple to describe. For each point in our image, we first find the closest intensity (or color) available. We then calculate the difference between the image value at that point and that nearest available intensity/color: this difference is our error value. Now we divide up the error value and distribute it to some of the neighboring image areas which we have not visited (or processed) yet. When we get to these later dots, we add in the portions of error values which were distributed there from the preceding dots, and clip the cumulative value to an allowed range if needed. This new, modified value now becomes the image value that we use for processing this point.

P. Stucki offered a rework of the Jarvis, Judice, and Ninke filter in 1981:

            *   8   4
    2   4   8   4   2
    1   2   4   2   1   (1/42)
 

Once again, division by 42 is quite slow to calculate (requiring DIVs). However, after the initial 8/42 is calculated, some time can be saved by producing the remaining fractions by shifts. The Stucki filter has been observed to give very clean, sharp output, which helps to offset the slow processing time.

Since:
JDK1.5
Version:
0.002, 29/06/07
Author:
Andrzej Jóźwiak, Stanisław Walczak, Konrad Jojczyk
See Also:
FloydSteinberg, JarvisJudiceNinke, Burkes, Sierra2, Sierra24A, Sierra3, FalseFloydSteinberg, OrderedDithering, MedianDithering, MeanDithering

Field Summary
protected  float[] errors
          The errors table stores computed error values for halftoned image pixels.
protected  int shades
          The shades stores number of desired shades in halftoned image.
 
Fields inherited from class org.plant.kzpif.basic.AbstractFilter
normalization
 
Constructor Summary
Stucki()
           
 
Method Summary
 javax.media.jai.TiledImage applyFilter(javax.media.jai.TiledImage src, javax.media.jai.TiledImage dest)
          Applies Stucki dithering to a given image.
 int getShades()
          This method returns number of shades generated by Stucki algorithm in image dithering process.
 void setShades(int shades)
          This method sets number of shades generated by Stucki algorithm in image dithering process.
 
Methods inherited from class org.plant.kzpif.basic.AbstractFilter
applyFilter, getNormalization, setNormalization
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shades

protected int shades
The shades stores number of desired shades in halftoned image.


errors

protected float[] errors
The errors table stores computed error values for halftoned image pixels.

Constructor Detail

Stucki

public Stucki()
Method Detail

applyFilter

public javax.media.jai.TiledImage applyFilter(javax.media.jai.TiledImage src,
                                              javax.media.jai.TiledImage dest)
Applies Stucki dithering to a given image. Source and destination images are TiledImage objects.

Specified by:
applyFilter in class AbstractFilter
Parameters:
src - The source image that the filter will be apllied to.
dest - The destination image that is result of appling filter.
Returns:
The resulting TiledImage

getShades

public int getShades()
This method returns number of shades generated by Stucki algorithm in image dithering process. Default returned value is 2.

Returns:
Number of shades.

setShades

public void setShades(int shades)
This method sets number of shades generated by Stucki algorithm in image dithering process.

Parameters:
shades - New number of shades.