public class Contrast extends LookupTableOperation
If all you want is to create a new image with adjusted contrast from the image data of an existing image, simply use the static helper method:
PixelImage adjustedImage = Contrast.adjust(inputImage, 30);This leaves the original image inputImage unchanged and allocates a second image object which is here assigned to the variable adjustedImage.
If you want more control over parameters, create your own Contrast object. You can then reuse image objects, e.g. to write the adjusted image data to the original image object:
Contrast op = new Contrast(); op.setInputImage(image); op.setOutputImage(image); op.setContrast(30); op.process(); // at this point, image will contain the adjusted image data, // the original data wil be overwritten
Modifier and Type | Field and Description |
---|---|
private int |
contrast |
Constructor and Description |
---|
Contrast() |
Modifier and Type | Method and Description |
---|---|
static PixelImage |
adjust(PixelImage input,
int percentage)
This static helper method is more simple to use when all
you need are the standard options.
|
private int[] |
createLookupTable(int numSamples,
int contrast) |
int |
getContrast()
Returns the contrast adjustment value associated with this opperation.
|
void |
process()
This method does the actual work of the operation.
|
private void |
process(Paletted8Image in,
Paletted8Image out) |
void |
setContrast(int newContrast)
Sets the value for contrast adjustment to be used within this operation.
|
getNumTables, getTable, prepareImages, setNumTables, setTable, setTables
canInputAndOutputBeEqual, ensureImagesHaveSameResolution, ensureInputImageIsAvailable, ensureOutputImageResolution, getInputImage, getOutputImage, setCanInputAndOutputBeEqual, setInputImage, setOutputImage
addProgressListener, addProgressListeners, getAbort, removeProgressListener, setAbort, setProgress, setProgress
public static PixelImage adjust(PixelImage input, int percentage)
input
- the image to work onpercentage
- contrast modification, from -100 to 100private int[] createLookupTable(int numSamples, int contrast)
public int getContrast()
setContrast(int)
private void process(Paletted8Image in, Paletted8Image out)
public void process() throws MissingParameterException, WrongParameterException
Operation
process
in class LookupTableOperation
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 setContrast(int newContrast)
newContrast
- new contrast, between -100 and 100 (including both values)java.lang.IllegalArgumentException
- if the new contrast value is not in the above mentioned intervalgetContrast()