Warning: session_start(): open(/var/lib/php/sessions/sess_onms8la56mqettrhife2vvjvrd, 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
sclass MakeMaskCorrelationMatrix is MakesBufferedImage {
settable long[][] imagesH;
settable long[][] imagesW;
// size w()*h(), every entry is a pixel diff count
gettable int[] matrix;
int w() { ret imagesH.length; }
int h() { ret imagesW.length; }
int maxPixelDiff() { ret l(first(imagesW))*64; }
run {
int w = w(), h = h();
var matrix = this.matrix = new int[w*h];
int i = 0;
for y to h: {
long[] imageH = imagesH[y];
for x to w:
matrix[i++] = countDifferingBits(imageH, imagesW[x]);
}
}
FloatBWImage get() {
if (matrix == null) run();
int w = w(), h = h();
float max = maxPixelDiff();
ret floatBWImageFromFunction(w, h,
(x, y) -> 1f-matrix[y*w+x]/max);
}
public BufferedImage getBufferedImage() { ret toBufferedImage (get()); }
}