/** Called from io/Opener.java. */ public void run(String path) { if (path.equals("")) return; File theFile = new File(path); String directory = theFile.getParent(); String fileName = theFile.getName(); if (directory == null) directory = ""; // Try and recognise file type and load the file if recognised ImagePlus imp = openImage(directory, fileName, path); if (imp == null) { IJ.showStatus(""); return; // failed to load file or plugin has opened and displayed it } ImageStack stack = imp.getStack(); // get the title from the stack (falling back to the fileName) String title = imp.getTitle().equals("") ? fileName : imp.getTitle(); // set the stack of this HandleExtraFileTypes object // to that attached to the ImagePlus object returned by openImage() setStack(title, stack); // copy over the calibration info since it doesn't come with the ImageProcessor setCalibration(imp.getCalibration()); // also copy the Show Info field over if it exists if (imp.getProperty("Info") != null) setProperty("Info", imp.getProperty("Info")); // copy the FileInfo setFileInfo(imp.getOriginalFileInfo()); // copy dimensions if (IJ.getVersion().compareTo("1.38s") >= 0) setDimensions(imp.getNChannels(), imp.getNSlices(), imp.getNFrames()); if (IJ.getVersion().compareTo("1.41o") >= 0) setOpenAsHyperStack(imp.getOpenAsHyperStack()); }
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(); }