@Test public void testIsBinaryReturnsFalseIfImageHasWrongType() throws Exception { final ImagePlus testImage = mock(ImagePlus.class); final int wrongTypes[] = { ImagePlus.COLOR_256, ImagePlus.COLOR_RGB, ImagePlus.GRAY16, ImagePlus.GRAY32 }; for (final int wrongType : wrongTypes) { when(testImage.getType()).thenReturn(wrongType); final boolean result = ImageCheck.isBinary(testImage); assertFalse("Only ImagePlus.GRAY8 type should be binary", result); } }
public static boolean isBinary(final ImagePlus imp) { if (imp == null) { IJ.error("Image is null"); return false; } if (imp.getType() != ImagePlus.GRAY8) { return false; } final ImageStatistics stats = imp.getStatistics(); return stats.histogram[0] + stats.histogram[255] == stats.pixelCount; }
ImageCheck { public static boolean isBinary(final ImagePlus imp) { if (imp == null) { IJ.error("Image is null"); return false; } if (imp.getType() != ImagePlus.GRAY8) { return false; } final ImageStatistics stats = imp.getStatistics(); return stats.histogram[0] + stats.histogram[255] == stats.pixelCount; } }
ImageCheck { public static boolean isBinary(final ImagePlus imp) { if (imp == null) { IJ.error("Image is null"); return false; } if (imp.getType() != ImagePlus.GRAY8) { return false; } final ImageStatistics stats = imp.getStatistics(); return stats.histogram[0] + stats.histogram[255] == stats.pixelCount; } private  ImageCheck(); }
ImageCheck { public static boolean isBinary(final ImagePlus imp) { if (imp == null) { IJ.error("Image is null"); return false; } if (imp.getType() != ImagePlus.GRAY8) { return false; } final ImageStatistics stats = imp.getStatistics(); return stats.histogram[0] + stats.histogram[255] == stats.pixelCount; } private  ImageCheck(); static void dicomVoxelDepth(final ImagePlus imp); static boolean huCalibrated(final ImagePlus imp); static boolean isBinary(final ImagePlus imp); static boolean isSingleSlice(final ImagePlus imp); static boolean isVoxelIsotropic(final ImagePlus imp,
		final double tolerance); }
ImageCheck { public static boolean isBinary(final ImagePlus imp) { if (imp == null) { IJ.error("Image is null"); return false; } if (imp.getType() != ImagePlus.GRAY8) { return false; } final ImageStatistics stats = imp.getStatistics(); return stats.histogram[0] + stats.histogram[255] == stats.pixelCount; } private  ImageCheck(); static void dicomVoxelDepth(final ImagePlus imp); static boolean huCalibrated(final ImagePlus imp); static boolean isBinary(final ImagePlus imp); static boolean isSingleSlice(final ImagePlus imp); static boolean isVoxelIsotropic(final ImagePlus imp,
		final double tolerance);  }