Last active
October 22, 2021 01:55
-
-
Save maweigert/9f2684f36d3272786461a0c18d4ea176 to your computer and use it in GitHub Desktop.
Generate label image from rois in Fiji
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#@ ImagePlus imp | |
#@ OUTPUT ImagePlus result | |
from ij import IJ | |
from ij.plugin.frame import RoiManager | |
result = IJ.createImage("Labeling", "16-bit black", imp.getWidth(), imp.getHeight(), 1) | |
ip = result.getProcessor() | |
rm = RoiManager.getInstance() | |
for index, roi in enumerate(rm.getRoisAsArray()): | |
ip.setColor(index+1) | |
ip.fill(roi) | |
ip.resetMinAndMax() | |
IJ.run(result, "glasbey inverted", "") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment