The current snapshot (1.7-SNAPSHOT) of the imagingbook library adds a new feature for drawing anti-aliased graphics directly on the image raster. This is accomplished by the new class ImageGraphics, which works for images of type ByteProcessor, ShortProcessor and ColorProcessor (there is currently no support for FloatProcessor).

Grid-1d Grid-2d
standard graphics anti-aliased graphics

Note that a similar mechanism is implemented in vanilla ImageJ for “flattening” vector overlays. However, this facility does not require the creation of graphic overlays but operates directly on ImageProcessor objects. The new class also adds several convenience methods for drawing operations with floating-point (double) coordinates.

Typical usage (e.g., inside an ImageJ plugin):

import imagingbook.lib.image.ImageGraphics;

ImageProcessor ip = ... ;   // some ByteProcessor, ShortProcessor or ColorProcessor
try (ImageGraphics g = new ImageGraphics(ip)) {
   g.drawLine(40, 100.5, 250, 101.5);
   g.drawOval(230.6, 165.2, 150, 150);

See the documentation for ImageGraphics for additional details.