Warning: session_start(): open(/var/lib/php/sessions/sess_biu6sa8viprm41dsdeb8r9kg3d, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass IIHorizontalSplit extends Meta implements IIntegralImage {
// x coordinate of split point
int splitPoint;
// a and b must have same height
// [0; splitPoint)
RegisteredReference a = new(this);
// [splitPoint; width)
RegisteredReference b = new(this);
*() {}
*(IIntegralImage img, int splitPoint) {
init(img, splitPoint);
}
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));
}
*(IIntegralImage img) {
int w = img.getWidth();
if (w < 2) fail("Can't split image horizontally - too small");
init(img, w/2);
}
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!; }
}