static BufferedImage grayImageFromIBWIntegralImage(IBWIntegralImage img) { int w = img.getWidth(), h = img.getHeight(); byte[] pixels = new[w*h]; int i = 0; for y to h: for x to w: { int pixel = img.getPixel(x, y); pixels[i++] = clampToUByte(pixel; } ret newGrayBufferedImage(w, h, pixels); }