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(); } double certainty() { double sum = 0; int n = pixels.length; for i to n: sum += g22pixelCertainty(pixels[i]); ret sum/(w*h); } }