interface IG22MasksHolder {
replace Mask with IG22Mask.
WidthAndHeight maskSize();
L maskImages();
//LPair maskImagesWithLabels();
L extends Mask> masks();
G22GhostImage ghost();
double certainty();
default int nMasks() { ret l(masks()); }
default S renderCountAndCertainty() {
ret main nMasks(nMasks()) + " with c=" + formatDouble3(certainty());
}
default bool canSplit() { ret nMasks() > 1; }
default L> subHolders() { null; }
default void transformSubHolders(IF1> f) {}
default PStackComputable findSimilarMasks(G22FindSimilarMasksTask task) {
ret new FindSimilarMasks_BruteForce(this, task);
}
srecord noeq FindSimilarMasks_BruteForce(IG22MasksHolder masksHolder, G22FindSimilarMasksTask task) extends PStackComputableWithStep {
Mask maskBeingTested;
toString { ret formatFunctionCall(shortClassName(this), masksHolder, "step=" + step); }
void step(IPStack stack) {
if (task.ended()) ret with stack.ret();
if (step == 0) {
++step;
stack.optionsOrReturn(this, map(masksHolder.masks(), mask ->
self -> self.maskBeingTested = mask));
} else {
task.tryMask(maskBeingTested);
stack.ret();
}
}
}
IG22MasksHolder cloneTreeWithLabelTransform(IF1 transformLabel);
default L labels() { ret map(masks(), -> .label()); }
default Image2B regionToMaskImage(IImageRegion region) {
ret region == null ?: g22standardRegionToMaskImage(region, maskSize());
}
}