static BWImage iBWIntegralImageToBWImage(IBWIntegralImage img) { int w = img.getWidth(), h = img.getHeight(); BWImage out = new(w, h); for y to h: for x to w: { int pixel = iround(img.getPixelAverage(x, y, x+1, y+1)); out.setByte(x, y, (byte) pixel); } ret out; }