Class BinaryFast

java.lang.Object
  |
  +--image
        |
        +--BinaryFast

public class BinaryFast
extends image

Class BinaryFast is a representation of a binary image storing the foreground and background edge pixels in hash tables for efficiency.

Author:
Simon Horne.

Field Summary
static int background
          Background is black.
 java.util.HashSet backgroundEdgePixels
          The hash set storing positions of background edge pixels as Points.
static int foreground
          Foreground is white.
 java.util.HashSet foregroundEdgePixels
          The hash set storing positions of foreground edge pixels as Points.
 int h
          Height of the image.
 int[][] pixels
          The 2D array of all pixels.
 int s
          Size of the image (w*h), number of pixels.
 int w
          Width of the image.
 
Fields inherited from class image
height, width
 
Constructor Summary
BinaryFast()
           
BinaryFast(BinaryFast oldBinary)
           
BinaryFast(image oldimage)
          Constructor taking an image and converting it to a BinaryFast image
BinaryFast(int[][] p, int width, int height)
          Constructor taking a 2D array of pixel values.
 
Method Summary
 void addPixel(java.awt.Point p)
          Adds a foreground pixel to the 2D array by setting its value to foreground.
 int[] convertToArray()
          Converts the 2D array into a 1D array of pixel values.
 void convertToPixels(java.util.HashSet pix)
          Adds the pixels from a hash set to the 2D array of pixels.
 void generateBackgroundEdgeFromForegroundEdge()
          Generates the background edge hash set from the foreground edge hash set and the 2D array of pixels.
 void generateForegroundEdge()
          Generates the foreground edge hash set from the 2D array of pixels.
 void generateForegroundEdgeFromBackgroundEdge()
          Generates the foreground edge hash set from the background edge hash set and the 2D array of pixels.
 void generatePixels(java.util.HashSet pix)
          Generates a new 2D array of pixels from a hash set of foreground pixels.
 int[] getValues()
          Returns the int [] values of the Binary Fast image
 void removePixel(java.awt.Point p)
          Removes a foreground pixel from the 2D array by setting its value to background.
 
Methods inherited from class image
getHeight, getWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

background

public static final int background
Background is black.

foreground

public static final int foreground
Foreground is white.

w

public int w
Width of the image.

h

public int h
Height of the image.

s

public int s
Size of the image (w*h), number of pixels.

pixels

public int[][] pixels
The 2D array of all pixels.

foregroundEdgePixels

public java.util.HashSet foregroundEdgePixels
The hash set storing positions of foreground edge pixels as Points.

backgroundEdgePixels

public java.util.HashSet backgroundEdgePixels
The hash set storing positions of background edge pixels as Points.
Constructor Detail

BinaryFast

public BinaryFast(image oldimage)
Constructor taking an image and converting it to a BinaryFast image

BinaryFast

public BinaryFast(int[][] p,
                  int width,
                  int height)
Constructor taking a 2D array of pixel values.
Parameters:
p - The 2D array of pixel values.
width - The width of the image.
height - The height of the image.

BinaryFast

public BinaryFast()

BinaryFast

public BinaryFast(BinaryFast oldBinary)
Method Detail

removePixel

public void removePixel(java.awt.Point p)
Removes a foreground pixel from the 2D array by setting its value to background.
Parameters:
p - The point to be removed.

addPixel

public void addPixel(java.awt.Point p)
Adds a foreground pixel to the 2D array by setting its value to foreground.
Parameters:
p - The point to be added.

convertToArray

public int[] convertToArray()
Converts the 2D array into a 1D array of pixel values.
Returns:
The 1D array of pixel values.

generatePixels

public void generatePixels(java.util.HashSet pix)
Generates a new 2D array of pixels from a hash set of foreground pixels.
Parameters:
pix - The hash set of foreground pixels.

convertToPixels

public void convertToPixels(java.util.HashSet pix)
Adds the pixels from a hash set to the 2D array of pixels.
Parameters:
pix - The hash set of foreground pixels to be added.

generateForegroundEdge

public void generateForegroundEdge()
Generates the foreground edge hash set from the 2D array of pixels.

generateBackgroundEdgeFromForegroundEdge

public void generateBackgroundEdgeFromForegroundEdge()
Generates the background edge hash set from the foreground edge hash set and the 2D array of pixels.

generateForegroundEdgeFromBackgroundEdge

public void generateForegroundEdgeFromBackgroundEdge()
Generates the foreground edge hash set from the background edge hash set and the 2D array of pixels.

getValues

public int[] getValues()
Returns the int [] values of the Binary Fast image
Returns:
int[] the greylevel array of the image
Overrides:
getValues in class image