Common { public static <C extends ComplexType<C>> ImgPlus<BitType> toBitTypeImgPlus( final OpEnvironment ops, final ImgPlus<C> imgPlus) { final Img<BitType> convertedImg = ops.convert().bit(imgPlus.getImg()); final ImgPlus<BitType> convertedImgPlus = new ImgPlus<>(convertedImg); copyMetadata(imgPlus, convertedImgPlus); return convertedImgPlus; }  static LUT makeFire(); static ImgPlus<BitType> toBitTypeImgPlus(
		final OpEnvironment ops, final ImgPlus<C> imgPlus); static boolean warnAnisotropy(final ImagePlus image,
		final UIService uiService); static void cancelMacroSafe(final ContextCommand command, final String reason);  }
@Test public void testToBitTypeImgPlus() throws AssertionError { final String unit = "mm"; final String name = "Test image"; final double scale = 0.5; final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X, unit, scale); final Img<DoubleType> img = ArrayImgs.doubles(3); final ImgPlus<DoubleType> source = new ImgPlus<>(img, name, xAxis); final ImgPlus<BitType> result = Common.toBitTypeImgPlus(IMAGE_J.op(), source); final int dimensions = source.numDimensions(); assertEquals("Number of dimensions copied incorrectly", dimensions, result .numDimensions()); assertTrue("Dimensions copied incorrectly", IntStream.range(0, dimensions) .allMatch(d -> source.dimension(d) == result.dimension(d))); assertEquals("Image name was not copied", name, result.getName()); assertEquals("Axis type was not copied", Axes.X, result.axis(0).type()); assertEquals("Axis unit was not copied", unit, result.axis(0).unit()); assertEquals("Axis scale was not copied", scale, result.axis(0) .averageScale(0, 1), 1e-12); }
@Test(expected = NullPointerException.class) public void testToBitTypeImgPlusThrowsNPEIfOpEnvironmentNull() { final Img<DoubleType> img = ArrayImgs.doubles(3, 3); final ImgPlus<DoubleType> image = new ImgPlus<>(img); Common.toBitTypeImgPlus(null, image); }
@Test(expected = NullPointerException.class) public void testToBitTypeImgPlusThrowsNPEIfImageNull() { Common.toBitTypeImgPlus(IMAGE_J.op(), null); }