From: lingutln Date: Thu, 5 Jan 2012 07:53:37 +0000 (+0000) Subject: svn path=/; revision=251 X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=369abd7676067729ce053b6a6258842b416b0bd0;p=old-jaiswallab-svn%2F.git svn path=/; revision=251 --- diff --git a/Annotation/.classpath b/Annotation/.classpath index 22412b6..61c9bd1 100644 --- a/Annotation/.classpath +++ b/Annotation/.classpath @@ -1,11 +1,11 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java index d955db7..8e7f715 100644 --- a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java +++ b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java @@ -478,7 +478,7 @@ public class SegmentationView extends Composite { public void formSegmetationObject() { - view.getContext().getMask().formSegmentationObject(); + view.getContext().formSegmentationObject(); } diff --git a/Annotation/src/ie/dcu/segment/SegmentationContext.java b/Annotation/src/ie/dcu/segment/SegmentationContext.java index 229d3c2..333cffe 100644 --- a/Annotation/src/ie/dcu/segment/SegmentationContext.java +++ b/Annotation/src/ie/dcu/segment/SegmentationContext.java @@ -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 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(); } /** @@ -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 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(); diff --git a/Annotation/src/ie/dcu/segment/SegmentationMask.java b/Annotation/src/ie/dcu/segment/SegmentationMask.java index c3e820a..2d0095a 100644 --- a/Annotation/src/ie/dcu/segment/SegmentationMask.java +++ b/Annotation/src/ie/dcu/segment/SegmentationMask.java @@ -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 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(); 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 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++; } }