public class ReduceToBilevelThreshold extends ImageToImageOperation
GrayIntegerImage
to a
BilevelImage
by setting all values below
a certain threshold value to black and everything else to white.
setThreshold(int)
, this operation
uses a default value of (IntegerImage.getMaxSample(int)
+ 1) / 2.
GrayIntegerImage image = ...; ReduceToBilevelThreshold red = new ReduceToBilevelThreshold(); red.setInputImage(image); red.setThreshold(image.getMaxSample(0) / 3); red.process(); BilevelImage reducedImage= (BilevelImage)red.getOutputImage();
Modifier and Type | Field and Description |
---|---|
private java.lang.Integer |
threshold |
Constructor and Description |
---|
ReduceToBilevelThreshold() |
Modifier and Type | Method and Description |
---|---|
java.lang.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.
|
canInputAndOutputBeEqual, ensureImagesHaveSameResolution, ensureInputImageIsAvailable, ensureOutputImageResolution, getInputImage, getOutputImage, setCanInputAndOutputBeEqual, setInputImage, setOutputImage
addProgressListener, addProgressListeners, getAbort, removeProgressListener, setAbort, setProgress, setProgress
public java.lang.Integer getThreshold()
null
if
none was specified and the operation's process method was not
run yet.private void process(GrayIntegerImage in, BilevelImage out) throws WrongParameterException
WrongParameterException
public void process() throws MissingParameterException, WrongParameterException
Operation
process
in class Operation
MissingParameterException
- if any mandatory parameter was not given to the operationWrongParameterException
- if at least one of the input parameters was
not initialized appropriately (values out of the valid interval, etc.)public void setThreshold(int newThreshold)
newThreshold
- the new threshold value to be used for this operationjava.lang.IllegalArgumentException
- if the threshold value is negative