// is it a split? is it a join? depends on your view sclass IIHorizontalSplit extends Meta implements IIntegralImage { // x coordinate of split point // - isn't this just a.getWidth()? int splitPoint; // a and b must have same height // [0; splitPoint) RegisteredReference a = new(this); // [splitPoint; width) RegisteredReference b = new(this); *() {} *(IIntegralImage img) { int w = img.getWidth(); if (w < 2) fail("Can't split image horizontally - too small"); init(img, w/2); } *(IIntegralImage img, int splitPoint) { init(img, splitPoint); } *(IIntegralImage img1, IIntegralImage img2) { a.set(img1); b.set(img2); splitPoint = img1.getWidth(); } void init(IIntegralImage img, int splitPoint) { this.splitPoint = splitPoint; int w = img.getWidth(), h = img.getHeight(); a.set(img.clip(0, 0, splitPoint, h)); b.set(img.clip(splitPoint, 0, w-splitPoint, h)); } public simplyCached int getWidth() { ret a->getWidth()+b->getWidth(); } public int getHeight() { ret a->getHeight(); } public double getIntegralValue(int x, int y, int channel) { if (x < splitPoint) ret a->getIntegralValue(x, y, channel); else ret a->getIntegralValue(splitPoint, y, channel) + b->getIntegralValue(x-splitPoint, y, channel); } public double getIntegralValue(int x, int y) { if (x < splitPoint) ret a->getIntegralValue(x, y); else ret a->getIntegralValue(splitPoint, y) + b->getIntegralValue(x-splitPoint, y); } public BufferedImage getBufferedImage() { BufferedImage img = newBufferedImage(getWidth(), getHeight()); var g = graphics(img); a->drawAt(g, 0, 0); b->drawAt(g, splitPoint, 0); ret img; } IIntegralImage a() { ret a!; } IIntegralImage b() { ret b!; } void setA(IIntegralImage a) { this.a.set(a); } void setB(IIntegralImage b) { this.b.set(b); } }