import java.awt.color.ColorSpace; import java.awt.image.*; import java.awt.*; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import java.util.Scanner; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.event.*; public class Blob { public static final int gauss_width(double sigma) { // fill this in. Given a sigma, compute the appropriate width of a // Gaussian filter for that sigma. } public static final double[][] gauss(double sigma) { // Fill this in. Compute a 2D array that contains the appropriate // entries for a Gaussian filter. Use the formula for a Gaussian // to compute the values, and make sure that you normalize. } private static BufferedImage convertToGrayscale(BufferedImage source) { BufferedImage image = new BufferedImage( source.getWidth(), source.getHeight(), BufferedImage.TYPE_BYTE_GRAY ); Graphics g = image.getGraphics(); g.drawImage( source, 0, 0, null ); g.dispose(); return image; } private static BufferedImage readImage() { final String dir = "c:\\dwj\\matlab\\teach\\CMSC 426\\"; //The path needs to be changed from a machine to another BufferedImage img = null; BufferedImage imggray = null; String fname; Scanner scan = new Scanner (System.in); System.out.println ("Enter file name:"); fname = scan.nextLine(); File dirfile = new File(dir + fname); try { img = ImageIO.read(dirfile); } catch (IOException e) {System.out.println("Image not read"); } imggray = convertToGrayscale(img); imggray = img; return imggray; } public static double [][] myConvolve(double [][] img, int ih, int iw, int h, int w, double [][] filter){ // In order to find blobs, we must preserve all smoothed values as doubles. // Java's convolution converts to integers. This rounding off loses too much information // about local extrema. double [][] res_img = new double [iw][ih]; for (int i=0;i