import java.lang.Math.*; import java.awt.*; import java.awt.Color.*; /** * The laplacian of Gaussian operator code. * * @author Simon Horne. */ public class Log{ /** * A convolution operator. */ Convolution convolution; /** * An array representing the input image. */ int [] input; /** * An array representing the output image. */ int [] output; /** * The input image width. */ public int width; /** * The input image height. */ public int height; /** * The output image width. */ public int width2; /** * The output image height. */ public int height2; /** * The 2D array representing the laplacian of gaussian kernel. */ double [][] logKernel; /** * The 2D array representing the input image. */ double [][] input2D; /** * The 2D array representing the input image. */ double [][] output2D; /** * The user selected theta value. */ double theta; /** * The user selected kernel size. */ int kernelSize; /** * Constructor that generates the kernel from the kernel size and theta. * * @param k The kernel size. * @param t the theta value. */ public Log(int k, double t){ convolution = new Convolution(); kernelSize = k; theta = t; logKernel = new double [k][k]; generateKernel(); } /** * Boolean tests for valid kernel construction from the kernel size and theta. * * @param t the theta value. */ public boolean kernelValid(double t){ double sum = 0; double max = logKernel[0][0]; for(int j=0;j0.1 || sum<-0.1 || t<=0.5 || (t/kernelSize)>0.09){ // too far from a good value return false; }else{ // adjust values slightly to get zero sum double delta = sum / (kernelSize * kernelSize); for(int j=0;j