net.sourceforge.jiu.filters

Class OilFilter


public class OilFilter
extends AreaFilterOperation

Applies a filter that makes the image look like an oil painting. This is accomplished by creating a histogram of the neighboring samples for each input sample and storing the value that occurs most often in the output image. If two or more samples occur an equal number of times, the lowest sample value is picked.

Supported image types

Can process both GrayIntegerImage and RGBIntegerImage. Note that this operation becomes very slow with 16 bits per sample because a lot of runs over a 65536 element array are necessary.

Usage example

 PixelImage image = ...; // some GrayIntegerImage or RGBIntegerImage
 OilFilter filter = new OilFilter();
 filter.setArea(5, 5);
 filter.setInputImage(image);
 filter.process();
 PixelImage filteredImage = filter.getOutputImage();
 

Credits

Idea taken from the Oil class of Jef Poskanzer's ACME package.
Author:
Marco Schmidt

Field Summary

private int[]
hist
private int[]
zeroes

Fields inherited from class net.sourceforge.jiu.filters.AreaFilterOperation

areaHeight, areaWidth

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

int
computeSample(int[] samples, int numSamples)
void
process()
This method does the actual work of the operation.

Methods inherited from class net.sourceforge.jiu.filters.AreaFilterOperation

checkAreaHeight, checkAreaWidth, computeSample, getAreaHeight, getAreaWidth, process, process, process, processBorders, processCenter, setArea, setAreaHeight, setAreaWidth

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

hist

private int[] hist

zeroes

private int[] zeroes

Method Details

computeSample

public final int computeSample(int[] samples,
                               int numSamples)
Overrides:
computeSample in interface AreaFilterOperation

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 AreaFilterOperation
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