Package net.sourceforge.jiu.color.reduction

# Class ReduceToBilevelThreshold

java.lang.Object
net.sourceforge.jiu.ops.Operation
net.sourceforge.jiu.ops.ImageToImageOperation
net.sourceforge.jiu.color.reduction.ReduceToBilevelThreshold

public class ReduceToBilevelThreshold extends ImageToImageOperation
Reduces a `GrayIntegerImage` to a `BilevelImage` by setting all values below a certain threshold value to black and everything else to white.

### Default value

If no threshold is specified via `setThreshold(int)`, this operation uses a default value of (`IntegerImage.getMaxSample(int)` + 1) / 2.

### Usage example

This example sets all values below 33 percent luminance to black, everything else to white.

     GrayIntegerImage image = ...;
     ReduceToBilevelThreshold red = new ReduceToBilevelThreshold();
     red.setInputImage(image);
     red.setThreshold(image.getMaxSample(0) / 3);
     red.process();
     BilevelImage reducedImage= (BilevelImage)red.getOutputImage();

Author:
  Marco Schmidt

## Field Summary

Fields
Modifier and Type
Field
Description
`private Integer`
`threshold`

## Constructor Summary

Constructors
Constructor
Description
`ReduceToBilevelThreshold()`

## Method Summary

Modifier and Type
Method
Description
`Integer`
`getThreshold()`
Returns the current threshold value, or `null` if none was specified and the operation's process method was not run yet.
`void`
`process()`
This method does the actual work of the operation.
`private void`
`process(GrayIntegerImage in, BilevelImage out)`
`void`
`setThreshold(int newThreshold)`
Sets a new threshold value.

### Methods inherited from class net.sourceforge.jiu.ops.ImageToImageOperation

`canInputAndOutputBeEqual, ensureImagesHaveSameResolution, ensureInputImageIsAvailable, ensureOutputImageResolution, getInputImage, getOutputImage, setCanInputAndOutputBeEqual, setInputImage, setOutputImage`

### Methods inherited from class net.sourceforge.jiu.ops.Operation

`addProgressListener, addProgressListeners, getAbort, removeProgressListener, setAbort, setProgress, setProgress`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### threshold

private Integer threshold

## Constructor Details

### ReduceToBilevelThreshold

public ReduceToBilevelThreshold()

## Method Details

### getThreshold

public Integer getThreshold()
Returns the current threshold value, or `null` if none was specified and the operation's process method was not run yet.

Returns:
  threshold value

### process

private void process(GrayIntegerImage in, BilevelImage out) throws WrongParameterException

Throws:
  `WrongParameterException`

### process

public void process() throws MissingParameterException, WrongParameterException
Description copied from class: `Operation`
This method does the actual work of the operation. It must be called after all parameters have been given to the operation object.

Overrides:
  `process` in class `Operation`
Throws:
  `MissingParameterException` - if any mandatory parameter was not given to the operation
  `WrongParameterException` - if at least one of the input parameters was not initialized appropriately (values out of the valid interval, etc.)

### setThreshold

public void setThreshold(int newThreshold)
Sets a new threshold value.

Parameters:
  `newThreshold` - the new threshold value to be used for this operation
Throws:
  `IllegalArgumentException` - if the threshold value is negative