net.sourceforge.jiu.color.reduction

Class ReduceRGB


public class ReduceRGB
extends ImageToImageOperation

Reduces the color depth of RGB truecolor images. This class uses a simple approach, it just drops some of the lowest bits and scales the value back to eight or sixteen bits per sample.

Supported image classes

This class works with RGB24Image and RGB48Image.

Usage example

Reduce a 24 or 48 bits per pixel RGB image to 15 bits per pixel:
 PixelImage inputImage = ...; // initialize
 ReduceRGB reduce = new ReduceRGB();
 reduce.setBitsPerSample(5);
 reduce.setInputImage(inputImage);
 reduce.process();
 PixelImage reducedImage = reduce.getOutputImage();
 
Author:
Marco Schmidt
Since:
0.12.0
See Also:
ReduceShadesOfGray

Field Summary

private Integer
destBits
Number of significant bits per channel in the destination RGB image.

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

void
process()
This method does the actual work of the operation.
void
setBitsPerSample(int bits)
Specifies the number of bits per sample in the output image.

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

destBits

private Integer destBits
Number of significant bits per channel in the destination RGB image.

Method Details

process

public void process()
            throws MissingParameterException,
                   WrongParameterException
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 interface Operation
Throws:
WrongParameterException - if at least one of the input parameters was not initialized appropriately (values out of the valid interval, etc.)
MissingParameterException - if any mandatory parameter was not given to the operation

setBitsPerSample

public void setBitsPerSample(int bits)
Specifies the number of bits per sample in the output image.
Parameters:
bits - number of bits in output image, from 1 to 15