Warning: session_start(): open(/var/lib/php/sessions/sess_eo7o9mpa08aqksuel4nh047728, 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
transient sclass HexagonalBWIntegralImage {
final int w, h;
// data[0] is the sharp edge, data[1] the blunt edge
final int[][] data = new int[2][];
// the column sums in three directions
// north, north west, north east
final int[][] columnSums = new int[3][];
int offset1;
final static double slant = sqrtAThird();
*(BufferedImage img) { this(BWImage(img)); }
*(BWImage img) {
w = img.w();
h = img.h();
for i to 2:
data[0] = new int[w*h];
columnSums[0] = new int[h];
int i = 0;
int lastShift = 0;
for y to h: {
int sum = 0;
int shift = iround(y*slant);
int inc = shift-lastShift;
for x to w: {
// grab pixels
int pixel = img.getInt(x, y);
sum += pixel;
// calc wedges
data[0][i] = data[1][i] = sum;
if (y != 0) {
if (x >= inc)
data[0][i] += data[0][i-w-inc];
if (x+inc < w)
data[1][i] += data[1][i-w+inc];
}
i++;
}
columnSums[0][y] = sum;
}
offset1 = iceil(h*slant);
columnSums[1] = new int[offset1+w];
//columnSums[2] = ...
for (int x = w-1; x >= -offset1; x--) {
int y = 0;
double xfrac = x;
while true {
int x2 = iround(xfrac);
if (x2 >= w)
break;
sum += img.getInt(x2, y);
y++;
xfrac += slant;
}
columnSums[1][x-offset1] = sum;
}
// TODO: columnSums[2]
}
public int getWidth() { ret w; }
public int getHeight() { ret h; }
int w() { ret w; }
int h() { ret h; }
}