nao
Class CameraImage

java.lang.Object
  extended by nao.CameraImage

public class CameraImage
extends java.lang.Object


Nested Class Summary
static class CameraImage.Blob
           
 
Field Summary
static int BLACK
           
static int BLUE
           
static int GREEN
           
 int height
           
 int[] pixels
           
static int RED
           
static int WHITE
           
 int width
           
 
Constructor Summary
CameraImage(java.awt.Image i)
          Create a CameraImage from a normal Image.
CameraImage(int[] px, int width, int height)
          Create a CameraImage from the specified pixel array.
 
Method Summary
 void applyBlueThreshold(int blueThreshold, double redWeight, double greenWeight)
          Apply a threshold to pick out the blue pixels.
 void applyGreenThreshold(int greenThreshold, double blueWeight, double redWeight)
          Apply a threshold to pick out the green pixels.
 void applyGreyThreshold(int threshold)
          Apply a threshold to get a black and white image.
 void applyRedThreshold(int redThreshold, double blueWeight, double greenWeight)
          Apply a threshold to pick out the red pixels.
 void applyThreshold(java.awt.Color colour, int[] colourLimits)
          Apply a threshold to pick out an arbitrary colour.
 java.util.Vector<CameraImage.Blob> getBlobs(java.awt.Color colour, int blobThreshold, int maxBlobs)
          Label blobs (segments of contiguous colour) in the image of the specified colour and minimum size (blobThreshold).
 CameraImage.Blob getLargestBlob(java.awt.Color colour, int blobThreshold)
          Get the single largest blob in the image of the given colour and minimum size.
 java.awt.image.BufferedImage toImage()
          Convert this to a normal Image.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RED

public static final int RED
See Also:
Constant Field Values

GREEN

public static final int GREEN
See Also:
Constant Field Values

BLUE

public static final int BLUE
See Also:
Constant Field Values

BLACK

public static final int BLACK
See Also:
Constant Field Values

WHITE

public static final int WHITE
See Also:
Constant Field Values

pixels

public final int[] pixels

width

public final int width

height

public final int height
Constructor Detail

CameraImage

public CameraImage(java.awt.Image i)
Create a CameraImage from a normal Image.


CameraImage

public CameraImage(int[] px,
                   int width,
                   int height)
Create a CameraImage from the specified pixel array.

Method Detail

applyRedThreshold

public void applyRedThreshold(int redThreshold,
                              double blueWeight,
                              double greenWeight)
Apply a threshold to pick out the red pixels. These pixels must have a red component greater than redThreshold and the red component must be greater than the blue/green weight times the green/blue components. The marked pixels will be coloured red.


applyBlueThreshold

public void applyBlueThreshold(int blueThreshold,
                               double redWeight,
                               double greenWeight)
Apply a threshold to pick out the blue pixels. The marked pixels will be coloured blue.


applyGreenThreshold

public void applyGreenThreshold(int greenThreshold,
                                double blueWeight,
                                double redWeight)
Apply a threshold to pick out the green pixels. The marked pixels will be coloured green.


applyGreyThreshold

public void applyGreyThreshold(int threshold)
Apply a threshold to get a black and white image. Pixels less than the threshold are coloured black.


applyThreshold

public void applyThreshold(java.awt.Color colour,
                           int[] colourLimits)
Apply a threshold to pick out an arbitrary colour. To be marked, a pixel's red component must be greater than colourLimits[0] and less than [1], its green components must be between [2] and [3], and its blue components must be between [4] and [5]. Hence the colourLimits array must have six elements.


getBlobs

public java.util.Vector<CameraImage.Blob> getBlobs(java.awt.Color colour,
                                                   int blobThreshold,
                                                   int maxBlobs)
Label blobs (segments of contiguous colour) in the image of the specified colour and minimum size (blobThreshold). If maxBlobs==0 then all blobs meeting these criteria will be returned, sorted such that the largest blob is first in the vector. Otherwise, the vector will contain at most the number of blobs indicated by maxBlobs (possibly less), and they will be sorted.


getLargestBlob

public CameraImage.Blob getLargestBlob(java.awt.Color colour,
                                       int blobThreshold)
Get the single largest blob in the image of the given colour and minimum size.


toImage

public java.awt.image.BufferedImage toImage()
Convert this to a normal Image.