示例#1
0
 /**
  * Attempts to open the specified path with the given plugin. If the plugin extends the ImagePlus
  * class (e.g., BioRad_Reader), set extendsImagePlus to true, otherwise (e.g., LSM_Reader) set it
  * to false.
  *
  * @return A reference to the plugin, if it was successful.
  */
 private Object tryPlugIn(String className, String path) {
   Object o = IJ.runPlugIn(className, path);
   if (o instanceof ImagePlus) {
     // plugin extends ImagePlus class
     ImagePlus imp = (ImagePlus) o;
     if (imp.getWidth() == 0) o = null; // invalid image
     else width = IMAGE_OPENED; // success
   } else {
     // plugin does not extend ImagePlus; assume success
     width = IMAGE_OPENED;
   }
   return o;
 }
示例#2
0
  public void showRois3D() {
    registerActiveImage();
    if (currentImage == null) return;
    // verifier que l'image active a les memes dimentions
    Object[] os = this.list.getSelectedValues();

    if (os.length == 1) {
      mcib3d.geom.Object3D o = ((Object3DGui) os[0]).getObject3D();
      currentImage.setSlice((o.getZmax() + o.getZmin()) / 2 + 1);
    }
    int nSlices = currentImage.getNSlices();

    currentROIs = new HashMap<Integer, Roi>(nSlices);
    // stores the roi mask to save memory..
    if (roiMask == null || !roiMask.sameDimentions(currentImage)) {
      roiMask = new ImageByte("mask", currentImage.getWidth(), currentImage.getHeight(), nSlices);
    } else {
      roiMask.erase();
    }
    ImageStack maskStack = roiMask.getImageStack();
    Object3DGui obj;
    for (Object o : os) {
      obj = (Object3DGui) o;
      obj.getObject3D().draw(maskStack, 255);
    }
    // roiMask.show();

    for (int i = 1; i <= nSlices; i++) {
      ImagePlus im = new ImagePlus("mask", maskStack.getProcessor(i));
      im.getProcessor().setThreshold(1, 255, ImageProcessor.NO_LUT_UPDATE);
      ThresholdToSelection tts = new ThresholdToSelection();
      tts.setup("", im);
      tts.run(im.getProcessor());
      Roi r = im.getRoi();
      if (r != null) currentROIs.put(i, r);
    }
    updateRoi();
  }