Hello!

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

Note that updates take place every 10 minutes, commits may not be seen immediately.
Latest Commits. Done by Nikhil.
authorlingutln <lingutln@localhost>
Mon, 12 Mar 2012 18:56:49 +0000 (18:56 +0000)
committerlingutln <lingutln@localhost>
Mon, 12 Mar 2012 18:56:49 +0000 (18:56 +0000)
svn path=/; revision=310

Annotation/resources/config/actions.properties
Annotation/src/ie/dcu/apps/ist/actions/OpenAction.java
Annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java
Annotation/src/ie/dcu/segment/SegmentationContext.java
Annotation/src/ie/dcu/segment/SegmentationMask.java
Annotation/src/ie/dcu/segment/annotate/AnnotationManager.java

index f2ddcb0731f312d6b58479ba9210190b98aa7c02..ecffedd1f7a171c8cccdbc2cc4269f68e9e3ddbe 100644 (file)
@@ -1,7 +1,7 @@
 
 OpenAction.dialog.text=Open an image or saved context
-OpenAction.dialog.filter.exts=*.jpg;*.jpeg;*.png;*.gif;*.bmp;*.ctx
-OpenAction.dialog.filter.text=Image and Context Files
+OpenAction.dialog.filter.exts=*.jpg;*.jpeg;*.png;*.gif;*.bmp;*.ctx;*.imgmap
+OpenAction.dialog.filter.text=Image,imagemap and Context Files
 
 SaveAction.dialog.text=Save Segmentation Context
 SaveAction.dialog.filter.exts=*.ctx
