JIU 0.12.0 Homepage

net.sourceforge.jiu.filters
Class OilFilter

java.lang.Object
  extended bynet.sourceforge.jiu.ops.Operation
      extended bynet.sourceforge.jiu.ops.ImageToImageOperation
          extended bynet.sourceforge.jiu.filters.AreaFilterOperation
              extended bynet.sourceforge.jiu.filters.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

Constructor Summary
OilFilter()
           
 
Method Summary
 int computeSample(int[] samples, int numSamples)
          Determine the resulting sample for an array with the source sample and zero or more of its neighbors.
 void process()
          This method does the actual work of the operation.
 
Methods inherited from class net.sourceforge.jiu.filters.AreaFilterOperation
checkAreaHeight, checkAreaWidth, getAreaHeight, getAreaWidth, 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, removeProgressListener, setAbort, setProgress, setProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OilFilter

public OilFilter()
Method Detail

computeSample

public final int computeSample(int[] samples,
                               int numSamples)
Description copied from class: AreaFilterOperation
Determine the resulting sample for an array with the source sample and zero or more of its neighbors. This abstract method must be implemented by classes extending this operation. The array will hold numSamples samples, which will be stored starting at offset 0.

Normally, numSamples is equal to AreaFilterOperation.getAreaWidth() times AreaFilterOperation.getAreaHeight(). Near the border of the image you may get less samples. Example: the top left sample of an image has only three neighbors (east, south-east and south), so you will only get four samples (three neighbors and the sample itself).

Specified by:
computeSample in class AreaFilterOperation
Parameters:
samples - the array holding the sample(s)
numSamples - number of samples in the array
Returns:
sample to be written to the output image

process

public void process()
             throws MissingParameterException,
                    WrongParameterException
Description copied from class: Operation
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 class AreaFilterOperation
Throws:
MissingParameterException
WrongParameterException

JIU 0.12.0 Homepage

Copyright © 2000, 2001, 2002, 2003, 2004 Marco Schmidt