net.sourceforge.jiu.color.adjustment

Class Contrast


public class Contrast
extends LookupTableOperation

Adjusts the contrast of an image. The amount of adjustment is given to the constructor as a percentage value between -100 and 100. -100 will make the resulting image middle-gray, 0 will leave it unchanged, 100 will map it to the eight corners of the color cube.

Usage examples

Both examples increase contrast by 30 percent.

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 
 
Author:
Marco Schmidt

Field Summary

private int
contrast

Fields inherited from class net.sourceforge.jiu.ops.LookupTableOperation

intTables, numTables

Fields inherited from class net.sourceforge.jiu.ops.ImageToImageOperation

canInAndOutBeEqual, inputImage, outputImage

Fields inherited from class net.sourceforge.jiu.ops.Operation

abort, progressListeners

Method Summary

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()
private void
process(Paletted8Image in, Paletted8Image out)
void
setContrast(int newContrast)
Sets the value for contrast adjustment to be used within this operation.

Methods inherited from class net.sourceforge.jiu.ops.LookupTableOperation

getNumTables, getTable, prepareImages, process, process, process, setNumTables, setTable, setTables

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, process, removeProgressListener, setAbort, setProgress, setProgress

Field Details

contrast

private int contrast

Method Details

adjust

public static PixelImage adjust(PixelImage input,
                                int percentage)
This static helper method is more simple to use when all you need are the standard options.
Parameters:
input - the image to work on
percentage - contrast modification, from -100 to 100
Returns:
a new image with adjusted contrast

createLookupTable

private int[] createLookupTable(int numSamples,
                                int contrast)

getContrast

public int getContrast()
Returns the contrast adjustment value associated with this opperation. The value lies between -100 and 100 (including both values).
Returns:
contrast adjustment

process

public void process()
            throws MissingParameterException,
                   WrongParameterException
Overrides:
process in interface LookupTableOperation

process

private void process(Paletted8Image in,
                     Paletted8Image out)

setContrast

public void setContrast(int newContrast)
Sets the value for contrast adjustment to be used within this operation.
Parameters:
newContrast - new contrast, between -100 and 100 (including both values)