/** * A simple ImageJ plugin to find stars in a CCD image. * Glen Cowan, RHUL Physics * 16 November, 2003 */ import ij.*; import ij.process.*; import ij.gui.*; import ij.plugin.filter.*; import java.awt.*; import java.awt.image.*; public class Star_Finder implements PlugInFilter { ImagePlus imp; // make imp available to run method public int setup(String arg, ImagePlus imp) { this.imp = imp; return DOES_ALL; // claim to work on all image types } public void run(ImageProcessor ip) { // Get info about image and set a threshold for star detection. // Default gain is for ST-7E CCD; currently set 5 sigma threshold. double gain = IJ.getNumber("enter gain (e-/ADU)", 2.3); int ny = ip.getHeight(); int nx = ip.getWidth(); IJ.write("nx = " + nx); IJ.write("ny = " + ny); IJ.write("total pixels = " + nx*ny); ImageStatistics istat = imp.getStatistics(); double mode = istat.dmode; System.out.println("mode = " + mode); IJ.write ("mode = " + mode); int threshold = (int)(mode + 5*Math.sqrt(mode/gain)); IJ.write("threshold = " + threshold); // Loop over the pixels, for now just count pixels over threshold. // Method getPixel returns counts in ADU. int numPixelsOverThresh = 0; for (int j=0; j threshold ) { System.out.println(i + "\t" + j + "\t" + c); numPixelsOverThresh++; // add your code here to find stars } } } IJ.write("numPixelsOverThresh = " + numPixelsOverThresh); } // end of run } // end of Star_Finder