@Test
    void testSubimageAccess() {
        final ImageBuilder imageBuilder = new ImageBuilder(100, 100, false);
        populate(imageBuilder);
        final BufferedImage bImage = imageBuilder.getSubimage(25, 25, 25, 25);
        final int w = bImage.getWidth();
        final int h = bImage.getHeight();
        assertEquals(w, 25, "Width of subimage does not match");
        assertEquals(h, 25, "Height of subimage does not match");

        for (int x = 25; x < 50; x++) {
            for (int y = 25; y < 50; y++) {
                final int k = bImage.getRGB(x - 25, y - 25);
                final int rgb = imageBuilder.getRgb(x, y);
                assertEquals(k, rgb, "Invalid buffered image subpixel at " + x + ", " + y);
            }
        }

        final ImageBuilder testBuilder = imageBuilder.getSubset(25, 25, 25, 25);
        for (int x = 25; x < 50; x++) {
            for (int y = 25; y < 50; y++) {
                final int k = testBuilder.getRgb(x - 25, y - 25);
                final int rgb = imageBuilder.getRgb(x, y);
                assertEquals(k, rgb, "Invalid image builder subpixel at " + x + ", " + y);
            }
        }
    }
Test whether sub-image is consistent with source
src/test/java/org/apache/commons/imaging/common/ImageBuilderTest.java