koala
Class KoalaImage

java.lang.Object
  extended by koala.KoalaImage

public class KoalaImage
extends java.lang.Object

Class which encapsulates disturbingly common image operations.


Nested Class Summary
static class KoalaImage.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
KoalaImage(java.awt.Image i)
          Create a KoalaImage from a normal Image.
KoalaImage(int[] px, int width, int height)
          Create a KoalaImage 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 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.
static int bluePart(int rgb)
          Get the blue component of an RGB pixel.
 java.util.Vector<KoalaImage.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).
 int[] getBlueHistogram()
          Get the histogram of blue pixel values.
 int[] getGreenHistogram()
          Get the histogram of green pixel values.
 KoalaImage.Blob getLargestBlob(java.awt.Color colour, int blobThreshold)
          Get the single largest blob in the image of the given colour and minimum size.
 int[] getRedHistogram()
          Get the histogram of red pixel values.
static int greenPart(int rgb)
          Get the green component of an RGB pixel.
 boolean isAbnormal()
          Heuristic to detect abnormal images.
static int redPart(int rgb)
          Get the red component of an RGB pixel.
 java.awt.image.BufferedImage toImage()
          Convert this to a normal Image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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

KoalaImage

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


KoalaImage

public KoalaImage(int[] px,
                  int width,
                  int height)
Create a KoalaImage 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.


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<KoalaImage.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 KoalaImage.Blob getLargestBlob(java.awt.Color colour,
                                      int blobThreshold)
Get the single largest blob in the image of the given colour and minimum size.


isAbnormal

public boolean isAbnormal()
Heuristic to detect abnormal images. It detects those occasionally produced by the KoreCamera in which all pixels have a blue value of 255. Also returns true if the majority of pixels are black.


getRedHistogram

public int[] getRedHistogram()
Get the histogram of red pixel values. Returns an array containing 256 elements.


getGreenHistogram

public int[] getGreenHistogram()
Get the histogram of green pixel values. Returns an array containing 256 elements.


getBlueHistogram

public int[] getBlueHistogram()
Get the histogram of blue pixel values. Returns an array containing 256 elements.


toImage

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


bluePart

public static final int bluePart(int rgb)
Get the blue component of an RGB pixel.


greenPart

public static final int greenPart(int rgb)
Get the green component of an RGB pixel.


redPart

public static final int redPart(int rgb)
Get the red component of an RGB pixel.