I am trying to write jython code for creating a binary mask from freehand selection.
The code below
imp = IJ.getImage() mask=imp.getMask() mask_imp=ImagePlus("segmframe", mask) mask_imp.show()
works well but creates a mask with the dimensions of a rectangle enclosing the selection while I need a mask with the dimensions of image.
Also i need the mask to be passed internally as an ImagePlus object (therefore Selection.run(“mask”) does not work for me.
imp.createRoiMask() leads to error:
AttributeError: 'ij.ImagePlus' object has no attribute 'createRoiMask'