|
JIU 0.12.0 Homepage | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.jiu.ops.Operation
net.sourceforge.jiu.ops.ImageToImageOperation
net.sourceforge.jiu.color.quantization.MedianCutContourRemoval
Performs the Median Cut color quantization algorithm in combination with a contour removal algorithm.
Quantization is an operation that reduces the number of colors in
an image while trying to remain as close to the original image
as possible.
Standard Median Cut quantization is implemented in the
MedianCutQuantizer
class.
This class implements an algorithm that improves the standard implementation. It repeatedly calls the original quantizer and adjusts the palette in order to reduce the amount of contouring errors.
RGB24Image
object as input and produces a Paletted8Image
as output.
RGB24Image inputImage = ...; // image to be processed, from a file etc. MedianCutQuantizer quantizer = new MedianCutQuantizer(); quantizer.setPaletteSize(256); MedianCutContourRemoval removal = new MedianCutContourRemoval(); removal.setQuantizer(quantizer); removal.setInputImage(inputImage); removal.setTau(11.0); removal.setNumPasses(3); removal.process(); PixelImage outputImage = removal.getOutputImage();
MedianCutQuantizer
is used for that purpose.
This results in a palette and an output image that was mapped from
the original using the palette.
CoOccurrenceFrequencyMatrix
is created
from a CoOccurrenceMatrix
, which is in
turn created from the paletted image that was produced in the previous step.
The co-occurrence frequency matrix stores how often a pixel value j is the
neighbor of pixel i in the image, in relation to all occurrences of i.
The matrix stores this information as double
values between
0.0
and 1.0
.
If the value is 0.6
, j makes 60 percent of all neighboring
pixels of i.
setTau(double)
is a
distance value in RGB space (tau is adjusted for an RGB cube where each
axis can take values from 0 to 255).
It is used to define a threshold for similar colors.
A pair of compressible colors may not differ by more than tau.
It is guaranteed that no color can be both compressible and contouring.
setNumPasses(int)
method.
Usually, more than eight iterations do not make a difference.
MedianCutQuantizer
Field Summary | |
static int |
DEFAULT_NUM_PASSES
The default number of passes, used if they are not specified with setNumPasses(int) .
|
static double |
DEFAULT_TAU
The default tau value, used if none is specified with setTau(double) .
|
Constructor Summary | |
MedianCutContourRemoval()
|
Method Summary | |
static void |
main(String[] args)
Small command line application that performs a contour removal on an image. |
void |
process()
This method does the actual work of the operation. |
void |
setNumPasses(int newValue)
Specify the number of contour removal passes to be performed. |
void |
setQuantizer(MedianCutQuantizer medianCutQuantizer)
Set the MedianCutQuantizer
object to be used with this contour removal operation.
|
void |
setTau(double newValue)
Specify the tau value to be used by this operation. |
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, removeProgressListener, setAbort, setProgress, setProgress |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final double DEFAULT_TAU
setTau(double)
.
Check the class documentation to find out more about
the meaning of tau: MedianCutContourRemoval
.
public static final int DEFAULT_NUM_PASSES
setNumPasses(int)
.
Check the class documentation to find out more about
the meaning of that number of passes: MedianCutContourRemoval
.
Constructor Detail |
public MedianCutContourRemoval()
Method Detail |
public static void main(String[] args) throws Exception
args
- program arguments; must have length one, the only argument being the input image file name
Exception
public void process() throws MissingParameterException, OperationFailedException, WrongParameterException
Operation
process
in class Operation
MissingParameterException
- if any mandatory parameter was not given to the operation
WrongParameterException
- if at least one of the input parameters was
not initialized appropriately (values out of the valid interval, etc.)
OperationFailedException
public void setQuantizer(MedianCutQuantizer medianCutQuantizer)
MedianCutQuantizer
object to be used with this contour removal operation.
This is a mandatory parameter.
If process gets called before the quantizer object was specified,
a MissingParameterException
is thrown.
medianCutQuantizer
- the quantizer object that will get used by this operationpublic void setNumPasses(int newValue)
DEFAULT_NUM_PASSES
is used.
newValue
- number of passes, 1 or higher
IllegalArgumentException
- if the argument is 0 or smallerpublic void setTau(double newValue)
DEFAULT_TAU
is used.
newValue
- tau value, 0.0 or higher
IllegalArgumentException
- if the argument is smaller than 0.0
|
JIU 0.12.0 Homepage | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |