Class MeanSmooth
java.lang.Object
|
+--java.lang.Thread
|
+--MeanSmooth
- Direct Known Subclasses:
- Unsharp
- public class MeanSmooth
- extends java.lang.Thread
MeanSmooth is an algorithm to meany smooth a binary image
using a 3x3 kernel.
Fields inherited from class java.lang.Thread |
MAX_PRIORITY,
MIN_PRIORITY,
NORM_PRIORITY |
Constructor Summary |
MeanSmooth()
Default no-args constructor. |
Method Summary |
static int[][] |
generateInputArrays(int[] input,
int width,
int height)
Converts a 1D array into a 2D array. |
static int[] |
generateOutputArray(int[][] outputArrays,
int width,
int height)
Converts a 2D array into a 1D array. |
static int |
meanNeighbour(int[][] input,
int[][] kernel,
int w,
int h,
int x,
int y)
Calculates the mean of a 3x3 pixel neighbourhood (including centre pixel). |
static int[] |
smooth_image(int[] input,
int[] kernel,
int width,
int height,
int iterations)
Takes an image and a kernel and applies the specified number of
mean smoothings to it. |
static int[][] |
smooth(int[][] input,
int[][] kernel,
int width,
int height,
int iterations)
Takes an image in 2D array form and smoothes it according to the kernel. |
static int[] |
smoothImage(int[] input,
int width,
int height,
int[] kernel,
int kernelWidth,
int kernelHeight,
int iterations)
Takes an image and a kernel and applies the specified number of
mean smoothings to it. |
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 |
MeanSmooth
public MeanSmooth()
- Default no-args constructor.
meanNeighbour
public static int meanNeighbour(int[][] input,
int[][] kernel,
int w,
int h,
int x,
int y)
- Calculates the mean of a 3x3 pixel neighbourhood (including centre pixel).
- Parameters:
input
- the input image 2D arraykernel
- the kernel 2D arrayw
- the image widthh
- the image heightx
- the x coordinate of the centre pixel of the arrayy
- the y coordinate of the centre pixel of the array- Returns:
- the mean of the 9 pixels
generateInputArrays
public static int[][] generateInputArrays(int[] input,
int width,
int height)
- Converts a 1D array into a 2D array.
- Parameters:
input
- the input image 1D arraywidth
- of the input imageheight
- of the input image- Returns:
- the newly created 2D array [width][height]
generateOutputArray
public static int[] generateOutputArray(int[][] outputArrays,
int width,
int height)
- Converts a 2D array into a 1D array.
- Parameters:
outputArrays
- the image 2D arraywidth
- of the imageheight
- of the image- Returns:
- the new 1D array [width*height]
smooth
public static int[][] smooth(int[][] input,
int[][] kernel,
int width,
int height,
int iterations)
- Takes an image in 2D array form and smoothes it according to the kernel.
- Parameters:
input
- the input imagewidth
- of the input imageheight
- of the output imageiterations
- to be performed- Returns:
- the new smoothed image 2D array
smooth_image
public static int[] smooth_image(int[] input,
int[] kernel,
int width,
int height,
int iterations)
- Takes an image and a kernel and applies the specified number of
mean smoothings to it.
- Parameters:
input
- the input image 1D arraykernel
- the kernel 1D array 9 elements (3x3)width
- of the input imageheight
- of the output imageiterations
- to be performed- Returns:
- the new smoothed image 1D array
smoothImage
public static int[] smoothImage(int[] input,
int width,
int height,
int[] kernel,
int kernelWidth,
int kernelHeight,
int iterations)
throws InputException
- Takes an image and a kernel and applies the specified number of
mean smoothings to it.
- Parameters:
input
- the input image 1D arraykernel
- the kernel 1D array 9 elements (3x3)width
- of the input imageheight
- of the output imageiterations
- to be performed- Returns:
- the new smoothed image 1D array