/* JMF_Edge_Analyzer.java Glen Cowan RHUL Physics Department January 2007 This ImageJ plugin unpacks the R, G ad B pixel values of an image and sums them to form a single intensity. The values are put into an array. */ import ij.*; import ij.process.*; import ij.gui.*; import ij.io.*; import ij.plugin.filter.*; import java.awt.*; import java.awt.image.*; import java.util.*; import java.math.*; import java.io.*; public class Edge_Analyzer 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) { // Unpack pixel contents into array; reorder vertical direction to increase upwards. int ncol = ip.getWidth(); int nrow = ip.getHeight(); System.out.println("ncol, nrow = " + ncol + " " + nrow); int[] pixels = (int[])ip.getPixels(); int[][] intensity = new int[nrow][ncol]; int c, r, g, b; for(int k=0; k>16; g = (c&0xff00)>>8; b = c&0xff; intensity[nrow-j-1][k] = r + g + b; System.out.println(k + " " + j + " " + intensity[j][k]); } } // do more analysis here on the intensity array, e.g., to find edges. } // end of run } // end of class Edge_Analyzer