From 67dd3db9517de3e81cfb5e0d69dc0c377adb270e Mon Sep 17 00:00:00 2001 From: lingutln Date: Mon, 19 Dec 2011 19:00:19 +0000 Subject: [PATCH] Modifications, done by Nikhil. svn path=/; revision=228 --- .../src/ie/dcu/apps/ist/PainterRegistry.java | 1 - .../dcu/apps/ist/views/SegmentationView.java | 2 +- .../ie/dcu/segment/painters/LabelPainter.java | 114 ------------------ .../segment/painters/SegmentationPainter.java | 2 +- 4 files changed, 2 insertions(+), 117 deletions(-) delete mode 100644 Annotation/src/ie/dcu/segment/painters/LabelPainter.java diff --git a/Annotation/src/ie/dcu/apps/ist/PainterRegistry.java b/Annotation/src/ie/dcu/apps/ist/PainterRegistry.java index b115e2f..7b437b0 100644 --- a/Annotation/src/ie/dcu/apps/ist/PainterRegistry.java +++ b/Annotation/src/ie/dcu/apps/ist/PainterRegistry.java @@ -20,7 +20,6 @@ public class PainterRegistry { add(new MaskPainter()); add(new ForegroundOnlyPainter()); add(new OutlineOverlayPainter()); - add(new LabelPainter()); } diff --git a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java index 5633d7d..80268f9 100644 --- a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java +++ b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java @@ -793,7 +793,7 @@ public class SegmentationView extends Composite { Assign the label to the segment on clicking assign button and update the image segment. */ private void assignLabel() { - SegmentationPainter painter = painters.get("Display Label"); + SegmentationPainter painter = painters.get("Foreground Only"); setPainter(painter); } diff --git a/Annotation/src/ie/dcu/segment/painters/LabelPainter.java b/Annotation/src/ie/dcu/segment/painters/LabelPainter.java deleted file mode 100644 index 131d2f5..0000000 --- a/Annotation/src/ie/dcu/segment/painters/LabelPainter.java +++ /dev/null @@ -1,114 +0,0 @@ -package ie.dcu.segment.painters; - - -import ie.dcu.segment.*; -import ie.dcu.swt.ObservableImage; - -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.*; - -/** - * Shows the foreground region of the image. The background is greyed out. - * - * @author Kevin McGuinness - */ -public class LabelPainter implements SegmentationPainter { - - private ImageData maskData; - private Image maskImage; - - - public String getName() { - return "Display Label"; - } - - public String getDescription() { - return "Shows the segmented piece with label attached on hovering the mouse."; - } - - public ImageData getMaskData() { - return maskData; - } - - public void paint(SegmentationContext ctx, ObservableImage im) { - GC gc = im.beginPaint(); - - // Paint image - gc.drawImage(ctx.getImage(), 0, 0); - - // Paint mask - createVisibleMask(ctx.getMask()); - gc.drawImage(maskImage, 0, 0); - - // Commit changes - im.endPaint(); - } - - - private void createVisibleMask(SegmentationMask mask) { - dispose(); - - if (isNewMaskDataRequired(mask.getBounds())) { - maskData = createMaskData(mask.getBounds()); - } - // Blit in pixels - byte[] buff = new byte[maskData.width]; - for (int y = 0, i = 0; y < mask.height; y++) { - for (int x = 0; x < mask.width; x++) { - switch (mask.values[i++]) { - case SegmentationMask.BACKGROUND: - // black - buff[x] = 1; - break; - default: - // transparent - buff[x] = 0; - } - } - maskData.setPixels(0, y, buff.length, buff, 0); - } - - // Create new mask - maskImage = new Image(Display.getCurrent(), maskData); - } - - - private boolean isNewMaskDataRequired(Rectangle bounds) { - if (maskData == null) { - return true; - } else { - return maskData.width != bounds.width || maskData.height != bounds.height; - } - } - - - private static ImageData createMaskData(Rectangle bounds) { - RGB[] colors = new RGB[] { - new RGB(255,255,255), - new RGB(128,128,128) - }; - - // Create binary indexed palette - PaletteData palette = new PaletteData(colors); - - // Create 1 bit indexed image - ImageData data = new ImageData( - bounds.width, bounds.height, 1, palette); - - // Set transparent pixel - data.transparentPixel = 0; - // Create and return the image - return data; - } - - - public void dispose() { - // Dispose mask - if (maskImage != null) { - if (!maskImage.isDisposed()) { - maskImage.dispose(); - } - maskImage = null; - } - } -} \ No newline at end of file diff --git a/Annotation/src/ie/dcu/segment/painters/SegmentationPainter.java b/Annotation/src/ie/dcu/segment/painters/SegmentationPainter.java index 3bfc477..f69d6e9 100644 --- a/Annotation/src/ie/dcu/segment/painters/SegmentationPainter.java +++ b/Annotation/src/ie/dcu/segment/painters/SegmentationPainter.java @@ -24,7 +24,7 @@ public interface SegmentationPainter { public ImageData getMaskData(); /** - * Returns a masked image. + * Returns a masked imageData. */ public String getDescription(); -- 2.34.1