Warning: session_start(): open(/var/lib/php/sessions/sess_nu82l2ilc3mg76f5s1i1f24nu4, 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
sinterface IIntegralImage extends MakesBufferedImage {
public int getWidth();
public int getHeight();
public Pt getSize() { ret pt(getWidth, getHeight()); }
public int nChannels() { ret 3; }
// get value for 1 channel
// normal range [0; pixelCount*256)
public double getIntegralValue(int x, int y, int channel);
// gets value of the 3 channels
// normal range [0; pixelCount*256*3)
default double getIntegralValue(int x, int y) {
ret getIntegralValue(x, y, 0)
+ getIntegralValue(x, y, 1)
+ getIntegralValue(x, y, 2);
}
default double rectSum(int x1, int y1, int x2, int y2, int channel) {
double bottomLeft = getIntegralValue(x1-1, y2-1, channel);
double bottomRight = getIntegralValue(x2-1, y2-1, channel);
double topLeft = getIntegralValue(x1-1, y1-1, channel);
double topRight = getIntegralValue(x2-1, y1-1, channel);
ret bottomRight+topLeft-topRight-bottomLeft;
}
default double rectSum(int x1, int y1, int x2, int y2) {
double bottomLeft = getIntegralValue(x1-1, y2-1);
double bottomRight = getIntegralValue(x2-1, y2-1);
double topLeft = getIntegralValue(x1-1, y1-1);
double topRight = getIntegralValue(x2-1, y1-1);
ret bottomRight+topLeft-topRight-bottomLeft;
}
default double rectSum(Rect r) {
ret rectSum(r.x, r.y, r.x2(), r.y2());
}
default IIntegralImage clip(int x, int y, int w, int h) {
ret IIVirtualClip(this, x, y, w, h);
}
default double averageBrightness() {
int w = getWidth(), h = getHeight();
ret doubleRatio(getIntegralValue(w-1, h-1), w*h*3*255.0);
}
default double getPixel(int x, int y, int channel) {
ret rectSum(x, y, x+1, y+1, channel);
}
// returns RGB pixel without alpha
default int getPixel(int x, int y) {
int r = iround(rectSum(x, y, x+1, y+1, 0));
int g = iround(rectSum(x, y, x+1, y+1, 1));
int b = iround(rectSum(x, y, x+1, y+1, 2));
ret rgbInt(r, g, b);
}
default BufferedImage getBufferedImage() {
int w = getWidth(), h = getHeight();
int[] pixels = new[w*h];
int i = 0;
for y to h:
for x to w:
pixels[i++] = getPixel(x, y) | fullAlphaMask();
ret intArrayToBufferedImage_new(pixels, w, h);
}
// minimum and maximum brightness possible in image
default DoubleRange colorRange(int channel) { ret doubleRange(0, 256); }
}