I have questions about ROIs on cropped regions and wrote a small script to show it.
from ij import IJ, ImagePlus, ImageStack, WindowManager as wm from ij.gui import Roi, PolygonRoi from ij.plugin import Duplicator # imp = IJ.getImage(); # IJ.run("Blobs (25K)", ""); # imp = IJ.getImage(); # IJ.setTool("polygon"); imp = ImagePlus("http://imagej.nih.gov/ij/images/flybrain.zip") xpoints = [103,117,153,155,136]; ypoints = [95,61,62,92,100]; new_roi = PolygonRoi(xpoints,ypoints,Roi.POLYGON) imp.setRoi(new_roi) print(imp.getRoi().getBounds()) imp2 = Duplicator().run(imp, 1, 1, 1, imp.getNSlices(), 1, 1) imp2.setRoi(new_roi) IJ.run(imp2, "Clear Outside","") print(imp2.getRoi().getBounds()) imp2.show() imp.show()
This gives an imp2 completely black since the ROI is considered to be outside the boundaries of the image and therefore clear everything. Is there a clever way to reapply a ROI on a cropped region ? Also, why does
Restore Selection works if I have the image open (even though I want to avoid displaying the image) ?
Thanks for your help !