import java.awt.*; import java.awt.image.*; import java.applet.*; import java.net.*; import java.io.*; import java.lang.Math; import java.util.*; // additional stuff for swing import java.awt.event.*; import javax.swing.*; import javax.swing.JApplet; import javax.imageio.*; public class gaussianFilter { int[] input; int[] output; float[] template; int progress; double sigma; int templateSize; int width; int height; public void gaussianFilter() { progress=0; } public void init(int[] original, int sigmaIn, int tempSize, int widthIn, int heightIn) { if((tempSize%2)==0) templateSize=tempSize-1; sigma=(double)sigmaIn; templateSize=tempSize; width=widthIn; height=heightIn; input = new int[width*height]; output = new int[width*height]; template = new float[templateSize*templateSize]; input=original; } public void init(int[] original, double sigmaIn, int tempSize, int widthIn, int heightIn) { if((tempSize%2)==0) templateSize=tempSize-1; sigma=sigmaIn; templateSize=tempSize; width=widthIn; height=heightIn; input = new int[width*height]; output = new int[width*height]; template = new float[templateSize*templateSize]; input=original; } public void generateTemplate() { float center=(templateSize-1)/2; float total=0; for(int x = 0; x < templateSize; x++) { for(int y = 0; y < templateSize; y++) { template[x*templateSize+y] = (float)(1/(float)(2*Math.PI*sigma*sigma))*(float)Math.exp((float)(-((x-center)*(x-center)+(y-center)*(y-center))/(2*sigma*sigma))); total+=template[x*templateSize+y]; } } for(int x = 0; x < templateSize; x++) { for(int y = 0; y < templateSize; y++) { template[x*templateSize+y] = template[x*templateSize+y]/total; } } } public int[] process() { float sum; progress=0; int outputsmaller[] = new int[(width-(templateSize-1))*(height-(templateSize-1))]; for(int x=(templateSize-1)/2; x