Warning: session_start(): open(/var/lib/php/sessions/sess_bh3ins5phst0euvc5fq6hs3sao, 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
scope regionBorder_innerPoints.
static Pt[] #directions = {
pt(1, 0), pt(0, 1), pt(-1, 0), pt(0, -1) // r, d, l, u
};
static L regionBorder_innerPoints(BWImage_FastRegions regions, int iRegion) {
new PtBuffer out;
Pt p = regions.samplePixel(iRegion);
int x = p.x, y = p.y;
// move up until we're at the edge of the region
// probably we don't actually need to do this because of the way
// the image was scanned, but we'll do it anyway
while (y > 0 && regions.inRegion(iRegion, x, y-1))
y--;
// found our first border pixel with background above
int dir = 3; // direction up
// remember first point
int firstX = x, firstY = y;
int safety = regions.size();
while (x != firstX && y != firstY && --safety >= 0) {
out.add(x, y);
int turn = 3;
while (turn <= 6) { // try left, straight, right, back
int newDir = (dir+turn) & 3;
Pt d = directions[newDir];
int x2 = x+d.x; y2 = y+d.y;
if (regions.inRegion(x2, y2)) {
x = x2; y = y2; dir = newDir;
break;
}
}
// if we get here, the region is just 1 pixel (so we're done)
break;
}
ret out;
}