Package net.sourceforge.jiu.color
Class Invert
java.lang.Object
net.sourceforge.jiu.ops.Operation
net.sourceforge.jiu.ops.ImageToImageOperation
net.sourceforge.jiu.color.Invert
Creates an inverted (negated) version of an image.
This is done by subtracting each sample value of a channel
from the maximum sample for that channel.
The maximum sample for a channel is given by
IntegerImage.getMaxSample(int).
For paletted images, just the palette is treated that way.
Supported image types: IntegerImage.
Input and output image can be the same object.
Usage
There are two ways of using this class. Either create an Invert object and set all paramters yourself. This lets you reuse image objects or add a progress listener.Invert invert = new Invert(); invert.setInputImage(image); invert.addProgressListener(listener); // this is optional invert.process(); PixelImage invertedImage = invert.getOutputImage();The other method is by sing the static convenience method
PixelImage invertedImage = Invert.invert(someImage);You will have to catch the potential exceptions in both cases.
- Author:
- Marco Schmidt
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PixelImageinvert(PixelImage inputImage) Helper method to return an inverted image from the argument image.private voidprepare(PixelImage in) voidprocess()Inverts the input image, reusing an output image if one has been specified.private voidprocess(IntegerImage in) private voidMethods inherited from class net.sourceforge.jiu.ops.ImageToImageOperation
canInputAndOutputBeEqual, ensureImagesHaveSameResolution, ensureInputImageIsAvailable, ensureOutputImageResolution, getInputImage, getOutputImage, setCanInputAndOutputBeEqual, setInputImage, setOutputImageMethods inherited from class net.sourceforge.jiu.ops.Operation
addProgressListener, addProgressListeners, getAbort, removeProgressListener, setAbort, setProgress, setProgress
-
Constructor Details
-
Invert
public Invert()
-
-
Method Details
-
invert
Helper method to return an inverted image from the argument image.- Parameters:
inputImage- image to be inverted- Returns:
- new image object with inverted image
- Throws:
OperationFailedException- on operation errors
-
prepare
-
process
-
process
-
process
Inverts the input image, reusing an output image if one has been specified. For paletted images, inverts the palette. For all other types, subtracts each sample of each channel from the maximum value of that channel.- Overrides:
processin classOperation- Throws:
MissingParameterException- if the input image is missingWrongParameterException- if any of the specified image parameters are unsupported or of the wrong width or height
-