net.sourceforge.jiu.filters

Class AreaFilterOperation

Known Direct Subclasses:
MaximumFilter, MeanFilter, MedianFilter, MinimumFilter, OilFilter

public abstract class AreaFilterOperation
extends ImageToImageOperation

Base class for operations that convert images to images and determine an output sample by doing calculations on the input sample at the same position plus some neighboring samples.

Override computeSample(int[],int) and the operation will work.

Author:
Marco Schmidt
Since:
0.9.0

Field Summary

private int
areaHeight
private int
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

void
checkAreaHeight(int height)
Checks if the argument is a valid area height value.
void
checkAreaWidth(int width)
Checks if the argument is a valid area width value.
abstract int
computeSample(int[] samples, int numSamples)
Determine the resulting sample for an array with the source sample and zero or more of its neighbors.
int
getAreaHeight()
Returns the current area height.
int
getAreaWidth()
Returns the current area width.
void
process()
This method does the actual work of the operation.
private void
process(int channelIndex, IntegerImage in, IntegerImage out)
Applies the filter to one of the channels of an image.
private void
process(IntegerImage in, IntegerImage out)
private void
processBorders(int channelIndex, IntegerImage in, IntegerImage out)
private void
processCenter(int channelIndex, IntegerImage in, IntegerImage out)
void
setArea(int width, int height)
Sets the area of the window to be used to determine each pixel's mean to the argument width and height.
void
setAreaHeight(int height)
Sets the height of the area of the window to be used to determine each pixel's mean to the argument value.
void
setAreaWidth(int width)
Sets the width of the area of the window to be used to determine each pixel's mean to the argument value.

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

areaHeight

private int areaHeight

areaWidth

private int areaWidth

Method Details

checkAreaHeight

public void checkAreaHeight(int height)
Checks if the argument is a valid area height value. The default implementation requires the argument to be odd and larger than zero. Override this method if your extension of AreaFilterOperation requires different heights.

checkAreaWidth

public void checkAreaWidth(int width)
Checks if the argument is a valid area width value. The default implementation requires the argument to be odd and larger than zero. Override this method if your extension of AreaFilterOperation requires different widths.

computeSample

public abstract int computeSample(int[] samples,
                                  int numSamples)
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 getAreaWidth() times 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).

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

getAreaHeight

public int getAreaHeight()
Returns the current area height.
Returns:
height of area window in pixels

getAreaWidth

public int getAreaWidth()
Returns the current area width.
Returns:
width of area window in pixels

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

process

private void process(int channelIndex,
                     IntegerImage in,
                     IntegerImage out)
Applies the filter to one of the channels of an image.

process

private void process(IntegerImage in,
                     IntegerImage out)

processBorders

private void processBorders(int channelIndex,
                            IntegerImage in,
                            IntegerImage out)

processCenter

private void processCenter(int channelIndex,
                           IntegerImage in,
                           IntegerImage out)

setArea

public void setArea(int width,
                    int height)
Sets the area of the window to be used to determine each pixel's mean to the argument width and height.
Parameters:
width - width of window, must be 1 or larger
height - height of window, must be 1 or larger

setAreaHeight

public void setAreaHeight(int height)
Sets the height of the area of the window to be used to determine each pixel's mean to the argument value.
Parameters:
height - height of window, must be odd and 1 or larger

setAreaWidth

public void setAreaWidth(int width)
Sets the width of the area of the window to be used to determine each pixel's mean to the argument value.
Parameters:
width - width of window, must be odd and 1 or larger