Hello!

To see the file structure, click on "tree".

Note that updates take place every 10 minutes, commits may not be seen immediately.
svn path=/; revision=251
authorlingutln <lingutln@localhost>
Thu, 5 Jan 2012 07:53:37 +0000 (07:53 +0000)
committerlingutln <lingutln@localhost>
Thu, 5 Jan 2012 07:53:37 +0000 (07:53 +0000)
Annotation/.classpath
Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java
Annotation/src/ie/dcu/segment/SegmentationContext.java
Annotation/src/ie/dcu/segment/SegmentationMask.java
Annotation/src/ie/dcu/segment/painters/CombinedPainter.java

index 22412b6c9a2c02f608af7c008e1447f0c9cabf62..61c9bd15a41fc425ceb98dd42ebd3e345b58f214 100644 (file)
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry excluding="src/" kind="src" path=""/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-       <classpathentry kind="lib" path="/home/lingutln/workspace/Annotation/library/commons-lang3-3.1.jar"/>
-       <classpathentry kind="lib" path="/home/lingutln/workspace/Annotation/library/jface.jar"/>
-       <classpathentry kind="lib" path="/home/lingutln/workspace/Annotation/library/json.jar"/>
-       <classpathentry kind="lib" path="/home/lingutln/workspace/Annotation/library/swt-gtk-64.jar"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry excluding="src/" kind="src" path=""/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+       <classpathentry kind="lib" path="C:/Users/Nikhil/workspace/Annotation/library/commons-lang3-3.1.jar"/>\r
+       <classpathentry kind="lib" path="C:/Users/Nikhil/workspace/Annotation/library/jface.jar"/>\r
+       <classpathentry kind="lib" path="C:/Users/Nikhil/workspace/Annotation/library/json.jar"/>\r
+       <classpathentry kind="lib" path="C:/Users/Nikhil/workspace/image_annotation/lib/swt-win.jar"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
index d955db7b424f47c167d688595463041cf1e2a830..8e7f715bf72b2cbd403741feed1b155a61c32571 100644 (file)
@@ -478,7 +478,7 @@ public class SegmentationView extends Composite {
        
        public void formSegmetationObject() {
        
-               view.getContext().getMask().formSegmentationObject();
+               view.getContext().formSegmentationObject();
        }
        
        
index 229d3c2d0f9e630f65784161b9dfcbb6c46bbb9b..333cffe286446bb5f3e3a2102e7e985ea4e96e11 100644 (file)
@@ -6,6 +6,7 @@ import ie.dcu.swt.SwtUtils;
 import ie.dcu.util.FileUtils;
 
 import java.io.*;
+import java.util.ArrayList;
 import java.util.zip.*;
 
 import org.eclipse.swt.SWT;
@@ -40,7 +41,12 @@ public class SegmentationContext {
         * either the original image or a segmentation context file
         */
        private File file;
-
+       
+       /**
+        * For storing independent Segmentation objects
+        */
+       private ArrayList<SegmentationMask> maskObjects;
+       
        // lazy create (use getters for these fields)
        private AnnotationManager annotations;
        private SegmentationMask mask;
@@ -59,6 +65,7 @@ public class SegmentationContext {
        private SegmentationContext(ImageData imageData, File file) {
                this.imageData = imageData;
                this.file = file;
+               maskObjects = new ArrayList<SegmentationMask>();
        }
 
        /**
@@ -127,7 +134,24 @@ public class SegmentationContext {
                }
                return bounds;
        }
-
+       
+       public final void formSegmentationObject() {
+               maskObjects.add(mask);
+               System.out.println(""+maskObjects.get(0));
+               SegmentationMask tempMask = maskObjects.get(0);
+               mask = new SegmentationMask(imageData.width, imageData.height);
+               if(tempMask.equals(maskObjects.get(0)))
+               {
+                       System.out.println("Equal");
+               }
+               else
+               {
+                       System.out.println("Not equal");
+               }
+               System.out.println(""+maskObjects.get(0));
+       //      System.out.println("Mask objects size : "+maskObjects.size());
+       }
+       
        /**
         * Returns the current segmentation mask.
         * 
@@ -139,6 +163,14 @@ public class SegmentationContext {
                }
                return mask;
        }
+       
+       public ArrayList<SegmentationMask> getMasks() {
+               if (maskObjects.size() == 0 && mask == null) {
+                       mask = new SegmentationMask(getBounds());
+                       System.out.println("Mask coming as "+mask);
+               }
+                       return maskObjects;
+               }
 
        /**
         * Returns the current image being segmented. This method returns an an SWT
@@ -248,7 +280,7 @@ public class SegmentationContext {
                        out.putNextEntry(entry);
 
                        // Save the mask
-                       getMask().save(out);
+                       //getMask().save(out);
 
                        // End the entry
                        out.closeEntry();
index c3e820af333aab8511c288a32e38698b2e0fdcc9..2d0095a0b53fed8d23629f19f564aecf4c943a9a 100644 (file)
@@ -3,7 +3,6 @@ package ie.dcu.segment;
 import ie.dcu.matrix.ByteMatrix;
 
 import java.io.*;
-import java.util.ArrayList;
 
 import org.eclipse.swt.*;
 import org.eclipse.swt.graphics.*;
@@ -55,11 +54,6 @@ public class SegmentationMask extends ByteMatrix implements Cloneable{
         */
        public final int height;
        
-       /**
-        * For storing independent Segmentation objects
-        */
-       private ArrayList<ByteMatrix> objects;
-       
        /**
         * Create a segmentation mask using the specified dimensions. All pixels in
         * the mask are initially set to {@link SegmentationMask#UNKNOWN}.
@@ -73,7 +67,6 @@ public class SegmentationMask extends ByteMatrix implements Cloneable{
                super(height, width);
                this.width = width;
                this.height = height;
-               objects = new ArrayList<ByteMatrix>();
                clear();
        }
        
@@ -100,16 +93,7 @@ public class SegmentationMask extends ByteMatrix implements Cloneable{
        /**
         * forms a segmentation object and stores it in an arrayList
         */
-       public final void formSegmentationObject() {
-               ByteMatrix object = new SegmentationObject(getBounds());
-               object = new SegmentationMask(height, height).clone();
-               objects.add(object);
-               System.out.println("Object size : "+objects.size());
-               for(int i = 0; i<objects.size();i++)
-               {
-                       System.out.println("Layer number is "+(SegmentationObject)objects.get(i));
-               }
-       }
+
 
        /**
         * Get the offset of pixel (x, y).
index 15040a0e27ebfb05cdbcfe8b2c13036b7d90cea8..aa71de01e517256dae27c5936e8f3183a13505fb 100644 (file)
@@ -1,5 +1,7 @@
 package ie.dcu.segment.painters;
 
+import java.util.ArrayList;
+
 import ie.dcu.segment.*;
 import ie.dcu.swt.ObservableImage;
 
@@ -39,7 +41,12 @@ public class CombinedPainter implements SegmentationPainter {
                gc.drawImage(ctx.getImage(), 0, 0);
 
                // Paint mask
-               createVisibleMask(ctx.getMask());
+               // To be removed
+               if(ctx.getMasks().size() == 0)
+               {
+                       maskData = createMaskData(ctx.getBounds());
+               }
+               createVisibleMask(ctx.getMasks());
                gc.drawImage(maskImage, 0, 0);
 
                // Paint all annotations
@@ -50,45 +57,47 @@ public class CombinedPainter implements SegmentationPainter {
        }
 
 
-       private void createVisibleMask(SegmentationMask mask) {
+       private void createVisibleMask(ArrayList<SegmentationMask> masks) {
                dispose();
-               
-               if (isNewMaskDataRequired(mask.getBounds())) {
-                       maskData = createMaskData(mask.getBounds());
-               } 
-               
-               // Blit in pixels
-               for (int y = 0, i = 0; y < mask.height; y++) {
-                       int rowOffset = y * maskData.bytesPerLine;
-                       for (int x = 0; x < mask.width; x++) {
-                               byte alpha, index;
-                               
-                               switch (mask.values[i]) {
-                               case SegmentationMask.BACKGROUND:
-                                       alpha = (byte) 128;
-                                       index = 2;
-                                       break;
-                               case SegmentationMask.FOREGROUND:
-                                       alpha = (byte) 128;
-                                       index = 1;
-                                       break;
-                               default:
-                                       alpha = 0;
-                                       index = 0;
-                                       break;
+               System.out.println("In loop"+masks.size());
+               for (SegmentationMask mask : masks) {
+                       if (isNewMaskDataRequired(mask.getBounds())) {
+                               maskData = createMaskData(mask.getBounds());
+                       } 
+                       
+                       // Blit in pixels
+                       for (int y = 0, i = 0; y < mask.height; y++) {
+                               int rowOffset = y * maskData.bytesPerLine;
+                               for (int x = 0; x < mask.width; x++) {
+                                       byte alpha, index;
+                                       
+                                       switch (mask.values[i]) {
+                                       case SegmentationMask.BACKGROUND:
+                                               alpha = (byte) 128;
+                                               index = 2;
+                                               break;
+                                       case SegmentationMask.FOREGROUND:
+                                               alpha = (byte) 128;
+                                               index = 1;
+                                               break;
+                                       default:
+                                               alpha = 0;
+                                               index = 0;
+                                               break;
+                                       }
+                                                                       
+                                       // The SWT ImageData buffer doesn't usually have it's rows aligned
+                                       // contiguously in memory (i.e. there are > width bytes per scan-line in
+                                       // the buffer), so we can't directly copy in at the same index as the
+                                       // mask.
+                                       maskData.data[x + rowOffset] = index;
+                                       
+                                       // However, the alpha data is always aligned correctly
+                                       maskData.alphaData[i] = alpha;
+                                       
+                                       // Next location in the mask
+                                       i++;
                                }
-                                                               
-                               // The SWT ImageData buffer doesn't usually have it's rows aligned
-                               // contiguously in memory (i.e. there are > width bytes per scan-line in
-                               // the buffer), so we can't directly copy in at the same index as the
-                               // mask.
-                               maskData.data[x + rowOffset] = index;
-                               
-                               // However, the alpha data is always aligned correctly
-                               maskData.alphaData[i] = alpha;
-                               
-                               // Next location in the mask
-                               i++;
                        }
                }