Packagede.popforge.imageprocessing.filters.binarization
Classpublic final class Threshold
ImplementsIFilter

The Threshold class transforms a grayscale image into binary color-space using a threshold value.

The filter checks each pixel if it is greater or equal to the threshold value. If this condition is true then the resulting pixel is set to 1 otherwise to 0. This filter is working with a look-up table and can be overriden by another threshold filter that uses a different technique to create the look-up table.

The formula of this filter is new = ( old > threshold ) ? 1 : 0.

Supported formats:
This is a conversion filter so there are no supported formats.


Example
  
  // Set the conversion filter to Threshold
  Image.threshold = new Threshold();
  
  var video: WebCam = new WebCam( 160, 120 );
  var image: Image = new Image( 160, 120, ImageFormat.BINARY );
  
  image.loadBitmapData( video.getCurrentFrame(), true );
  



Public Methods
 MethodDefined by
  
Threshold(thresholdValue:int = 0x80)
Creates a new Threshold object with given threshold value.
Threshold
  
apply(image:Image):void
Applies the filter to the given Image object.
Threshold
  
toString():String
Builds and returns a string containing the name of the class.
Threshold
Protected Methods
 MethodDefined by
  
updateTable():void
Creates the look-up table.
Threshold
Constructor detail
Threshold()constructor
public function Threshold(thresholdValue:int = 0x80)

Creates a new Threshold object with given threshold value.

Parameters
thresholdValue:int (default = 0x80) — The threshold value (0 to 0xff).
Method detail
apply()method
public function apply(image:Image):void

Applies the filter to the given Image object.

Parameters
image:Image — The image that will be manipulated.
toString()method 
public function toString():String

Builds and returns a string containing the name of the class.

Returns
String — A string containing the name of the class.
updateTable()method 
protected function updateTable():void

Creates the look-up table. Can be overridden by another filter using a look-up table. If you want to create a general look-up table based filter you should check de.popforge.imageprocessing.filters.color.LUTFilter.

See also