-<?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
public void formSegmetationObject() {
- view.getContext().getMask().formSegmentationObject();
+ view.getContext().formSegmentationObject();
}
import ie.dcu.util.FileUtils;
import java.io.*;
+import java.util.ArrayList;
import java.util.zip.*;
import org.eclipse.swt.SWT;
* 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;
private SegmentationContext(ImageData imageData, File file) {
this.imageData = imageData;
this.file = file;
+ maskObjects = new ArrayList<SegmentationMask>();
}
/**
}
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.
*
}
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
out.putNextEntry(entry);
// Save the mask
- getMask().save(out);
+ //getMask().save(out);
// End the entry
out.closeEntry();
import ie.dcu.matrix.ByteMatrix;
import java.io.*;
-import java.util.ArrayList;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
*/
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}.
super(height, width);
this.width = width;
this.height = height;
- objects = new ArrayList<ByteMatrix>();
clear();
}
/**
* 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).
package ie.dcu.segment.painters;
+import java.util.ArrayList;
+
import ie.dcu.segment.*;
import ie.dcu.swt.ObservableImage;
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
}
- 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++;
}
}