Example #1
0
  void createErrorThumbnail() {
    int shadowSize = LARGE_SHADOWS ? SHADOW_SIZE : SMALL_SHADOW_SIZE;
    int width = getWidth();
    int height = getHeight();
    BufferedImage image =
        new BufferedImage(width + shadowSize, height + shadowSize, BufferedImage.TYPE_INT_ARGB);

    Graphics2D g = image.createGraphics();
    g.setColor(new java.awt.Color(0xfffbfcc6));
    g.fillRect(0, 0, width, height);

    g.dispose();

    ImageOverlay imageOverlay = mCanvas.getImageOverlay();
    boolean drawShadows = imageOverlay == null || imageOverlay.getShowDropShadow();
    if (drawShadows) {
      if (LARGE_SHADOWS) {
        ImageUtils.drawRectangleShadow(
            image, 0, 0, image.getWidth() - SHADOW_SIZE, image.getHeight() - SHADOW_SIZE);
      } else {
        ImageUtils.drawSmallRectangleShadow(
            image,
            0,
            0,
            image.getWidth() - SMALL_SHADOW_SIZE,
            image.getHeight() - SMALL_SHADOW_SIZE);
      }
    }

    mThumbnail = SwtUtils.convertToSwt(mCanvas.getDisplay(), image, true /* transferAlpha */, -1);
  }
Example #2
0
  /**
   * Sets the new image of the preview and generates a thumbnail
   *
   * @param image the full size image
   */
  void createThumbnail(BufferedImage image) {
    if (image == null) {
      mThumbnail = null;
      return;
    }

    ImageOverlay imageOverlay = mCanvas.getImageOverlay();
    boolean drawShadows = imageOverlay == null || imageOverlay.getShowDropShadow();
    double scale = getWidth() / (double) image.getWidth();
    int shadowSize;
    if (LARGE_SHADOWS) {
      shadowSize = drawShadows ? SHADOW_SIZE : 0;
    } else {
      shadowSize = drawShadows ? SMALL_SHADOW_SIZE : 0;
    }
    if (scale < 1.0) {
      if (LARGE_SHADOWS) {
        image = ImageUtils.scale(image, scale, scale, shadowSize, shadowSize);
        if (drawShadows) {
          ImageUtils.drawRectangleShadow(
              image, 0, 0, image.getWidth() - shadowSize, image.getHeight() - shadowSize);
        }
      } else {
        image = ImageUtils.scale(image, scale, scale, shadowSize, shadowSize);
        if (drawShadows) {
          ImageUtils.drawSmallRectangleShadow(
              image, 0, 0, image.getWidth() - shadowSize, image.getHeight() - shadowSize);
        }
      }
    }

    mThumbnail = SwtUtils.convertToSwt(mCanvas.getDisplay(), image, true /* transferAlpha */, -1);
  }
Example #3
0
  /** Reset overlays and set plugin to initial status */
  private void reset() {
    roiOverlay.setRoi(null);
    resultOverlay.setImage(null);
    confMatrix = null;

    // Set initial status
    controlPanel.status = ControlJPanel.FG_ADDED_STATUS;
    lastButton =
        controlPanel.fgJRadioButton.isSelected()
            ? controlPanel.fgJRadioButton
            : controlPanel.bgJRadioButton;

    roiOverlay.setColor(controlPanel.fgJRadioButton.isSelected() ? Color.RED : Color.GREEN);

    roiOverlay.setComposite(transparency050);

    if (controlPanel.bgJRadioButton.isSelected()) {
      imp.setRoi(backgroundRoi);
      roiOverlay.setRoi(foregroundRoi);
    } else {
      imp.setRoi(foregroundRoi);
      roiOverlay.setRoi(backgroundRoi);
    }

    controlPanel.updateComponentEnabling();

    imp.changes = true;
    imp.updateAndDraw();
  }
Example #4
0
  /** Update the result overlay with the current matrix of confidence */
  private void updateResult() {
    imp.killRoi();
    roiOverlay.setRoi(null);

    ImageProcessor cp = confMatrix.convertToRGB();
    cp.multiply(1.0 / 255.0);
    cp.copyBits(ip, 0, 0, Blitter.MULTIPLY);

    resultOverlay.setImage(cp);

    imp.changes = true;
    imp.updateAndDraw();
  }
Example #5
0
  /**
   * Create Graphical User Interface for SIOX segmentation.
   *
   * @param imp input image
   */
  public SegmentationGUI(ImagePlus imp) {
    super(imp, new OverlayedImageCanvas(imp));

    while (ic.getWidth() > 800 && ic.getHeight() > 600) IJ.run(imp, "Out", "");

    roiOverlay = new RoiOverlay();
    resultOverlay = new ImageOverlay();

    ((OverlayedImageCanvas) ic).addOverlay(roiOverlay);
    ((OverlayedImageCanvas) ic).addOverlay(resultOverlay);

    roiOverlay.setComposite(transparency050);
    resultOverlay.setComposite(transparency075);

    // Take snapshot of initial pixels
    ip = imp.getProcessor();

    this.setTitle("SIOX Segmentation");
    // Image panel
    Panel imagePanel = new Panel();
    imagePanel.add(ic);

    // Control panel
    controlPanel = new ControlJPanel(imp);
    controlPanel.bgJRadioButton.addActionListener(this);
    lastButton = controlPanel.fgJRadioButton;
    controlPanel.fgJRadioButton.addActionListener(this);
    controlPanel.segmentJButton.addActionListener(this);
    controlPanel.resetJButton.addActionListener(this);
    controlPanel.createMaskJButton.addActionListener(this);
    controlPanel.addJRadioButton.addActionListener(this);
    controlPanel.subJRadioButton.addActionListener(this);
    controlPanel.refineJButton.addActionListener(this);

    Panel all = new Panel();
    BoxLayout box = new BoxLayout(all, BoxLayout.X_AXIS);
    all.setLayout(box);
    all.add(imagePanel);
    all.add(controlPanel);

    add(all);

    this.pack();
    this.setVisible(true);
  }
 public VBox getOverlayContainer(ImageOverlay imageOverlay) {
   return imageOverlay.getContainer();
 }
 public ImageView getOverlayImageView(ImageOverlay imageOverlay) {
   return imageOverlay.getImageView();
 }