net.sourceforge.jiu.filters
Class MeanFilter
java.lang.Object
net.sourceforge.jiu.ops.Operation
net.sourceforge.jiu.ops.ImageToImageOperation
net.sourceforge.jiu.filters.AreaFilterOperation
net.sourceforge.jiu.filters.MeanFilter
- public class MeanFilter
- extends AreaFilterOperation
Applies a mean filter that replaces each pixel by the mean of itself and its neighbors.
The number of neighbors can be defined by the setArea methods.
This filter only works with intensity-based image types.
More precisely, only GrayIntegerImage
and
RGBIntegerImage
will work.
Usage example
PixelImage image = ...; // some GrayIntegerImage or RGBIntegerImage
MeanFilter filter = new MeanFilter();
filter.setArea(5, 5);
filter.setInputImage(image);
filter.process();
PixelImage filteredImage = filter.getOutputImage();
- Since:
- 0.5.0
- Author:
- Marco Schmidt
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.
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MeanFilter
public MeanFilter()
computeSample
public 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
Copyright © 2000, 2001, 2002, 2003, 2004 Marco Schmidt