ImageBoundsUtil { public static boolean outOfBounds(final Dimensions dimensions, final long[] currentPixelPosition) { for (int i = 0; i < currentPixelPosition.length; i++) { final long position = currentPixelPosition[i]; if (position < 0 || position >= dimensions.dimension(i)) { return true; } } return false; }  static boolean outOfBounds(final Dimensions dimensions, final long[] currentPixelPosition);  }
@Test public void testBounds() { Dimensions dimensions = ArrayImgs.bits(100, 100, 100); long[] positionInside = {50, 50, 50}; long[] positionTooLow = {-1, -1, -1}; long[] positionTooHigh = {100, 100, 100}; assertFalse(outOfBounds(dimensions, positionInside)); assertTrue(outOfBounds(dimensions, positionTooLow)); assertTrue(outOfBounds(dimensions, positionTooHigh)); }