Hello!

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

Note that updates take place every 10 minutes, commits may not be seen immediately.
Trac #197 and 282
authorpreecej <preecej@localhost>
Wed, 10 Oct 2012 23:10:35 +0000 (23:10 +0000)
committerpreecej <preecej@localhost>
Wed, 10 Oct 2012 23:10:35 +0000 (23:10 +0000)
svn path=/; revision=398

Annotation/src/ie/dcu/apps/ist/Application.java
Annotation/src/ie/dcu/apps/ist/actions/ExportImageMapAction.java
Annotation/src/ie/dcu/apps/ist/actions/OpenAction.java
Annotation/src/ie/dcu/apps/ist/actions/SaveAction.java
Annotation/src/ie/dcu/apps/ist/export/imagemap/Exporter.java
Annotation/src/ie/dcu/segment/SegmentationContext.java

index e8aa61ec84cab368c696558e89beeaa6c6dbc651..2442867be623bf2288e643be74da68ffb916adf8 100644 (file)
@@ -19,7 +19,7 @@ import static ie.dcu.util.OsUtils.*;
 public class Application {
        public static final String APP_ID   = "ist";
        public static final String APP_NAME = "SIA (Semantic Image Annotator)";
-       public static final String APP_VERSION  = "0.2 (beta)";
+       public static final String APP_VERSION  = "0.2.1 (beta)";
        public static final String APP_RESOURCE_DIR = "resources";
        
        /**
index be8654ca96d14e8f0991b0cf44595614764ac5c0..d5481d722fe17724fad522c924379b677ff1c071 100644 (file)
@@ -43,7 +43,7 @@ public class ExportImageMapAction extends AppAction{
                                
                                        BufferedImage image = ImageConverter.convert(ctx.getImageData());
                                        // Setup exporter
-                                       Exporter exporter = new Exporter(image);
+                                       Exporter exporter = new Exporter(image, ctx);
                                        exporter.setEffect(result.effect);
                                        exporter.setHtmlFile(result.html);
                                        
index 40a1f12af37e9cfba1b0978ead66b39a35a5746d..54568f83b2a3848422544f9bad98782d2cf141cb 100644 (file)
@@ -45,7 +45,7 @@ public class OpenAction extends AppAction {
                        // clear the decks
                        window.getView().resetView();
 
-                       if (SegmentationContext.isContextFile(file)) {
+                       if (SegmentationContext.isContextFile(file)) { // JP - minority case (opening an zip file to re-annotate)
                                // Load context
                                window.setContext(SegmentationContext.load(file));
                                status("Opened segmentation context %s successfully", name);
@@ -56,7 +56,7 @@ public class OpenAction extends AppAction {
                                window.setContext(SegmentationContext.loadImageMap(file));
                                status("Opened segmentation context %s successfully", name);
                        }                       
-                       else { // JP - majority of cases (opening an img or zip file to annotate)
+                       else { // JP - majority of cases (opening an img file to annotate)
                                // Create context
                                window.setContext(SegmentationContext.create(file));
                                status("Opened image file %s successfully", name);
index 47fa3a51273ead44a632546c10d0f977843833cc..6e60aba89ab240da9867288af7e57da5c98e703a 100644 (file)
@@ -49,7 +49,7 @@ public class SaveAction extends AppAction {
                                BufferedImage image = ImageConverter.convert(ctx.getImageData());
 
                                // Setup exporter
-                               Exporter exporter = new Exporter(image);
+                               Exporter exporter = new Exporter(image, ctx);
 
                                // save the annotated zip file
                                String zipFile = result.zipFile; 
@@ -100,7 +100,7 @@ public class SaveAction extends AppAction {
                                BufferedImage image = ImageConverter.convert(ctx.getImageData());
 
                                // Setup exporter
-                               Exporter exporter = new Exporter(image);
+                               Exporter exporter = new Exporter(image, ctx);
 
                                // save the annotated zip file
                                String zipFile = result.zipFile; 
index b8d89cdb6eed75091902b815dbbf905fb029a118..7eb8618bd5e9d0ba14e873f8503b6bd8522017b5 100644 (file)
@@ -1,7 +1,9 @@
 package ie.dcu.apps.ist.export.imagemap;
 
+import ie.dcu.apps.ist.Application;
 import ie.dcu.apps.ist.views.SegmentationView;
 import ie.dcu.image.ContourTracer;
+import ie.dcu.segment.SegmentationContext;
 import ie.dcu.segment.SegmentationMask;
 
 import java.awt.Polygon;
@@ -35,12 +37,14 @@ public class Exporter {
        private String zipFile = "";
        private String imageFile = "image.png";
        private String imageName = "image";
+       private String origImageFileName = "";
        private String objectDescription = "";
        private String objectLink = "";
        private AreaShape exportShape = AreaShape.Polygon;
        
-       public Exporter(BufferedImage image) {
+       public Exporter(BufferedImage image, SegmentationContext ctx) {
                this.image = image;
+               this.origImageFileName = ctx.getFile().getName();
        }
        
        public RolloverEffect getEffect() {
@@ -127,7 +131,7 @@ public class Exporter {
                
                try {
                        // Low (fast) compression.. most of data is PNG compressed anyway
-                       out.setLevel(0);
+                       out.setLevel(9);
                        out.flush();
                        // Create an entry for the image
                        ZipEntry entryImage = new ZipEntry(imageFile);
@@ -172,7 +176,7 @@ public class Exporter {
                                                }
                                                
                                                // Low (fast) compression.. most of data is PNG compressed anyway
-                                               out.setLevel(0);
+                                               //out.setLevel(0);
                                                
                                                // Create an entry for the image
                                                ZipEntry entryMaskImage = new ZipEntry(preloads.get(i).toString());
@@ -240,8 +244,8 @@ public class Exporter {
                }
                finally 
                {
-                       // Close
-                       out.close();
+                       out.flush();
+                       out.close(); // close the output zip file stream (makes the zip file) 
                }
        }
        
@@ -249,12 +253,7 @@ public class Exporter {
        {
                DataOutputStream out = new DataOutputStream(new BufferedOutputStream(o));
                byte[] intensityValues = mask.values;
-               boolean[] values = new boolean[intensityValues.length];
-               for(int x =0; x < intensityValues.length;x++)
-               {
-                       values[x] = (intensityValues[x] == 2 ? false:true);
-                       out.writeBoolean(values[x]);
-               }
+               out.write(intensityValues);
        }
        
        private void saveMetadata(OutputStream o, List<SegmentationMask> masks) throws IOException
@@ -268,10 +267,16 @@ public class Exporter {
                  DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
                  
                  Document document = documentBuilder.newDocument();
+
                  Element rootElement = document.createElement("image_data");
                  document.appendChild(rootElement);
-                 
-                 Element imageElement = document.createElement("image_filename");
+
+                 Element versionElement = document.createElement("sia_version");
+                 versionElement.setTextContent(Application.APP_VERSION);
+                 rootElement.appendChild(versionElement);
+
+                 Element imageElement = document.createElement("orig_image_filename");
+                 imageElement.setTextContent(this.origImageFileName);
                  rootElement.appendChild(imageElement);
                  
                  Element speciesElement = document.createElement("species");
index 90cd1dccea4d3dab87d03129e47ad731752eacaa..cb2dce00c1c576d139f5f237a9ecb207e75fd2a4 100644 (file)
@@ -599,16 +599,16 @@ public class SegmentationContext {
                {
                        DataInputStream input = new DataInputStream(new BufferedInputStream(in));
                        int length = width * height;
-                       boolean[] intensity = new boolean[length];
+                       //boolean[] intensity = new boolean[length];
+                       byte[] intensity = new byte[length];
                        
                        int index = 0;
                        boolean EOF = false;
-                       // see code in export and something to do with sizes Array index out of bounds exception do it today completely
                        while(!EOF)
                        {
                                try
                                {
-                                       intensity[index] = input.readBoolean();
+                                       intensity[index] = (byte)input.read();
                                }
                                catch(Exception e)
                                {
@@ -617,14 +617,13 @@ public class SegmentationContext {
                                index = index+1;
                        }
                        int i = 0;
-                       for (int x=0;x<height;x++)
+                       for (int y=0;y<height;y++)
                        {
-                               for (int y=0;y<width;y++)
+                               for (int x=0;x<width;x++)
                                {
                                        if(i <= index)
                                        {
-                                               byte type = (byte)(intensity[i] == false ? 2:1);
-                                               mask.setPixel(y,x, (byte)type);
+                                               mask.setPixel(x,y, intensity[i]);
                                                i++;
                                        }
                                }