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();
default public Pt getSize() { ret pt(getWidth(), getHeight()); }
default public int defaultChannel() { ret 0; }
default public int nChannels() { ret 3; }
// get value for 1 channel
// normal range [0; pixelCount*256)
public double getIntegralValue(int x, int y, int channel);
default double getIntegralValue(double x, double y, int channel) {
ret getIntegralValue(ifloor(x), ifloor(y), channel);
}
// gets summed 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(double x1, double y1, double x2, double y2, int channel) {
ret rectSum(iround(x1), iround(y1), iround(x2), iround(y2), channel);
}
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 rectAverage(int x1, int y1, int x2, int y2, int channel) {
ret doubleRatio(rectSum(x1, y1, x2, y2, channel), areaFromPoints(x1, y1, x2, y2));
}
default double rectAverage(Rect r, int channel) {
ret doubleRatio(rectSum(r, channel), rectArea(r));
}
default double rectSum(Rect r) {
ret rectSum(r.x, r.y, r.x2(), r.y2());
}
default double rectSum(Rect r, int channel) {
ret rectSum(r.x, r.y, r.x2(), r.y2(), channel);
}
default double pixelSum(DoubleRect r) {
ret rectSum(toRect_floor(r), defaultChannel());
}
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 RGB averageRGB() {
int w = getWidth(), h = getHeight();
double factor = 1/(255.0*(w*h));
ret RGB(
rectSum(0, 0, w, h, 0)*factor,
rectSum(0, 0, w, h, 1)*factor,
rectSum(0, 0, w, h, 2)*factor);
}
// normal range: (0, 255)
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 int nPixels() { ret getWidth()*getHeight(); }
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(pixels, w, h);
}
// minimum and maximum brightness possible in image
// Better not to use because without this information
// you have a more general recognition algorithm.
//default DoubleRange colorRange(int channel) { ret doubleRange(0, 256); }
}