final sclass BWIntegralImage_twoParts implements MakesBufferedImage, IBWIntegralImage { int th; BWIntegralImage top, bottom; *() {} *(File f) { this(loadImage2(f)); } *(MakesBufferedImage img) { this(toBufferedImage(img)); } *(BufferedImage image) ctex { int 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) : bottom.getIIValue(x, y-th); } public int getWidth() { ret w; } public int getHeight() { ret h; } // unoptimized public BufferedImage getBufferedImage() { ret scaleDownUsingIntegralImageBW(this, w).getBufferedImage(); } }