Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate label image from rois in Fiji
#@ 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