Commit in CDMS/src/CDMS/Partridge/ImageComparison on MAIN
ImageComparison.java+76added 1.1
ImageData.java+1-11.1 -> 1.2
PixelArray.java+1-11.3 -> 1.4
+78-2
1 added + 2 modified, total 3 files
Some bug fixes, crude main routine to test clustering

CDMS/src/CDMS/Partridge/ImageComparison
ImageComparison.java added at 1.1
diff -N ImageComparison.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ImageComparison.java	6 Sep 2010 20:30:43 -0000	1.1
@@ -0,0 +1,76 @@
+/*
+ * ImageComparison.java
+ */
+
+package CDMS.Partridge.ImageComparison;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import javax.imageio.ImageIO;
+
+/**
+ * Main program for comparing an optical scan of a CDMS detector with
+ * reference images and identifying defects.
+ *
+ * @author Richard Partridge
+ */
+public class ImageComparison {
+
+    public static void main(String[] args) throws IOException {
+
+        String fname1 = "c:/CDMS/IZipG47_Side1_PKG/IZipG47_Side1_PKG-6509.png";
+        String fname2 = "c:/CDMS/IZipG47_Side1_PKG/IZipG47_Side1_PKG-6510.png";
+        int id = 1;
+        double xc = 0.;
+        double yc = 0.;
+        double dx = 0.0014;
+        double dy = 0.0014;
+        int nrow = 480;
+        int ncol = 640;
+        ImageDescriptor image1 = new ImageDescriptor(fname1, id, xc, yc, dx, dy, nrow, ncol);
+        ImageDescriptor image2 = new ImageDescriptor(fname2, id, xc, yc, dx, dy, nrow, ncol);
+
+        Map<ImageDescriptor, ImageDescriptor> imagemap = new HashMap<ImageDescriptor, ImageDescriptor>();
+        imagemap.put(image1, image2);
+
+        int seed_threshold = 20;
+        int nbr_threshold = 10;
+        CompareImages compare = new CompareImages((double) seed_threshold, (double) nbr_threshold);
+
+        List<Cluster> clusters = compare.FindClusters(imagemap);
+
+        BufferedImage buf = new BufferedImage(640, 480, BufferedImage.TYPE_3BYTE_BGR);
+
+        PixelArray pixarray = image1.getPixelArray();
+        System.out.println("Number of clusters found: "+clusters.size());
+        int tot = 0;
+        for (Cluster clus : clusters) {
+//            System.out.println("Cluster size: "+clus.getClusterSize());
+            tot += clus.getClusterSize();
+            PixelArray mother = clus.getPixelArray();
+            Random rn = new Random();
+            int blue = rn.nextInt(255);
+            int green = rn.nextInt(255);
+            int red = rn.nextInt(255);
+            int rgb = (red << 16) + (green << 8) + blue;
+            for (long pixel : clus.getPixelList()) {
+                double x = mother.getX(pixel);
+                double y = mother.getY(pixel);
+                int row = pixarray.getRow(y);
+                int col = pixarray.getCol(x);
+                buf.setRGB(col, row, rgb);
+            }
+        }
+        System.out.println("Clustered pixels: "+tot);
+            File outfile = new File("c:/CDMS/ClusterTestSeed-seed"+seed_threshold+"nbr"+nbr_threshold+".png");
+
+            ImageIO.write(buf, "png", outfile);
+        
+    }
+
+}

CDMS/src/CDMS/Partridge/ImageComparison
ImageData.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- ImageData.java	4 Sep 2010 01:25:37 -0000	1.1
+++ ImageData.java	6 Sep 2010 20:30:43 -0000	1.2
@@ -32,7 +32,7 @@
      * @param image image
      */
     public ImageData(PixelArray pixarray, BufferedImage image) {
-        _pixarray = pixarray;
+        this(pixarray);
 
         //  Check that the image sizes match
         if (_pixarray.getNRow() != image.getHeight() || _pixarray.getNCol() != image.getWidth())

CDMS/src/CDMS/Partridge/ImageComparison
PixelArray.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- PixelArray.java	5 Sep 2010 20:40:03 -0000	1.3
+++ PixelArray.java	6 Sep 2010 20:30:43 -0000	1.4
@@ -376,7 +376,7 @@
         for (int irow=row-1; irow<=row+1; irow++) {
             if (irow < 0 || irow >= _nrow) continue;
             for (int icol=col-1; icol<=col+1; icol++) {
-                if (icol < 0 || icol > _ncol) continue;
+                if (icol < 0 || icol >= _ncol) continue;
                 nbrs.add(getPixel(irow, icol));
             }
         }
CVSspam 0.2.8