jjil.algorithm
Class RgbSelect2Gray

java.lang.Object
  extended by jjil.core.PipelineStage
      extended by jjil.algorithm.RgbSelect2Gray

public class RgbSelect2Gray
extends PipelineStage

Transforms a RgbImage into a Gray8Image by selecting one of the three bands. The pixel value chosen is adjusted from the range 0->255 to the range -128->127.

Usage:
RgbImage imageRgb = ...;
RgbSelect2Gray rgb = new RgbSelect2Gray(RgbSelect2Gray.RED);
rgb.push(imageRgb);

Author:
webb

Nested Class Summary
static class RgbSelect2Gray.ColorClass
          Used to represent the three colors red, green, or blue.
 
Field Summary
static RgbSelect2Gray.ColorClass BLUE
          The class represents the color blue.
static RgbSelect2Gray.ColorClass GREEN
          The class represents the color green.
static RgbSelect2Gray.ColorClass RED
          The class represents the color red.
 
Constructor Summary
RgbSelect2Gray(RgbSelect2Gray.ColorClass color)
          Creates a new instance of RgbSelect2Gray.
 
Method Summary
 RgbSelect2Gray.ColorClass getColor()
          Returns the current color selected.
 void push(Image image)
          Convert a color image to gray by selecting one of the color bands: red, green, or blue.
 void setColor(RgbSelect2Gray.ColorClass color)
          Changes the color selected.
 java.lang.String toString()
          Return a string describing the RGB select operation.
 
Methods inherited from class jjil.core.PipelineStage
getFront, isEmpty
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RED

public static final RgbSelect2Gray.ColorClass RED
The class represents the color red. It is used like an enumerated value when calling the RgbSelect2Gray constructor.


GREEN

public static final RgbSelect2Gray.ColorClass GREEN
The class represents the color green. It is used like an enumerated value when calling the RgbSelect2Gray constructor.


BLUE

public static final RgbSelect2Gray.ColorClass BLUE
The class represents the color blue. It is used like an enumerated value when calling the RgbSelect2Gray constructor.

Constructor Detail

RgbSelect2Gray

public RgbSelect2Gray(RgbSelect2Gray.ColorClass color)
               throws Error
Creates a new instance of RgbSelect2Gray.

Parameters:
color - the color selected from the color image to create the gray image.
Throws:
Error - if color is not RED, GREEN, or BLUE.
Method Detail

getColor

public RgbSelect2Gray.ColorClass getColor()
Returns the current color selected.

Returns:
the current color, as a ColorClass object.

push

public void push(Image image)
          throws Error
Convert a color image to gray by selecting one of the color bands: red, green, or blue. The band selected is chosen in the class constructor. The gray pixel value is adjusted so its range is from -128->127 instead of the 0-255 value in the ARGB word.

Specified by:
push in class PipelineStage
Parameters:
image - the input image
Throws:
Error - if the input image is not a color image.

setColor

public void setColor(RgbSelect2Gray.ColorClass color)
              throws Error
Changes the color selected.

Parameters:
color - the new color selected
Throws:
Error - if the input color is not ColorClass.RED, GREEN, or BLUE.

toString

public java.lang.String toString()
Return a string describing the RGB select operation.

Overrides:
toString in class java.lang.Object
Returns:
the string describing the RGB select operation.