Commit 953f5efd authored by Andrey Filippov's avatar Andrey Filippov

CLAUDE: FPN iteration - composite rebuilt center over original (NaN-hole fix)

POSE-13 forensics (from files, run 02:18-02:24): the iteration executed but dG
came out defined on only 5% of the frame (right-edge strip + terrain patches),
so fpn2 = fpn1 over 95% - the ghost survived. Chain: rebuild accumulation was
healthy (494/494 scenes, ~75% per scene, ~85% union) but a single-sequence
new-average center keeps NaN holes in the weak sky (no parent cumulative, no
fillNewGaps), and convert_direct of a NaN-holed center image NaN-poisons
nearly all back-projected tiles (task inversion + overlap spread).

Fix: composite before the second back-propagation - keep rebuilt values where
defined, fall back to the original center in the holes. There dG measures the
pass-1 residual (~0), so it degrades to "no correction where not rebuilt"
instead of NaN. Adds a coverage printout and a cuas_debug save of the
composited center (-FPN-CENTER2-ITERn) so the next run is file-verifiable.
Co-Authored-By: 's avatarClaude Fable 5 <noreply@anthropic.com>
parent 3b1049d6
......@@ -248,6 +248,50 @@ public class CorrectionFPN {
fpn_iter+" of "+cuas_fpn_iters);
break;
}
// By Claude on 07/06/2026: a single-sequence new-average center has NaN holes
// (weak sky tiles), and convert_direct of a NaN-holed center image NaN-poisons
// nearly all back-projected tiles (POSE-13 run: dG defined on only 5% of the
// frame). Composite: keep the rebuilt value where defined, fall back to the
// original center elsewhere - there dG measures the pass-1 residual (~0)
// instead of NaN, degrading gracefully to "no correction where not rebuilt".
{
long num_pix_c2 = 0, num_holes = 0, num_still_nan = 0;
for (int nchn = 0; nchn < image_center2.length; nchn++) if (image_center2[nchn] != null){
double [] orig = ((image_center0 != null) && (nchn < image_center0.length)) ? image_center0[nchn] : null;
for (int npix = 0; npix < image_center2[nchn].length; npix++) {
num_pix_c2++;
if (Double.isNaN(image_center2[nchn][npix])) {
num_holes++;
if (orig != null) {
image_center2[nchn][npix] = orig[npix];
}
if ((orig == null) || Double.isNaN(image_center2[nchn][npix])) {
num_still_nan++;
}
}
}
}
System.out.println(String.format(
"cuasSubtractFpn(): rebuilt center coverage %.2f%% (%d of %d pixels), "+
"%d holes filled from the original center, %d remain NaN",
100.0*(num_pix_c2-num_holes)/Math.max(num_pix_c2,1),
num_pix_c2-num_holes, num_pix_c2, num_holes-num_still_nan, num_still_nan));
if (cuas_debug) {
String [] c2_titles = new String[image_center2.length];
for (int nchn = 0; nchn < c2_titles.length; nchn++) c2_titles[nchn] = "CHN-"+nchn;
ImagePlus imp_c2 = ShowDoubleFloatArrays.makeArrays(
image_center2,
fpn_width,
image_center2[0].length/fpn_width,
center_CLT.getImageName()+"-FPN-CENTER2-ITER"+(fpn_iter+1),
c2_titles);
if (imp_c2 != null) {
center_CLT.saveImagePlusInModelDirectory(
"-FPN-CENTER2-ITER"+(fpn_iter+1), imp_c2);
if (show_fpn) imp_c2.show();
}
}
}
center_CLT.setImageCenter(image_center2); // in-memory only: backPropagate() reads it
double [][][] dg_and_weights = backPropagate(
clt_parameters, // CLTParameters clt_parameters,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment