org.jscience.computing.ai.vision
Class GreyscaleFilter

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

public class GreyscaleFilter
extends Filter

This class converts an RGB colour to a greyscale image.


Field Summary
static int BT709
          BT709 Greyscale: Red: 0.2125 Green: 0.7154 Blue: 0.0721
protected  int greyscaleType
          The greyscale type (BT709, Y or RMY)
static int RMY
          RMY Greyscale: Red: 0.5 Green: 0.419 Blue: 0.081
static int Y
          Y-Greyscale (YIQ/NTSC): Red: 0.299 Green: 0.587 Blue: 0.114
 
Constructor Summary
GreyscaleFilter()
          Creates a new instance of GreyscaleFilter
 
Method Summary
protected  int calculateGrey(int r, int g, int b)
          Calculate the grey value according to the grey conversion set.
 java.awt.image.BufferedImage filter(java.awt.image.BufferedImage image, java.awt.image.BufferedImage output)
          Convert an RGB image to greyscale.
static java.awt.image.BufferedImage toGrey(java.awt.image.BufferedImage input, java.awt.image.BufferedImage output)
          A static utility function to generate a greyscale image.
 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

BT709

public static final int BT709
BT709 Greyscale: Red: 0.2125 Green: 0.7154 Blue: 0.0721

See Also:
Constant Field Values

Y

public static final int Y
Y-Greyscale (YIQ/NTSC): Red: 0.299 Green: 0.587 Blue: 0.114

See Also:
Constant Field Values

RMY

public static final int RMY
RMY Greyscale: Red: 0.5 Green: 0.419 Blue: 0.081

See Also:
Constant Field Values

greyscaleType

protected int greyscaleType
The greyscale type (BT709, Y or RMY)

Constructor Detail

GreyscaleFilter

public GreyscaleFilter()
Creates a new instance of GreyscaleFilter

Method Detail

filter

public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage image,
                                           java.awt.image.BufferedImage output)
Convert an RGB image to greyscale.

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

toGrey

public static java.awt.image.BufferedImage toGrey(java.awt.image.BufferedImage input,
                                                  java.awt.image.BufferedImage output)
A static utility function to generate a greyscale image. Simply implemented as: GreyscaleFilter grey = new GreyscaleFilter(); return grey.filter(input, output);

Parameters:
input - the input image.
output - the output image (optional).
Returns:
the greyscale image.

calculateGrey

protected int calculateGrey(int r,
                            int g,
                            int b)
Calculate the grey value according to the grey conversion set.

Parameters:
r - the red value.
g - the green value.
b - the blue value.
Returns:
the calculated grey value.

toString

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

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