org.jscience.computing.ai.vision
Class RankFilter

java.lang.Object
  extended by org.jscience.computing.ai.vision.Filter
      extended by org.jscience.computing.ai.vision.RankFilter

public class RankFilter
extends Filter

This class implements a simple rank filter: allowing you to select the median, minimum or maximum for any given neighbourhood size. Note that this class is unapologetically slow! There are no optimizations at all, to ensure the best code readability.


Field Summary
static int MAXIMUM
          Retrieve the maximum from the neighbourhood.
static int MEDIAN
          Calculate the median for the neighbourhood.
static int MINIMUM
          Retrieve the minimum from the neighbourhood.
protected  int neighbourhoodSize
          The neighbourhood size.
protected  int rankPosition
          The type of rank position (median, maximum, minimum).
 
Constructor Summary
RankFilter()
          Creates a new instance of RankFilter
RankFilter(int rank)
          Creates a new instance of RankFilter, with the given rank type.
RankFilter(int rank, int neighbourhoodSize)
          Creates a new instance of RankFilter, with the given rank type and neighbourhood size.
 
Method Summary
 java.awt.image.BufferedImage filter(java.awt.image.BufferedImage image, java.awt.image.BufferedImage output)
          Rank filter an image.
 int getNeighbourhoodSize()
          Get the neighbourhood size.
 int getRankPosition()
          Get the rank position.
static void main(java.lang.String[] args)
          Utility method for the class.
 void setNeighbourhoodSize(int neighbourhoodSize)
          Set the neighbourhood size.
 void setRankPosition(int rankPosition)
          Set the rank position.
 java.lang.String toString()
          DOCUMENT ME!
 
Methods inherited from class org.jscience.computing.ai.vision.Filter
filter, verifyOutput, verifyOutput, verifyOutput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MEDIAN

public static final int MEDIAN
Calculate the median for the neighbourhood.

See Also:
Constant Field Values

MINIMUM

public static final int MINIMUM
Retrieve the minimum from the neighbourhood.

See Also:
Constant Field Values

MAXIMUM

public static final int MAXIMUM
Retrieve the maximum from the neighbourhood.

See Also:
Constant Field Values

neighbourhoodSize

protected int neighbourhoodSize
The neighbourhood size.


rankPosition

protected int rankPosition
The type of rank position (median, maximum, minimum).

Constructor Detail

RankFilter

public RankFilter()
Creates a new instance of RankFilter


RankFilter

public RankFilter(int rank)
Creates a new instance of RankFilter, with the given rank type.

Parameters:
rank - the rank type.

RankFilter

public RankFilter(int rank,
                  int neighbourhoodSize)
Creates a new instance of RankFilter, with the given rank type and neighbourhood size.

Parameters:
rank - the rank type.
neighbourhoodSize - the neighbourhood size.
Method Detail

filter

public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage image,
                                           java.awt.image.BufferedImage output)
Rank filter an image.

Specified by:
filter in class Filter
Parameters:
image - the input image.
output - the output image (optional).
Returns:
the rank filtered output.
See Also:
Filter.verifyOutput(BufferedImage,BufferedImage)

getNeighbourhoodSize

public int getNeighbourhoodSize()
Get the neighbourhood size.

Returns:
the current neighbourhood size.

setNeighbourhoodSize

public void setNeighbourhoodSize(int neighbourhoodSize)
Set the neighbourhood size. Note that this must be an odd number, an even numbers will be incremented.

Parameters:
neighbourhoodSize - the new neighbourhood size.

getRankPosition

public int getRankPosition()
Get the rank position.

Returns:
the current rank position.

setRankPosition

public void setRankPosition(int rankPosition)
Set the rank position. See MEDIAN, MINIMUM or MAXIMUM.

Parameters:
rankPosition - the new rank position.

toString

public java.lang.String toString()
DOCUMENT ME!

Overrides:
toString in class java.lang.Object
Returns:
DOCUMENT ME!

main

public static void main(java.lang.String[] args)
Utility method for the class.

Parameters:
args - the command line arguments