import java.applet.*; import java.awt.*; import java.awt.image.*; import java.net.*; import java.util.*; import java.io.*; import java.lang.Math; import java.awt.Color.*; /** * MeanSmooth is an algorithm to meany smooth a binary image * using a 3x3 kernel. * * @author: Simon Horne. */ public class MeanSmooth extends Thread { /** * Default no-args constructor. */ public MeanSmooth() { } /** * Calculates the mean of a 3x3 pixel neighbourhood (including centre pixel). * * @param input the input image 2D array * @param kernel the kernel 2D array * @param w the image width * @param h the image height * @param x the x coordinate of the centre pixel of the array * @param y the y coordinate of the centre pixel of the array * @return the mean of the 9 pixels */ public static int meanNeighbour(int [][] input, int [][] kernel, int w, int h, int x, int y) { int sum = 0; int number = 0; for(int j=0;j<3;++j){ for(int i=0;i<3;++i){ if((kernel[i][j]==1) && ((x-1+i)>=0) && ((y-1+j)>=0) && ((x-1+i)0){ int [][] inputArrays = new int [width][height]; int [][] kernelArrays = new int [3][3]; int [][] outputArrays = new int [width][height]; for(int j=0;j128){ k=1; }else{ k=0; } kernelArrays[i][j] = k; } } for(int j=0;j