Class Erode

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--Erode

public class Erode
extends java.lang.Thread

Erode is an algorithm to erode a binary image using a 3x3 kernel.

Author:
Simon Horne, Craig Strachan, Judy Robertson, SELLIC Online

Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Erode()
          Default no-args constructor.
 
Method Summary
static BinaryFast erode_image(BinaryFast binary, int[] kernel, int iterations)
          Applies several iterations of the erode algorithm to an image.
static BinaryFast erodeSingleIteration(BinaryFast binary, int[] kernel)
          Applies a single iteration of the erode algorithm to the image.
static boolean kernelAll1s(int[] kernel)
          Returns true if the kernel consists of 9 1s.
static boolean kernelMatch(java.awt.Point p, int[][] pixels, int w, int h, int[] kernel)
          Returns true if the kernel matches the area of image centred on the given point.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Erode

public Erode()
Default no-args constructor.
Method Detail

kernelMatch

public static boolean kernelMatch(java.awt.Point p,
                                  int[][] pixels,
                                  int w,
                                  int h,
                                  int[] kernel)
Returns true if the kernel matches the area of image centred on the given point.
Parameters:
p - The centre point identifying the pixel neighbourhood.
pixels - The 2D array representing the image.
w - The width of the image.
h - The height of the image.
kernel - The array representing the kernel.
Returns:
True or false (true - the kernel and image match).

kernelAll1s

public static boolean kernelAll1s(int[] kernel)
Returns true if the kernel consists of 9 1s.
Parameters:
kernel - The array representing the kernel.
Returns:
True or false (true - kernel is all 1s).

erodeSingleIteration

public static BinaryFast erodeSingleIteration(BinaryFast binary,
                                              int[] kernel)
Applies a single iteration of the erode algorithm to the image.
Parameters:
binary - The BinaryFast representation of the input image.
kernel - The array representing the kernel.
Returns:
The BinaryFast representation of the new eroded image.

erode_image

public static BinaryFast erode_image(BinaryFast binary,
                                     int[] kernel,
                                     int iterations)
Applies several iterations of the erode algorithm to an image.
Parameters:
binary - The BinaryFast representation of the input image.
kernel - The array representing the kernel.
iterations - The number of iterations to be applied.
Returns:
The BinaryFast representation of the new eroded image.