Warning: session_start(): open(/var/lib/php/sessions/sess_bn3vbkfa47podlgjcap41ukdkg, 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
// an indexing structure for grayscale images
// -all images have the same size
// -images are sorted by
// 1. average brightness
// 2. "lexical" scanline ordering (within same brightness)
// -every image can have an arbitrary value associated (type "A")
persistable sclass ScaledGrayscaleCache extends Meta is WidthAndHeight, IntSize {
int w, h;
new TreeSet entries;
persistable class Entry is Comparable {
double brightness;
BWImage image;
settable A value;
*(BWImage *image) {
brightness = image.averageBrightness();
}
public int compareTo(Entry e) {
if (brightness != e.brightness)
ret cmp(brightness, e.brightness);
ret compareBWImagesByScanlineOrdering(image, e.image);
}
}
*(int w) { this(w, w); }
*(int *w, int *h) {}
public int getWidth() { ret w; }
public int getHeight() { ret h; }
// returns true if image was new
bool add(IBWImage image) {
BWImage scaledImage = scaledBWImageFromBWIntegralImage(w, h, image);
var entry = new Entry(scaledImage);
var existingEntry = entries.floor(entry);
if (cmp(entry, existingEntry) == 0)
false;
entries.add(entry);
true;
}
public int size() { ret entries.size(); }
}