Antialiased fill command

Hi there,

I’m fairly new to writing plugins in ImageJ and hoping someone has a simple/fast solution to a problem I’m having. I’m using the fill command to fill an ROI, but because fill doesn’t use antialiasing, I get unwanted jaggies along the interpolated diagonal lines.

I’ve thought of two possible solutions, but I was sort of hoping I’ve missed a parameter/command that would save me the time of implementing one of them.

I could upscale the image and ROI, fill the ROI, then downscale the image, allow the scaling to perform the interpolation, but this approach seems a bit excessive/might be slow for my large image stacks!

Otherwise I could write code to iterate along the edge pixels and perform the interpolation and antialiasing myself, which might take me a while to implement, and then may still be slow.

Any help would be appreciated!

Thanks and regards,


@JIMageJ Awesome screen name. :smile:

Another option is that you can take a “screenshot” of the image as it is currently painted on screen. See the Plugins :arrow_forward: Utilities :arrow_forward: Capture Image command.

@Wayne Is there a better way to fill ROIs or overlays with antialiasing?

1 Like

The Flatten command does antialiasing of filled ROIs. It also supports ROIs filled with a translucent color. Here is a macro example:

run("Clown (14K)");
makeOval(148, 64, 77, 42);
run("Properties... ", "fill=#cc77bbff");
run("Add Selection...");
run("Select None");
makeRectangle(185, 55, 30, 30);
run("To Selection");
run("Select None");'

The 50 ms delay is only needed if you are running a version of ImageJ earlier than 1.51o34.


Thanks Wayne and ctrueden, the Flatten command sounds like what I was looking for. The documentation says it only outputs to an RGB image… but I can work around that in this case! :grinning:


1 Like