persistable sclass G22GhostImage is IBWImage { int w, h; public int getWidth() { ret w; } public int getHeight() { ret h; } // number of images averaged int imageCount; // array contains raw sum over images // (1 for white pixel, 0 for black pixel) int[] pixels; *(L maskImages) { imageCount = l(maskImages); if (imageCount == 0) ret; var img = first(maskImages); w = img.w(); h = img.h(); pixels = sumOfBinaryImages(maskImages); } public float getFloatPixel(int x, int y) { ret imageCount == 0 ? 0.5f : floatRatio(pixels[y*w+x], imageCount); } FloatBWImage toFloatBWImage() { float[] floatPixels = new[pixels.length]; if (imageCount == 0) fillArray(floatPixels, 0.5f); else for i over pixels: floatPixels[i] = floatRatio(pixels[i], imageCount); ret new FloatBWImage(w, h, floatPixels); } public BufferedImage getBufferedImage() { ret toFloatBWImage().getBufferedImage(); } FloatBWImage certaintyImage() { ret preciseCertaintyImage(this); } simplyCached double certainty() { if (imageCount == 0) ret 0; double sum = 0; int n = pixels.length; for i to n: sum += g22pixelCertainty(doubleRatio(pixels[i], imageCount)); ret sum/(w*h); } G22GhostImage minus(G22GhostImage img) { new G22GhostImage ghost; ghost.w = w; ghost.h = h; ghost.imageCount = imageCount-img.imageCount; ghost.pixels = intArray_minus(pixels, img.pixels); ret ghost; } }