ImagePlusUtil { public static ImagePlus cleanDuplicate(final ImagePlus image) { image.killRoi(); final ImagePlus copy = image.duplicate(); image.restoreRoi(); copy.setTitle(image.getTitle()); return copy; } private  ImagePlusUtil(); static double anisotropy(final ImagePlus image); static ImagePlus cleanDuplicate(final ImagePlus image); static boolean is3D(final ImagePlus image); static boolean isBinaryColour(final ImagePlus image);  }
@Test public void testCleanDuplicate() { final String title = "bonej-test-image.tiff"; final int width = 5; final int height = 7; final int depth = 11; final Roi roi = new Roi(1, 1, 3, 3); final ImagePlus image = IJ.createImage(title, width, height, depth, 8); image.setRoi(roi); final ImagePlus result = ImagePlusUtil.cleanDuplicate(image); assertEquals("Duplicate has wrong title", result.getTitle(), title); assertEquals("ROI should not affect duplicate size", width, result .getWidth()); assertEquals("ROI should not affect duplicate size", height, result .getHeight()); assertEquals("The original image should still have its ROI", roi, image .getRoi()); }
@Test(expected = NullPointerException.class) public void testCleanDuplicateThrowsNPEIfImageNull() { ImagePlusUtil.cleanDuplicate(null); }