Hello!

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

Note that updates take place every 10 minutes, commits may not be seen immediately.
Working functionality for Layered segmentation. Done by Nikhil.
authorlingutln <lingutln@localhost>
Sat, 14 Jan 2012 00:40:47 +0000 (00:40 +0000)
committerlingutln <lingutln@localhost>
Sat, 14 Jan 2012 00:40:47 +0000 (00:40 +0000)
svn path=/; revision=263

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/SegmentationObject.java [deleted file]
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 dc688bee405a711310f6b3397a9d11719893141e..ba2a5e2ac25eeaef388e1025dfdf4017e3ec7c90 100644 (file)
@@ -833,7 +833,7 @@ public class SegmentationView extends Composite {
                        Tool.ZoomBestFit.action.setEnabled(canZoomBestFit());
                        if(view.getContext() != null)
                        {
-                               comboLabel.setEnabled((view.getContext().getSegmentObjects().size() > 0));
+                               comboLabel.setEnabled((view.getContext().getSegmentationMasks().size() > 0));
                        }
                        else
                        {
index 51831f2191594ccd00913719b0e45b7dbd57e364..a3a205b8684928e14d329d7f36858c59f7731781 100644 (file)
@@ -48,13 +48,14 @@ public class SegmentationContext {
        public static Point mouseClickedPoint;
        
        /**
-        * For storing independent Segmentation objects
+        * For storing independent Segmentation objects (i.e the masks which are formed into objects)
         */
-       private ArrayList<SegmentationMask> segmentationObjects;
+       private ArrayList<SegmentationMask> segmentationMaskObjects;
        
        // lazy create (use getters for these fields)
        private AnnotationManager annotations;
-       private SegmentationObject segmentObject;
+       // SegmentationMask which has not yet been turned into an Object
+       private SegmentationMask currentSegmentMask;
        private Image image;
        private Rectangle bounds;
 
@@ -70,7 +71,7 @@ public class SegmentationContext {
        private SegmentationContext(ImageData imageData, File file) {
                this.imageData = imageData;
                this.file = file;
-               segmentationObjects = new ArrayList<SegmentationMask>();
+               segmentationMaskObjects = new ArrayList<SegmentationMask>();
        }
 
        /**
@@ -144,11 +145,11 @@ public class SegmentationContext {
                // Makes needsHighlighting <code>False</code> for all the previous segments.
                disableAllSegments(false);
                // Set needsHighlighting <code>True</code> for the current segment.
-               segmentObject.enabled = true;
-               segmentationObjects.add(segmentObject);
+               currentSegmentMask.enabled = true;
+               segmentationMaskObjects.add(currentSegmentMask);
                
                // Making a new segmentationObject after storing the current SegmentationObject
-               segmentObject = null;
+               currentSegmentMask = null;
                annotations.clear();
        }
        
@@ -156,19 +157,19 @@ public class SegmentationContext {
         * @return A {@link SegmentationObject} instance. Returns the latest mask which hasn't yet turned into an object.
         */
        public SegmentationMask getMask() {
-               if (segmentObject == null) {
-                       segmentObject = new SegmentationObject(getBounds());
+               if (currentSegmentMask == null) {
+                       currentSegmentMask = new SegmentationMask(getBounds());
                }
-               return segmentObject;
+               return currentSegmentMask;
        }
        /**
         * All the masks excluding the current mask (i.e the mask which has not yet been made into a Segmentation object)
         * @return
         * A list of SegmentationMasks excluding the current mask which has not yet been made into a Segmentation object 
         */
-       public ArrayList<SegmentationMask> getSegmentObjects() {
+       public ArrayList<SegmentationMask> getSegmentationMasks() {
                
-               return segmentationObjects;
+               return segmentationMaskObjects;
        }
        
        /**
@@ -178,26 +179,23 @@ public class SegmentationContext {
         */
        public void enableClickedSegment(Point mouseClickedPoint) {
                
-               for(SegmentationMask segmentMaskObject : segmentationObjects)
+               for(SegmentationMask segmentMaskObject : segmentationMaskObjects)
                {
                        if(segmentMaskObject.getPixel(mouseClickedPoint.x, mouseClickedPoint.y) == 1)
                        {
                                // Disable all previous segments
                                disableAllSegments(false);
                                // Enable the currently clicked segment.
-                               segmentObject.enabled = true;
+                               segmentMaskObject.enabled = true;
                        }
                }
        }
                
        public void disableAllSegments(boolean value)
        {
-               for(SegmentationMask segmentObject : segmentationObjects)
+               for(SegmentationMask currentSegmentMask : segmentationMaskObjects)
                {
-                       if(segmentObject instanceof ie.dcu.segment.SegmentationObject)
-                       {
-                               ((ie.dcu.segment.SegmentationObject)segmentObject).enabled = value;
-                       }
+                       currentSegmentMask.enabled = value;
                }       
        }
        
@@ -350,7 +348,7 @@ public class SegmentationContext {
                        new FileInputStream(file)));
 
                ImageData imageData = null;
-               SegmentationObject segmentObject = null;
+               SegmentationMask segmentMask = null;
                AnnotationManager annotations = null;
 
                try {
@@ -381,7 +379,7 @@ public class SegmentationContext {
                        throw new IOException("No image found in context file");
                }
 
-               if (segmentObject == null) {
+               if (segmentMask == null) {
                        throw new IOException("No mask found in context file");
                }
 
@@ -391,7 +389,7 @@ public class SegmentationContext {
 
                SegmentationContext ctx = new SegmentationContext(imageData, file);
 
-               ctx.segmentObject = segmentObject;
+               ctx.currentSegmentMask = segmentMask;
                ctx.annotations = annotations;
 
                return ctx;
index 56bfacb9d88ad866bb95fb29df0d90067cda9dc0..473f1f329eea985de3303b9f8cb58440ffb060e7 100644 (file)
@@ -53,6 +53,15 @@ public class SegmentationMask extends ByteMatrix{
         */
        public final int height;
        
+       //The total number of layers formed.
+       public static int numberOfLayers;
+       
+       //The layering number of the segmentation mask.
+       public int layerNumber;
+       
+       //Whether the segment needs to be enabled(highlighted) or not ?
+       public boolean enabled;
+       
        /**
         * Create a segmentation mask using the specified dimensions. All pixels in
         * the mask are initially set to {@link SegmentationMask#UNKNOWN}.
diff --git a/Annotation/src/ie/dcu/segment/SegmentationObject.java b/Annotation/src/ie/dcu/segment/SegmentationObject.java
deleted file mode 100644 (file)
index a835d84..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-package ie.dcu.segment;
-
-import org.eclipse.swt.graphics.Rectangle;
-
-
-/**
- * Class that represents a independent segmentation mask.
- * 
- * A segmentation mask is a two dimensional matrix of byte values. It is used
- * to represents which pixels in an image that are part of the foreground, and 
- * which are part of the background.
- * 
- * @author Nikhil
- */
-
-public final class SegmentationObject extends SegmentationMask{
-
-       private static final long serialVersionUID = 8321845179859248904L;
-       
-       //The total number of layers formed.
-       public static int numberOfLayers;
-       
-       //The layering number of the segmentation mask.
-       public int layerNumber;
-       
-       //Whether the segment needs to be enabled(highlighted) or not ?
-       public boolean enabled;
-       
-       public SegmentationObject(int width, int height) {
-               super(width, height);
-               this.layerNumber = ++numberOfLayers;
-               this.enabled = false;
-               // TODO Auto-generated constructor stub
-       }
-       
-       public SegmentationObject(Rectangle bounds) {
-               this(bounds.width, bounds.height);
-               // TODO Auto-generated constructor stub
-       }
-               
-       
-}
index d92042979b1ff204b3bcd7d984ddc6313ca397cb..30e49db8df0575e7b40230b9ce5e0cbd01489d2f 100644 (file)
@@ -37,49 +37,46 @@ public class CombinedPainter implements SegmentationPainter {
 
                // Paint image
                gc.drawImage(ctx.getImage(), 0, 0);
-               
-               System.out.println("Number of mask objects"+ctx.getSegmentObjects().size());
+               int numberOfMaskObjects = ctx.getSegmentationMasks().size();
                // Paint all masks skipping the enabled mask.
-               if(ctx.getSegmentObjects().size() > 0)
+               if(numberOfMaskObjects > 0)
                {
                        // For drawing all the disabled masks.
-                       for(SegmentationMask segmentObject : ctx.getSegmentObjects())
+                       for(SegmentationMask segmentMask : ctx.getSegmentationMasks())
                        {
                                // Skipping the enabled segment from painting. We will paint the enabled segment at last.
-                               if(segmentObject instanceof ie.dcu.segment.SegmentationObject)
+                               /*if(segmentMask.layerNumber == 0)
+                               {
+                                       createVisibleMask(segmentMask,true);
+                                       gc.drawImage(maskImage, 0, 0);
+                               }*/
+                               if(segmentMask.enabled == true)
                                {
-                                       System.out.println("Enabled status : "+((ie.dcu.segment.SegmentationObject)segmentObject).enabled);
-                                       if(((ie.dcu.segment.SegmentationObject)segmentObject).enabled == true)
-                                       {
-                                               continue;
-                                       }
+                                       continue;
                                }
                                else
                                {
-                                       createVisibleMask(segmentObject,false);
+                                       createVisibleMask(segmentMask,false);
                                        gc.drawImage(maskImage, 0, 0);
                                }
                        }
-                       // Current mask which has not yet been made into an object
-                       createVisibleMask(ctx.getMask(),false);
-                       gc.drawImage(maskImage, 0, 0);
                }
                // Painting the enabled mask.
-               if(ctx.getSegmentObjects().size() > 0)
+               if(numberOfMaskObjects > 0)
                {
                        // For drawing all the previous masks.
-                       for(SegmentationMask segmentObject : ctx.getSegmentObjects())
+                       for(SegmentationMask segmentMask : ctx.getSegmentationMasks())
                        {
                                // Blending of background pixel values while pasting the last mask only
-                               if(segmentObject instanceof ie.dcu.segment.SegmentationObject)
+                               if(segmentMask.enabled == true)
                                {
-                                       if(((ie.dcu.segment.SegmentationObject)segmentObject).enabled == true)
-                                       {
-                                               createVisibleMask(segmentObject,true);
-                                               gc.drawImage(maskImage, 0, 0);
-                                       }
+                                       createVisibleMask(segmentMask,true);
+                                       gc.drawImage(maskImage, 0, 0);
                                }
                        }
+                       // Current mask which has not yet been made into an object
+                       createVisibleMask(ctx.getMask(),false);
+                       gc.drawImage(maskImage, 0, 0);
                }
                // Very initial mask, which has not yet been turned into an object.
                else
@@ -87,7 +84,6 @@ public class CombinedPainter implements SegmentationPainter {
                        createVisibleMask(ctx.getMask(),true);
                        gc.drawImage(maskImage, 0, 0);
                }
-                               
                // Paint all annotations
                ctx.getAnnotations().paint(im);
                
@@ -122,7 +118,7 @@ public class CombinedPainter implements SegmentationPainter {
                                        index = 2;
                                        break;
                                case SegmentationMask.FOREGROUND:
-                                       alpha = (byte) 128;
+                                       alpha = (byte) 255;
                                        index = 1;
                                        break;
                                default: