void invert(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi == null || !roi.isArea()) { IJ.error("Inverse", "Area selection required"); return; } ShapeRoi s1, s2; if (roi instanceof ShapeRoi) s1 = (ShapeRoi) roi; else s1 = new ShapeRoi(roi); s2 = new ShapeRoi(new Roi(0, 0, imp.getWidth(), imp.getHeight())); imp.setRoi(s1.xor(s2)); }