Esempio n. 1
0
 protected void hideRois() {
   if (currentImage == null) return;
   currentImage.killRoi();
   if (currentImage.isVisible()) {
     currentImage.updateAndDraw();
     ImageUtils.removeScrollListener(currentImage, this, this);
   }
   currentImage = null;
 }
Esempio n. 2
0
 protected void updateRoi() {
   // System.out.println("image:"+currentImage.getTitle()+ " slice:"+currentImage.getSlice());
   Roi r = currentROIs.get(currentImage.getSlice());
   if (r != null) {
     currentImage.setRoi(r);
   } else {
     currentImage.killRoi();
   }
   currentImage.updateAndDraw();
 }
Esempio n. 3
0
 protected void registerActiveImage() {
   ImagePlus activeImage = WindowManager.getCurrentImage();
   if (activeImage != null
       && activeImage.getProcessor() != null) { // && activeImage.getImageStackSize() > 1
     if (currentImage != null && currentImage.getWindow() != null && currentImage != activeImage) {
       // System.out.println("remove listener:"+currentImage.getTitle());
       ImageUtils.removeScrollListener(currentImage, this, this);
       currentImage.killRoi();
       currentImage.updateAndDraw();
       currentImage = null;
     }
     if (currentImage != activeImage) {
       // System.out.println("add listener:"+activeImage.getTitle());
       ImageUtils.addScrollListener(activeImage, this, this);
       this.currentImage = activeImage;
     }
   }
 }
Esempio n. 4
0
 public void mergeSelectedObjects() {
   this.populatingObjects = true;
   HashMap<Integer, ArrayList<Object3DGui>> allObjects = getSplitSelection();
   for (int channelIdx : allObjects.keySet()) {
     ArrayList<Object3DGui> objects = allObjects.get(channelIdx);
     if (objects != null && objects.size() >= 2) {
       Collections.sort(objects);
       Object3DGui o1 = objects.get(0);
       for (int i = objects.size() - 1; i > 0; i--) {
         Object3DGui o2 = objects.get(i);
         o1.merge(o2);
         listModel.removeElement(o2);
         // IJ.log("merge:"+o1.getName()+ "::"+objects.get(i).getName()+ " channel:"+channelIdx);
       }
       o1.getChannel().createObjects();
       if (autoSave) o1.getChannel().saveOutput();
       ImagePlus img = o1.getChannel().getSegmented().getImagePlus();
       if (img.isVisible()) {
         img.updateAndDraw();
       }
     }
   }
   this.populatingObjects = false;
 }
Esempio n. 5
0
 public void deleteSelectedObjects() {
   populatingObjects = true;
   try {
     boolean[] modif = new boolean[currentChannels.length];
     for (Object o : this.list.getSelectedValues()) {
       listModel.removeElement(o);
       modif[getChannelRank(((Object3DGui) o).getChannel())] = true;
       ((Object3DGui) o).delete(true);
     }
     for (int i = 0; i < currentChannels.length; i++) {
       if (modif[i]) {
         ImagePlus img = currentChannels[i].getSegmented().getImagePlus();
         if (img.isVisible()) {
           img.updateAndDraw();
         }
         currentChannels[i].createObjects();
         if (autoSave) currentChannels[i].saveOutput();
       }
     }
   } catch (Exception e) {
     exceptionPrinter.print(e, "", Core.GUIMode);
   }
   populatingObjects = false;
 }
Esempio n. 6
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();
  }