Commit d260d3de authored by Andrey Filippov's avatar Andrey Filippov

docs: Add Gemini notes on potential double-normalization bug in TD accumulation

parent 09adc66b
# AI Agent Bug Suspicions & TODOs
This file tracks potential issues, structural anomalies, and mathematical mismatches identified by AI agents during code analysis. Items here require human verification before invasive code changes are made.
---
### [2026-04-24] Potential Double Normalization in Ranging Accumulation (Gemini)
**Location:** `CuasRanging.java`, method: `refineSingleTargetDisparity()` around line 1946.
**Observation:**
The method accumulates transform-domain (TD) correlations across multiple scenes to increase SNR for deep disparity.
1. It calls `OpticalFlow.accumulateCorrelationsAcOnly(accum_weights, fcorr_td_acc)`. This method loops over the array and divides `fcorr_td_acc` values by `accum_weights`.
2. It then calls `image_dtt.clt_process_tl_correlations(...)`, passing *both* the normalized `fcorr_td_acc` and the `accum_weights`.
If the downstream GPU call (`gpuQuad.execCorr2D_normalize`) uses `accum_weights` to divide the values again, the integrated signal is divided by $N^2$ instead of $N$. For a sequence of 200 frames, this suppresses the signal by a factor of 40,000, effectively destroying the correlation peak.
**Action Required:**
Verify if `execCorr2D_normalize` (or the downstream CPU equivalent if GPU falls back) applies division by the passed weights. If so, remove the `accumulateCorrelationsAcOnly` call in `refineSingleTargetDisparity`.
---
...@@ -1947,6 +1947,14 @@ public class CuasRanging { ...@@ -1947,6 +1947,14 @@ public class CuasRanging {
} // for (int nseq = 0; nseq < num_seq; nseq++) { } // for (int nseq = 0; nseq < num_seq; nseq++) {
// Normalize accumulated correlations // Normalize accumulated correlations
/*
* [Gemini Note, 2026-04-24]: Potential Double-Normalization Bug.
* accumulateCorrelationsAcOnly explicitly divides the fcorr_td_acc arrays by accum_weights.
* Immediately after, image_dtt.clt_process_tl_correlations is called and also receives accum_weights.
* Inside the GPU pipeline (execCorr2D_normalize), the weights might be applied again.
* If so, the signal is divided by N^2 instead of N, causing massive signal loss on long integrations.
* Requires verification of GPU behavior before removing.
*/
OpticalFlow.accumulateCorrelationsAcOnly( OpticalFlow.accumulateCorrelationsAcOnly(
accum_weights, // final float [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair] accum_weights, // final float [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair]
fcorr_td_acc); // final float [][][][] fcorr_td_acc // [tilesY][tilesX][pair][256] sparse transform domain representation of corr pairs fcorr_td_acc); // final float [][][][] fcorr_td_acc // [tilesY][tilesX][pair][256] sparse transform domain representation of corr pairs
......
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