Class ConSmooth

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

public class ConSmooth
extends java.lang.Thread

ConSmooth is an algorithm to conservatively smooth an image using a 3x3 kernel.

Author:
Simon Horne.

Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ConSmooth()
          Default no-arg constructor.
 
Method Summary
static boolean emptyKernel(int[] kernel)
          True if the kernel consists of 8 0s surrounding the centre pixel.
static int[][] generateInputArrays(int[] input, int width, int height)
          Converts a 1D array to a 2D array.
static int[] generateOutputArray(int[][] outputArrays, int width, int height)
          Converts a 2D array into a continuous 1D array.
static int maxNeighbour(int[][] input, int[] kernel, int w, int h, int x, int y)
          Finds the maximum value from a 3x3 pixel neighbourhood overlaid with a 3x3 kernel (on/off).
static int minNeighbour(int[][] input, int[] kernel, int w, int h, int x, int y)
          Finds the minimum value from a 3x3 pixel neighbourhood overlaid with a 3x3 kernel (on/off).
static int[] smooth_image(int[] input, int[] kernel, int width, int height)
          Takes an image and a kernel and applies conservative smoothing to it.
 int[][] smooth(int[][] inputArrays, int[] kernel, int width, int height)
           
 int[] smoothImage(int[] input, int width, int height, int[] kernel, int kernelWidth, int kernelHeight)
           
 
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

ConSmooth

public ConSmooth()
Default no-arg constructor.
Method Detail

maxNeighbour

public static int maxNeighbour(int[][] input,
                               int[] kernel,
                               int w,
                               int h,
                               int x,
                               int y)
Finds the maximum value from a 3x3 pixel neighbourhood overlaid with a 3x3 kernel (on/off). The centre pixel of the kernel is ignored.
Parameters:
input - The 2D array of pixel values representing the image.
kernel - The array representing the kernel.
w - The width of the image.
h - The height of the image.
x - The x coordinate of the centre of the 3x3 neighbourhood.
y - The y coordinate of the centre of the 3x3 neighbourhood.
Returns:
The maximum value.

minNeighbour

public static int minNeighbour(int[][] input,
                               int[] kernel,
                               int w,
                               int h,
                               int x,
                               int y)
Finds the minimum value from a 3x3 pixel neighbourhood overlaid with a 3x3 kernel (on/off). The centre pixel of the kernel is ignored.
Parameters:
input - The 2D array of pixel values representing the image.
kernel - The array representing the kernel.
w - The width of the image.
h - The height of the image.
x - The x coordinate of the centre of the 3x3 neighbourhood.
y - The y coordinate of the centre of the 3x3 neighbourhood.
Returns:
The minimum value.

generateInputArrays

public static int[][] generateInputArrays(int[] input,
                                          int width,
                                          int height)
Converts a 1D array to a 2D array.
Parameters:
input - The 1D array.
width - The width of the 2D array.
height - The height of the 2D array.
Returns:
The 2D array.

generateOutputArray

public static int[] generateOutputArray(int[][] outputArrays,
                                        int width,
                                        int height)
Converts a 2D array into a continuous 1D array.
Parameters:
outputArrays - The 2D array.
width - The width of the 2D array.
height - The height of the 2D array.
Returns:
The 1D array.

emptyKernel

public static boolean emptyKernel(int[] kernel)
True if the kernel consists of 8 0s surrounding the centre pixel.
Parameters:
kernel - The array containing the kernel values.
Returns:
True or false (true if all 0s).

smooth_image

public static int[] smooth_image(int[] input,
                                 int[] kernel,
                                 int width,
                                 int height)
Takes an image and a kernel and applies conservative smoothing to it.
Parameters:
input - The 1D array representing the image.
kernel - The array representing the kernel.
width - The width of the image.
height - The height of the image.
Returns:
The array representing the new smoothed image.

smooth

public int[][] smooth(int[][] inputArrays,
                      int[] kernel,
                      int width,
                      int height)

smoothImage

public int[] smoothImage(int[] input,
                         int width,
                         int height,
                         int[] kernel,
                         int kernelWidth,
                         int kernelHeight)