index 5c956b668901e56d46dd7a6c76d22d73558b878f..797723aae57739938728f075fef0bac98709ee45 100644 (file)
@@ -17,6 +17,11 @@ public class OpenAction extends AppAction {
 
        private FileDialog dialog;
        
+       /**
+        * The file extension given to a this object when it is saved on a disk
+        */
+       public static final String IMGMAP_EXTENSION = ".imgmap";
+       
        public OpenAction(ActionManager m) {
                super(m);
        }
@@ -39,8 +44,14 @@ public class OpenAction extends AppAction {
                                // Load context
                                window.setContext(SegmentationContext.load(file));
                                status("Opened segmentation context %s successfully", name);
-                       } else {
-                       
+                       }
+                       else if (name.toLowerCase().endsWith(IMGMAP_EXTENSION))
+                       {
+                               // Load Imagemap from Disk
+                               window.setContext(SegmentationContext.loadImageMap(file));
+                               status("Opened segmentation context %s successfully", name);
+                       }                       
+                       else {
                                // Create context
                                window.setContext(SegmentationContext.create(file));
                                status("Opened image file %s successfully", name);
@@ -83,7 +94,7 @@ public class OpenAction extends AppAction {
                if (dialog == null) {
                        dialog = new FileDialog(window.getShell(), SWT.OPEN | SWT.SHEET);
                        dialog.setText(property("OpenAction.dialog.text"));
-                       //dialog.setFilterExtensions(getFilters());
+                       dialog.setFilterExtensions(getFilters());
                        dialog.setFilterNames(getFilterNames());
                }
        }
index 9017f93d35bc7fdd9010b88d0004b2bf69bf0818..42fcf05037576b2a5ff1b806ecf50bb7fb941a52 100644 (file)
@@ -169,6 +169,13 @@ public class Exporter {
                                
                                                // writing to the folder
                                                ImageIO.write(im, "png", output);
+                                               
+                                               // Saving the marked up annotations 
+                                               ZipEntry markupData = new ZipEntry("markup-"+mask.layerNumber+".dat");
+                                               
+                                               out.putNextEntry(markupData);
+                                               
+                                               mask.getAnnotations().save(out);
                                        }
                                }
                                
@@ -236,7 +243,8 @@ public class Exporter {
                
                if (effect != null) {
                        
-                       String basename = FileUtils.removeExtension(imageFile);
+                       //String basename = FileUtils.removeExtension(imageFile);
+                       String basename = "segment";
                        for (int i = 0; i < trace.size(); i++) {
                                String filename = String.format("%s-%d.png", basename, layerNumber);
                                preloads.add(filename);
index b7c095064d63387123087032aff2045f4c0282ea..094d46e66e3726c20e3268aa18229200864af277 100644 (file)
@@ -146,6 +146,7 @@ public class SegmentationContext {
                disableAllSegments();
                // Set needsHighlighting <code>True</code> for the current segment.
                currentSegmentMask.enabled = true;
+               currentSegmentMask.setAnnotations(getAnnotations());
                segmentationMaskObjects.add(currentSegmentMask);
                // Making a new segmentationObject after storing the current SegmentationObject
                currentSegmentMask = null;
@@ -355,6 +356,7 @@ public class SegmentationContext {
                        out.putNextEntry(entry);
 
                        // Store the markup
+                       System.out.println("Near seg context save");
                        getAnnotations().save(out);
 
                        // close entry
@@ -368,6 +370,7 @@ public class SegmentationContext {
                        // Set new filename
                        this.file = file;
                }
+               System.out.println("After all the saving is done");
        }
 
        /**
@@ -431,6 +434,77 @@ public class SegmentationContext {
                return ctx;
        }
 
+       
+       
+       /**
+        * Load a ImageMap object from the disk.
+        * 
+        * @param file
+        *        A file containing the Imagemap.
+        * @return A new segmentation context object.
+        * @throws IOException
+        *         If there is an error loading the segmentation context file.
+        */
+       public static SegmentationContext loadImageMap(File file) throws IOException {
+               ZipInputStream in = new ZipInputStream(new BufferedInputStream(
+                       new FileInputStream(file)));
+               
+               ImageData imageData = null;
+               SegmentationMask segmentMask = null;
+               AnnotationManager annotations = null;
+
+               try {
+                       ZipEntry entry;
+                       while ((entry = in.getNextEntry()) != null) {
+
+                               String name = entry.getName();
+
+                               if (name.equals("image.png")) {
+                                       System.out.println("Loading Original image");
+                                       imageData = SwtUtils.loadImageData(in);
+
+                               } else if (name.startsWith("segment")) {
+                                       String[] temp;
+                                       temp = name.split("-");
+                                       System.out.println("Temp array coming as "+temp[0]+" and "+temp[1]);
+                                       //segmentObject = (SegmentationObject) SegmentationMask.read(in);
+
+                               } else if (name.equals("markup.dat")) {
+                                       annotations = new AnnotationManager();
+                                       annotations.load(in);
+                               }
+                               System.out.println("File name is : "+name);
+
+                               in.closeEntry();
+                       }
+
+               } finally {
+                       in.close();
+               }
+
+               if (imageData == null) {
+                       throw new IOException("No image found in context file");
+               }
+
+               if (segmentMask == null) {
+                       throw new IOException("No mask found in context file");
+               }
+
+               if (annotations == null) {
+                       throw new IOException("No annotations found in context file");
+               }
+
+               SegmentationContext ctx = new SegmentationContext(imageData, file);
+
+               ctx.currentSegmentMask = segmentMask;
+               ctx.annotations = annotations;
+
+               return ctx;
+       }
+
+       
+       
+       
        /**
         * Static method that checks if the given file appears to be a segmentation
         * context file.
index bc9c35ef1b038f63f034c389978ab0cb49e8d327..32ba6e1d6680a2ae642b49d8a88890eb9b5f19c4 100644 (file)
@@ -1,6 +1,7 @@
 package ie.dcu.segment;
 
 import ie.dcu.matrix.ByteMatrix;
+import ie.dcu.segment.annotate.AnnotationManager;
 
 import java.io.*;
 
@@ -51,6 +52,9 @@ public class SegmentationMask extends ByteMatrix{
         * The height of the segmentation mask.
         */
        public final int height;
+
+       // Annotations associated with Mask objects
+       private AnnotationManager annotations;
        
        //The total number of layers formed.
        public static int numberOfLayers;
@@ -213,6 +217,16 @@ public class SegmentationMask extends ByteMatrix{
                return new Rectangle(0, 0, width, height);
        }
        
+       public void setAnnotations(AnnotationManager annotations) {
+               this.annotations = annotations;
+       }
+       
+       public AnnotationManager getAnnotations() {
+               if (annotations == null) {
+                       annotations = new AnnotationManager();
+               }
+               return annotations;
+       }
        
        /**
         * Returns a string representation of the mask.
index 92ff8e43ed9f488bda3e1920a11aa8758b9b20a3..5cdbb968f16dfaedd98844157a9da06ea1c8855c 100644 (file)
@@ -261,7 +261,6 @@ public class AnnotationManager {
        }
        
        public void save(OutputStream o) throws IOException {
-               
                DataOutputStream out = new DataOutputStream(
                                new BufferedOutputStream(o));