Package net.sourceforge.jiu.filters
Class MedianFilter
- java.lang.Object
-
- net.sourceforge.jiu.ops.Operation
-
- net.sourceforge.jiu.ops.ImageToImageOperation
-
- net.sourceforge.jiu.filters.AreaFilterOperation
-
- net.sourceforge.jiu.filters.MedianFilter
-
public class MedianFilter extends AreaFilterOperation
Applies a Median filter that replaces each pixel by the median of itself and its neighbors. The number of neighbors can be defined with the setArea methods.Can be used as despeckle filter, but the image will lose sharpness. The larger the area becomes, the less noise and the less sharpness will remain, and the longer it will take.
Uses
Median
to do the search for the median value.Usage example
PixelImage image = ...; // some GrayIntegerImage or RGBIntegerImage MedianFilter filter = new MedianFilter(); filter.setArea(5, 5); filter.setInputImage(image); filter.process(); PixelImage filteredImage = filter.getOutputImage();
- Author:
- Marco Schmidt
-
-
Constructor Summary
Constructors Constructor Description MedianFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 net.sourceforge.jiu.filters.AreaFilterOperation
checkAreaHeight, checkAreaWidth, getAreaHeight, getAreaWidth, process, 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
-
-
-
-
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 holdnumSamples
samples, which will be stored starting at offset0
.Normally,
numSamples
is equal toAreaFilterOperation.getAreaWidth()
timesAreaFilterOperation.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 classAreaFilterOperation
- Parameters:
samples
- the array holding the sample(s)numSamples
- number of samples in the array- Returns:
- sample to be written to the output image
-
-