final sclass BWIntegralImage_twoParts implements MakesBufferedImage, IBWIntegralImage { int w, h, th; BWIntegralImage top, bottom; *() {} *(File f) { this(loadImage2(f)); } *(MakesBufferedImage img) { this(toBufferedImage(img)); } *(BufferedImage image) ctex { w = image.getWidth(); h = image.getHeight(); th = (h+1)/2; L l = parallelEval( () -> BWIntegralImage(virtualClipBufferedImage(image, 0, 0, w, th)), () -> h <= th ? null : BWIntegralImage(virtualClipBufferedImage(image, 0, th, w, h)) ); top = first(l); bottom = second(l); } public int getIIValue(int x, int y) { ret y < th ? top.getIIValue(x, y) : top.getIIValue(x, th-1) + bottom.getIIValue(x, y-th); } public int getWidth() { ret w; } public int getHeight() { ret h; } }