Commit b7cd20d7 authored by Andrey Filippov's avatar Andrey Filippov

More tracking stage 1 scores

parent 29ff9963
......@@ -1210,8 +1210,7 @@ public class CuasMotion {
case ANLZ_SECT:
System.out.println("Displaying scenes from "+nseq0+" to "+nseq1+", parameter: "+choices[npar+extra_choices.length]); // CuasMotionLMA.LMA_TITLES
System.out.println("tx="+tx0+", ty="+ty0+", twidth="+twidth+", theight="+theight);
// int ntile = tx0 + ty0 * wh[0];
double [] min_max = {Double.NaN, Double.NaN};
for (int nseq = nseq0; nseq <= nseq1; nseq++) {
boolean [][] has_targ = new boolean [theight][twidth];
boolean has_targets = false;
......@@ -1229,12 +1228,10 @@ public class CuasMotion {
for (int ty = ty0; ty < (ty0+theight); ty++) {
for (int tx = tx0; tx < (tx0+twidth); tx++) {
int ntile = tx + ty * wh[0];
// boolean has_targets = (multi_targets[nseq] != null) && (multi_targets[nseq][ntile] != null) && (multi_targets[nseq][ntile].length > 0);
if (has_targ[ty-ty0][tx-tx0] || !skip_empty) {
if ((theight * twidth) > 1) {
System.out.print(String.format("%5s,%2d:%2d, ",ntile,tx,ty));
}
// System.out.print(String.format("%17s, %4d, ",pvf_titles[0][nseq],nseq));
if (has_targ[ty-ty0][tx-tx0]) {
int num_targ = multi_targets[nseq][ntile].length;
for (int ntarg = 0; ntarg < num_targ; ntarg++) {
......@@ -1269,6 +1266,15 @@ public class CuasMotion {
//
default:
System.out.print(String.format("%"+fw+"f",multi_targets[nseq][ntile][ntarg][npar]));
if (!Double.isNaN(multi_targets[nseq][ntile][ntarg][npar])) {
if (!(multi_targets[nseq][ntile][ntarg][npar] >= min_max[0])) {
min_max[0] = multi_targets[nseq][ntile][ntarg][npar];
}
if (!(multi_targets[nseq][ntile][ntarg][npar] <= min_max[1])) {
min_max[1] = multi_targets[nseq][ntile][ntarg][npar];
}
}
}
// if (ntarg < (num_targ-1)) {
System.out.print(", ");
......@@ -1282,7 +1288,8 @@ public class CuasMotion {
System.out.println();
}
}
System.out.println();
System.out.println("\n"+choices[npar+extra_choices.length]+" Rectangle("+tx0+", "+ty0+", "+twidth+", "+theight+")"+
" scenes:["+nseq0+", "+nseq1+"] min = "+min_max[0]+", max = "+min_max[1]);
break;
case ANLZ_NEMPTY: // list tiles with targets
case ANLZ_DEFINED: // list tiles with targets with non-NaN parameter
......@@ -6394,7 +6401,7 @@ public class CuasMotion {
targets_list.add(indx);
}// keep_failed
// set RSLT_BOOST
target[CuasMotionLMA.RSLT_BOOST] = boost_exposure;
target[CuasMotionLMA.RSLT_EBOOST] = boost_exposure;
} // if (mv != null) {
} // for (int indx = 0; indx < max_candidate.size(); indx++) {
......@@ -6710,6 +6717,8 @@ public class CuasMotion {
targets[ntarg][CuasMotionLMA.RSLT_PHASE1_AMP] = targets[ntarg][CuasMotionLMA.RSLT_A];
targets[ntarg][CuasMotionLMA.RSLT_PHASE1_MSCORE] = targets[ntarg][CuasMotionLMA.RSLT_MSCORE];
targets[ntarg][CuasMotionLMA.RSLT_PHASE1_VSTR] = targets[ntarg][CuasMotionLMA.RSLT_VSTR];
targets[ntarg][CuasMotionLMA.RSLT_PHASE1_VBOOST] = targets[ntarg][CuasMotionLMA.RSLT_VBOOST];
targets[ntarg][CuasMotionLMA.RSLT_PHASE1_EBOOST] = targets[ntarg][CuasMotionLMA.RSLT_EBOOST];
}
}
}
......@@ -8027,10 +8036,6 @@ public class CuasMotion {
}
// niter = 19; //
}
final int num_seq = motion_sequence.length;
final int num_tiles = motion_sequence[0].length;
// By Claude on 05/07/2026: temporal LPF for accumulation and MV refinement inputs
// fpixels_accum: LPF for shiftAndRenderAccumulate (accum_ra); fpixels_refine: LPF for refineMotionVectors (precorr_ra)
final float [][] fpixels_accum;
if (accum_ra > 1) {
fpixels_accum = cuas_gaussian_ra ?
......@@ -8051,8 +8056,6 @@ public class CuasMotion {
if (target_sequence_multi == null) {
// final double [][][][]
// target_sequence_multi = new double [num_seq][num_tiles][][];
// initFromMotionSequence(motion_sequence, target_sequence_multi); // By Claude on 05/07/2026
target_sequence_multi = initTargetsFromMotion(motion_sequence);
// Calculate and set motion vectors strengths/failures
setEffectiveStrengthMV( // calculate tiles effective strength by the motion vectors. Combine with the target LMA?
......@@ -8066,7 +8069,6 @@ public class CuasMotion {
speed_boost); // double speed_boost);
// first pass, using non-centered targets
// double boost_accum_pairs = slow_mode? 1.0:4.0; // just for testing, unconditionally boost tracking cameras exposure time
for (; niter < num_cycles; niter++) {
boolean save_filtered_low = intermed_low && (niter < iter_show);
boolean save_filtered_high = intermed_high && (niter < iter_show);
......@@ -8100,33 +8102,6 @@ public class CuasMotion {
parentCLT.saveImagePlusInModelDirectory(imp_ms1);
}
// double [][] effective_strength =
// ==== does it need to be re-calculated ? =====
// Only used in int [][] filter5 = filter5Targets( // will ignore failed tiles
// for centered tile pass, trying to eliminate with null for the motion sequence
// Not needed - set once above
/*
getEffectiveStrengthMV( // calculate tiles effective strength by the motion vectors. Combine with the target LMA?
motion_sequence, // final double [][][] motion_scan,
niter, // int niter, // save iteration number on failure if >=
cuasMotion.tilesX, // final int tilesX)
0, // final double min_score_mv,
speed_min, // double speed_min,
speed_pref, // double speed_pref,
speed_boost); // double speed_boost);
syncMotionScoreToSentinels(motion_sequence, target_sequence_multi); // By Claude on 05/07/2026
*/
/*
if (save_filtered_low && debug_more) {
ImagePlus imp_mv_strength = showTargetSequence(
motion_sequence, // double [][][] vector_fields_sequence,
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
model_prefix+"-MV_STRENGTH-n"+niter,// String title,
!batch_mode, // boolean show,
cuasMotion.tilesX); // int tilesX) {
parentCLT.saveImagePlusInModelDirectory(imp_mv_strength);
}
*/
if (save_filtered_low && debug_more) {
String title = model_prefix+"-PRE-SELECT-n"+niter;
ImagePlus imp_pre_select = showTargetSequence(
......@@ -8141,7 +8116,6 @@ public class CuasMotion {
}
int [][] filter5 = filter5Targets( // will ignore failed tiles
// null, // By Claude on 05/07/2026: use FAIL_PENDING sentinels in target_sequence_multi
target_sequence_multi, // final double [][][][] target_sequence_multi,
// if use motion and select_new will only consider tiles (and compare motion scores in motion_sequence) that have nulls in target_sequence_multi[nseq][ntile]
// if not use motion and select_new will only consider (and compare scores) tiles that have [RSLT_CENTERED] = 0.0
......@@ -8214,6 +8188,9 @@ public class CuasMotion {
int num_new = 0;
// double effective_boost = boost_accum_pairs; // default virtual exposure scale
if (phase1_boosted) {
if (debugLevel > -4) {
System.out.println ("Accumulating targets with exposure time boosted x"+boost_accum_pairs);
}
double [][][][] targets_new_multi=getNewTargets(
false, // boolean centered,
clt_parameters, // CLTParameters clt_parameters,
......@@ -8325,6 +8302,9 @@ public class CuasMotion {
}
if (phase1_base) {
if (debugLevel > -4) {
System.out.println ("Accumulating targets with nominal exposure time");
}
double [][][][] targets_new_multi=getNewTargets(
false, // boolean centered,
clt_parameters, // CLTParameters clt_parameters,
......@@ -8463,13 +8443,10 @@ public class CuasMotion {
}
} // end of phase 1
//===========================================================================
if (debugLevel > -4) {
System.out.println("\n========================== Starting centered iterations =============================.\n");
}
// By Claude on 05/05/2026 — optional MV refinement parameters for centered loop
// boolean recalc_mv = clt_parameters.imp.cuas_recalc_mv && !slow_mode;
int recalc_mv_num = slow_mode ? 0 : clt_parameters.imp.cuas_recalc_mv_num;
double recalc_mv_boost = clt_parameters.imp.cuas_recalc_mv_boost;
double recalc_mv_corr = clt_parameters.imp.cuas_recalc_mv_corr;
......@@ -8514,8 +8491,6 @@ public class CuasMotion {
fail_mismatch, // final boolean fail_mismatch,
offcenter, // final double offcenter,
cuasMotion.getNoiseNeibs(), // final int [] noise_neibs,
// cuasMotion.getNoiseMap(), // final double [] noise_map,
// noisemax, // final double noise_max,
target_horizon, // final double lma_horizon, // horizon as maximal pixel Y
cuasMotion.tilesX); // final int tilesX,
getScore(
......@@ -8528,6 +8503,15 @@ public class CuasMotion {
sortMultiTargets(
target_sequence_multi, // final double [][][][] target_multi,
true); // final boolean trim_nulls) { // trim null targets
int [] num_duplicates = removeWeakerDuplicates( // needs sortMultiTargets and after
target_sequence_multi, // final double [][][][] target_multi,
duplicate_tolerance); // final double pix_tolerance)
if (debugLevel > -4) System.out.println("Removed "+num_duplicates[1]+" good duplicate targets (total with bad - "+num_duplicates[0]+").");
sortMultiTargets(
target_sequence_multi, // final double [][][][] target_multi,
true); // final boolean trim_nulls) { // trim null targets
trimTargets( // limit number of targets per tile
target_sequence_multi, // final double [][][][] target_multi,
trim_first); // final int max_targets) {
......@@ -8576,7 +8560,6 @@ public class CuasMotion {
}
int [][] filter5 = filter5Targets( // will ignore failed tiles
// null, // motion_sequence, // final double [][][] target_sequence,
target_sequence_multi, // final double [][][][] target_sequence_multi,non-centered marked as "used"
// if use motion and select_new will only consider tiles (and compare motion scores in motion_sequence) that have nulls in target_sequence_multi[nseq][ntile]
// if not use motion and select_new will only consider (and compare scores) tiles that have [RSLT_CENTERED] = 0.0
......@@ -8624,9 +8607,6 @@ public class CuasMotion {
break;
}
// render and process in centered mode
// double [][][] targets_nonoverlap = applyFilter( // motion vectors // will have nulls not top try
// motion_sequence, // double [][][] motion_scan,
// filter5); // boolean [][] filter5)
double [][][] targets_nonoverlap = applyFilter( // motion vectors // will have nulls not top try
target_sequence_multi, // double [][][][] target_sequence_multi
......@@ -8651,7 +8631,7 @@ public class CuasMotion {
// By Claude on 05/05/2026 — re-correlate with spatial mask around known target
if (recalc_mv_num > 0) {
effective_boost = recalc_mv_boost; // virtual exposure scale used in refineMotionVectors()
int corr_offset_scale = (int) Math.round(recalc_mv_boost); // TODO: promote to config or derive from other params
// int corr_offset_scale = (int) Math.round(recalc_mv_boost); // TODO: promote to config or derive from other params
refineMotionVectors(
clt_parameters, // CLTParameters clt_parameters,
batch_mode, // boolean batch_mode,
......@@ -8792,8 +8772,6 @@ public class CuasMotion {
slow_score, // double slow_score,
batch_mode, // boolean batch_mode,
debugLevel); // int debugLevel);
//int
num_new += addNewResults(
target_sequence_multi, // final double [][][] target_sequence, // will only process non-nulls here
targets_new_multi, // final double [][][] new_sequence,
......@@ -8807,7 +8785,6 @@ public class CuasMotion {
}
}
if (accum_base) {
// int corr_offset_scale = 4; // (int) Math.round(recalc_mv_boost); // TODO: promote to config or derive from other params
// Andrey 05/05/2026 moved here (earlier) so shiftAndRenderAccumulate() will use updated motion vector
// By Claude on 05/05/2026 — re-correlate with spatial mask around known target
if (recalc_mv_num > 0) {
......@@ -9220,9 +9197,6 @@ public class CuasMotion {
// new results are sorted by decreasing amplitude, there should be only one - test it. If not still use only the first
// continue niter for "when"
// keep only one (best) result for centered getAccumulatedCoordinatesMulti()
if (save_filtered_low && debug_more) {
String title = model_prefix+"-NEW-TARGETS"+(centered?"-CENTERED":"")+"-n"+niter;
if (boost_accum_pairs > 1.0) {
......@@ -9301,349 +9275,7 @@ public class CuasMotion {
* @param debugLevel
* @return
*/
/*
@Deprecated
public static int [][] filter5Targets( // should work for motion vectors and target coordinates returns index of selected target or -1 for unselected
final double [][][] motion_sequence, // may be null
final double [][][][] target_sequence_multi, // not null
// if use motion and select_new will only consider tiles (and compare motion scores in motion_sequence) that have nulls in target_sequence_multi[nseq][ntile]
// if not use motion and select_new will only consider (and compare scores) tiles that have [RSLT_CENTERED] = 0.0. After selection will mark those as
// if not select_new (assumes not use motion) will return best (and good) target indices
final boolean use_motion_in, // true - use motion vectors confidence, false - use target confidence
final boolean select_new_in, // true - use only untested tiles, false - use good tiles
// when using good ones - will select first good one (best if correctly ordered)
final double min_confidence, // 0 OK
final double lma_horizon, // target below horizon
final int tilesX,
final int range, // 1 or 2
final int [] remain,
final int [] passes, // debugging - number of passes required
final int debugLevel){
final boolean use_motion = use_motion_in; // By Claude on 05/07/2026: decouple from motion_sequence presence
final boolean select_new = select_new_in; // By Claude on 05/07/2026: decouple from motion_sequence
boolean debug_now = (debugLevel<5);
final int num_seq = target_sequence_multi.length;
final int num_tiles = target_sequence_multi[0].length;
final int tilesY = num_tiles/ tilesX;
final int [][] filter5 = new int [num_seq][num_tiles];
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
final int dbg_tile = debug_now ?(51+38*80) : -1;
final int dbg_seq0 = debug_now ? 27: -1;
final int dbg_seq1 = debug_now ? 29: -1;
final int ihorizon = (lma_horizon > 0) ?( (int) Math.ceil(lma_horizon/GPUTileProcessor.DTT_SIZE)) : -1; // tiles with tileY >= ihorizon are removed
if (dbg_tile >=0) {
System.out.println("filter5Targets()):00: use_motion="+use_motion+", select_new="+select_new+", ihorizon="+ihorizon);
}
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
TileNeibs tn = new TileNeibs(tilesX, tilesY);
boolean [] prohibit = new boolean [num_tiles];
for (int nSeq = ai.getAndIncrement(); nSeq < num_seq; nSeq = ai.getAndIncrement()) {
Arrays.fill(filter5[nSeq], -1);
double [][] motion = (motion_sequence != null) ? motion_sequence[nSeq] : null;
int num_total = 0;
Arrays.fill(prohibit, false);
// set initially prohibited tiles - ones not to consider when competing
for (int ntile = 0; ntile < num_tiles; ntile++) {
if ((motion != null) && ((motion[ntile] == null) || !(motion[ntile][CuasMotionLMA.RSLT_MSCORE] >= min_confidence))) { // defined: good or bad
if ((ntile == dbg_tile) && (nSeq >= dbg_seq0) && (nSeq <= dbg_seq1)) {
System.out.println("filter5Targets()):0: ntile="+ntile+", nSeq="+nSeq);
}
prohibit[ntile] = true;
} else if (select_new){
if (use_motion ) {
if (motion != null) { // original path: prohibit already-tested tiles
if (target_sequence_multi[nSeq][ntile] != null) {
prohibit[ntile] = true;
}
} else { // By Claude on 05/07/2026: motion==null, find FAIL_PENDING+CENTERED_NO sentinels
boolean has_pending = false;
double [][] targets = target_sequence_multi[nSeq][ntile];
if (targets != null) {
for (int i = 0; i < targets.length; i++) if (targets[i] != null) {
if (targets[i][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_PENDING &&
targets[i][CuasMotionLMA.RSLT_CENTERED] == CuasMotionLMA.CENTERED_NO) {
has_pending = true;
break;
}
}
}
prohibit[ntile] |= !has_pending;
}
} else { // !use_motion - find if it has at least one good with that have [RSLT_CENTERED] = 0.0
boolean prohibit_this = true;
double [][] targets = target_sequence_multi[nSeq][ntile];
if (targets != null) {
for (int i = 0; i < targets.length; i++) if (targets[i] != null) {
if ((targets[i][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE) && (targets[i][CuasMotionLMA.RSLT_CENTERED] == CuasMotionLMA.CENTERED_NO)) {
prohibit_this = false; // still have some potential targets that were not tried in centered mode
}
}
}
prohibit[ntile] |= prohibit_this;
}
} else { // valid motion (or motion_sequence==null), not select new - prohibit if no good targets for this tile
boolean prohibit_this = true;
double [][] targets = target_sequence_multi[nSeq][ntile];
if (targets != null) {
for (int i = 0; i < targets.length; i++) if (targets[i] != null){
if ((targets[i][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE) &&
(targets[i][CuasMotionLMA.RSLT_CENTERED] != CuasMotionLMA.CENTERED_USED)) {
prohibit_this = false; // still have some potential targets that were not tried in centered mode
break;
}
}
}
prohibit[ntile] |= prohibit_this;
}
}
// is it still used?
if ((ihorizon > 0) && (ihorizon < tilesY)) {
Arrays.fill(prohibit, ihorizon*tilesX, num_tiles, true);
}
if ((nSeq >= dbg_seq0) && (nSeq <= dbg_seq1)) {
System.out.println("filter5Targets()):2: nSeq="+nSeq);
}
int num_this_pass = 0;
int npass = 0;
do {
npass++;
num_this_pass = 0;
for (int tileY = 0; tileY < tilesY; tileY++) {
for (int tileX = 0; tileX < tilesX; tileX++) {
int ntile = tileX + tilesX * tileY;
if ((ntile == dbg_tile) && (nSeq >= dbg_seq0) && (nSeq <= dbg_seq1)) {
System.out.println("filter5Targets()):1: ntile="+ntile+", nSeq="+nSeq+", npass="+npass+", num_this_pass="+num_this_pass+", num_total="+num_total);
}
if (!prohibit[ntile]) { // targets[ntile][conf_index] >0 here by the prohibit preset
boolean ismax = true;
if (select_new) {
if (use_motion) {
if (motion != null) {
check_max_motion:{
double cval = motion[ntile][CuasMotionLMA.RSLT_MSCORE] - min_confidence;
if (cval <= 0) {
ismax = false;
prohibit[ntile] = true; // not needed
break check_max_motion;
}
for (int dy = -range; dy <= range; dy++) {
for (int dx = -range; dx <= range; dx++) {
int indx = tn.getNeibIndex(ntile, dx, dy);
if ((indx >= 0) && !prohibit[indx]) {
double val = motion[indx][CuasMotionLMA.RSLT_MSCORE]- min_confidence;
if (val > cval) {
ismax = false;
break check_max_motion;
}
}
}
}
filter5[nSeq][ntile] = 0;
}
} else { // By Claude on 05/07/2026: motion==null, rank FAIL_PENDING+CENTERED_NO sentinels by QSCORE
double [][] targets = target_sequence_multi[nSeq][ntile];
if (targets != null) {
int best_pending = -1;
check_max_pending:{
for (int ntarg = 0; ntarg < targets.length; ntarg++) if (targets[ntarg] != null &&
targets[ntarg][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_PENDING &&
targets[ntarg][CuasMotionLMA.RSLT_CENTERED] == CuasMotionLMA.CENTERED_NO) {
double qval = targets[ntarg][CuasMotionLMA.RSLT_QSCORE];
if ((best_pending < 0) || (qval > targets[best_pending][CuasMotionLMA.RSLT_QSCORE])) {
best_pending = ntarg;
}
}
if (best_pending < 0) {
ismax = false;
prohibit[ntile] = true;
break check_max_pending;
}
double cval = targets[best_pending][CuasMotionLMA.RSLT_QSCORE] - min_confidence;
if (cval <= 0) {
ismax = false;
prohibit[ntile] = true;
break check_max_pending;
}
for (int dy = -range; dy <= range; dy++) {
for (int dx = -range; dx <= range; dx++) {
int ntile1 = tn.getNeibIndex(ntile, dx, dy);
if ((ntile1 >= 0) && !prohibit[ntile1]) {
double [][] other_targets = target_sequence_multi[nSeq][ntile1];
if (other_targets != null) {
for (int ntarg = 0; ntarg < other_targets.length; ntarg++) if (other_targets[ntarg] != null &&
other_targets[ntarg][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_PENDING &&
other_targets[ntarg][CuasMotionLMA.RSLT_CENTERED] == CuasMotionLMA.CENTERED_NO) {
double val = other_targets[ntarg][CuasMotionLMA.RSLT_QSCORE];
if (val > cval + min_confidence) {
ismax = false;
break check_max_pending;
}
}
}
}
}
}
filter5[nSeq][ntile] = best_pending;
} // check_max_pending
} else {
prohibit[ntile] = true;
}
}
} else { // not using motion, only consider non-centered good tiles
double [][] targets = target_sequence_multi[nSeq][ntile];
if (targets != null) {
// find the best non-centered good target in this tile
int best_targ = -1;
check_max_target:{
for (int ntarg = 0; ntarg < targets.length; ntarg++) if ((targets[ntarg] != null) &&
(targets[ntarg][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE) &&
(targets[ntarg][CuasMotionLMA.RSLT_CENTERED] == CuasMotionLMA.CENTERED_NO)) {
double cval = targets[ntarg][CuasMotionLMA.RSLT_QSCORE];
if ((cval > 0) && ((best_targ <0) || (cval > targets[best_targ][CuasMotionLMA.RSLT_QSCORE]))) {
best_targ = ntarg;
}
}
if (best_targ < 0) {
ismax = false;
prohibit[ntile] = true; // not needed
break check_max_target;
}
double cval = targets[best_targ][CuasMotionLMA.RSLT_QSCORE];
for (int dy = -range; dy <= range; dy++) {
for (int dx = -range; dx <= range; dx++) {
int ntile1 = tn.getNeibIndex(ntile, dx, dy);
if ((ntile1 >= 0) && !prohibit[ntile1]) {
// targets = target_sequence_multi[nSeq][ntile]; // other targets
double [][] other_targets = target_sequence_multi[nSeq][ntile1]; // other targets
if (other_targets != null) {
for (int ntarg = 0; ntarg < other_targets.length; ntarg++) if ((other_targets[ntarg] != null) &&
(other_targets[ntarg][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE) &&
(other_targets[ntarg][CuasMotionLMA.RSLT_CENTERED] == CuasMotionLMA.CENTERED_NO)) {
double val = other_targets[ntarg][CuasMotionLMA.RSLT_QSCORE];
if (val > cval) {
ismax = false;
break check_max_target;
}
}
}
}
}
}
filter5[nSeq][ntile] = best_targ;
} // check_max_target:{
} else {
prohibit[ntile] = true; // probably not needed
}
}
} else {//if (select_new) find best good target (assuming non-motion)
double [][] targets = target_sequence_multi[nSeq][ntile];
if (targets != null) {
// find the best good target in this tile ?
int best_targ = -1;
check_max_target_any:{
for (int ntarg = 0; ntarg < targets.length; ntarg++) if ((targets[ntarg] != null) &&
(targets[ntarg][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE) &&
(targets[ntarg][CuasMotionLMA.RSLT_CENTERED] != CuasMotionLMA.CENTERED_USED)) {
double cval = targets[ntarg][CuasMotionLMA.RSLT_QSCORE];
if ((cval > 0) && ((best_targ <0) || (cval > targets[best_targ][CuasMotionLMA.RSLT_QSCORE]))) {
best_targ = ntarg;
}
}
if (best_targ < 0) {
ismax = false;
prohibit[ntile] = true; // not needed
break check_max_target_any;
}
double cval = targets[best_targ][CuasMotionLMA.RSLT_QSCORE];
for (int dy = -range; dy <= range; dy++) {
for (int dx = -range; dx <= range; dx++) {
int ntile1 = tn.getNeibIndex(ntile, dx, dy);
if ((ntile1 >= 0) && !prohibit[ntile1]) {
// targets = target_sequence_multi[nSeq][ntile1]; // other targets
double [][] other_targets = target_sequence_multi[nSeq][ntile1]; // other targets
if (other_targets != null) {
for (int ntarg = 0; ntarg < other_targets.length; ntarg++) if ((other_targets[ntarg] != null) &&
(other_targets[ntarg][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE) &&
(other_targets[ntarg][CuasMotionLMA.RSLT_CENTERED] != CuasMotionLMA.CENTERED_USED)) {
double val = other_targets[ntarg][CuasMotionLMA.RSLT_QSCORE];
if (val > cval) {
ismax = false;
break check_max_target_any;
}
}
}
}
}
}
filter5[nSeq][ntile] = best_targ;
} // check_max_target_any
}
} //if (select_new) else
if (ismax) {
// filter5[nSeq][ntile] = true; // ismax; already set
// prohibit all around, including this one
for (int dy = -range; dy <= range; dy++) {
for (int dx = -range; dx <= range; dx++) {
int indx = tn.getNeibIndex(ntile, dx, dy);
if (indx >= 0) { // && ((filtered == null) || !filtered[nSeq][indx])){
prohibit[indx] = true;
}
}
}
num_this_pass++;
}
} // if (!prohibit[ntile]) { // targets[ntile][conf_index] >0 here by the prohibit preset
} // for (int tileX = 0; tileX < tilesX; tileX++)
} // for (int tileY = 0; tileY < tilesY; tileY++) {
num_total+=num_this_pass;
} while (num_this_pass > 0);
if (remain != null) {
remain[nSeq] = num_total;
}
if (passes != null) {
passes[nSeq] = npass;
}
}
}
};
}
ImageDtt.startAndJoin(threads);
// By Claude on 05/07/2026: also mark FAIL_PENDING sentinels when use_motion=true, motion==null
if (select_new && (!use_motion || (motion_sequence == null))) {
ai.set(0);
// mark selected targets as "used" (CENTERED_USED): FAIL_NONE+CENTERED_NO or FAIL_PENDING+CENTERED_NO
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nSeq = ai.getAndIncrement(); nSeq < num_seq; nSeq = ai.getAndIncrement()) {
for (int ntile = 0; ntile < num_tiles; ntile++) { // if (target_sequence[nSeq][ntile] != null) {
if ((ntile == dbg_tile)&& (nSeq >= dbg_seq0) && (nSeq <= dbg_seq1)) {
System.out.println("filter5Targets()):4: filter5["+nSeq+"]["+ntile+"]="+filter5[nSeq][ntile]);
}
if (filter5[nSeq][ntile] >= 0) {
target_sequence_multi[nSeq][ntile][filter5[nSeq][ntile]][CuasMotionLMA.RSLT_CENTERED] = CuasMotionLMA.CENTERED_USED;
if ((ntile == dbg_tile) && (nSeq >= dbg_seq0) && (nSeq <= dbg_seq1)) {
System.out.println("target_sequence_multi["+nSeq+"]["+ntile+"]["+filter5[nSeq][ntile]+"]["+CuasMotionLMA.RSLT_CENTERED+"] ="+
target_sequence_multi[nSeq][ntile][filter5[nSeq][ntile]][CuasMotionLMA.RSLT_CENTERED]);
}
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
}
return filter5;
}
*/
// removing final double [][][] motion_sequence, // AF 05/22/2026
public static int [][] filter5Targets( // should work for motion vectors and target coordinates returns index of selected target or -1 for unselected
final double [][][][] target_sequence_multi, // not null
// if use motion and select_new will only consider tiles (and compare motion scores in motion_sequence) that have nulls in target_sequence_multi[nseq][ntile]
......@@ -9782,62 +9414,7 @@ public class CuasMotion {
// Also mark used
target_sequence_multi[nSeq][ntile][0][CuasMotionLMA.RSLT_CENTERED] = CuasMotionLMA.CENTERED_USED;
}
/*
// By Claude on 05/07/2026: motion==null, rank FAIL_PENDING+CENTERED_NO sentinels by QSCORE
double [][] targets = target_sequence_multi[nSeq][ntile];
if (targets != null) {
int best_pending = -1;
check_max_pending:{
for (int ntarg = 0; ntarg < targets.length; ntarg++) if (targets[ntarg] != null &&
targets[ntarg][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_PENDING &&
targets[ntarg][CuasMotionLMA.RSLT_CENTERED] == CuasMotionLMA.CENTERED_NO) {
double qval = targets[ntarg][CuasMotionLMA.RSLT_QSCORE];
if ((best_pending < 0) || (qval > targets[best_pending][CuasMotionLMA.RSLT_QSCORE])) {
best_pending = ntarg;
}
}
if (best_pending < 0) {
ismax = false;
prohibit[ntile] = true;
break check_max_pending;
}
double cval = targets[best_pending][CuasMotionLMA.RSLT_QSCORE] - min_confidence;
if (cval <= 0) {
ismax = false;
prohibit[ntile] = true;
break check_max_pending;
}
for (int dy = -range; dy <= range; dy++) {
for (int dx = -range; dx <= range; dx++) {
int ntile1 = tn.getNeibIndex(ntile, dx, dy);
if ((ntile1 >= 0) && !prohibit[ntile1]) {
double [][] other_targets = target_sequence_multi[nSeq][ntile1];
if (other_targets != null) {
for (int ntarg = 0; ntarg < other_targets.length; ntarg++) if (other_targets[ntarg] != null &&
other_targets[ntarg][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_PENDING &&
other_targets[ntarg][CuasMotionLMA.RSLT_CENTERED] == CuasMotionLMA.CENTERED_NO) {
double val = other_targets[ntarg][CuasMotionLMA.RSLT_QSCORE];
if (val > cval + min_confidence) {
ismax = false;
break check_max_pending;
}
}
}
}
}
}
filter5[nSeq][ntile] = best_pending;
} // check_max_pending
} else {
prohibit[ntile] = true;
}
*/
} else { // not using motion, only consider non-centered good tiles
// double [][] targets = target_sequence_multi[nSeq][ntile];
if (targets != null) {
// find the best non-centered good target in this tile
int best_targ = -1;
......@@ -10007,7 +9584,6 @@ public class CuasMotion {
}
// mark all "used" targets (non-centered, after all centered are added) as failed
public static void failUsed(
final double [][][][] target_sequence) {
......
......@@ -72,7 +72,7 @@ public class CuasMotionLMA {
public static final int RSLT_ITERS = 10;
public static final int RSLT_CENTERED=11; //1: this target was evaluated in centered mode, 0 - was in non-centered, -1 - consumed in non-centered
// add
public static final int RSLT_BOOST= 12; // target accumulated with boosted "exposure time" (based scaled this)
public static final int RSLT_EBOOST= 12; // target accumulated with boosted "exposure time" (based scaled this)
public static final int RSLT_CENT_X = 13;
public static final int RSLT_CENT_Y = 14;
public static final int RSLT_CENT_MX= 15;
......@@ -133,7 +133,9 @@ public class CuasMotionLMA {
public static final int RSLT_PHASE1_AMP = 69; // target index in phase 1 (to set minimal score for phase 1) - debug feature
public static final int RSLT_PHASE1_MSCORE = 70; // target index in phase 1 (to set minimal score for phase 1) - debug feature
public static final int RSLT_PHASE1_VSTR = 71; // target index in phase 1 (to set minimal score for phase 1) - debug feature
public static final int RSLT_LEN = RSLT_PHASE1_VSTR + 1;
public static final int RSLT_PHASE1_VBOOST = 72; // target index in phase 1 (to set minimal score for phase 1) - debug feature
public static final int RSLT_PHASE1_EBOOST = 73; // target index in phase 1 (to set minimal score for phase 1) - debug feature
public static final int RSLT_LEN = RSLT_PHASE1_EBOOST + 1;
public static final String [] LMA_TITLES =
{"X-OFFS","Y-OFFS", "AMPLITUDE", "RADIUS","RAD_POS", "OVERSHOOT","OFFSET","RMSE","RMSE/A","MAX2A","ITERATIONS",
......@@ -153,7 +155,8 @@ public class CuasMotionLMA {
"segment-length","segment-disparity","segment_disp-diff", "segment-strength", "segment-range",
"FLOG-px","FLOG-pY","FLOG-DISP","FLOG-range","infinity",
"GTarget-ID","Vel-away", "Vel-right", "Vel-up","Range-linear",
"Phase1-index","Phase1-score","Phase1-amplitude","Phase1-mscore","Phase1-vstr"};
"Phase1-index","Phase1-score","Phase1-amplitude","Phase1-mscore","Phase1-vstr",
"Phase1-vboost", "Phase1-exp_boost"};
public static final String EXTRA_SLICE_DISCARD_ON_LOAD = "Targets";
public static final int FAIL_PENDING = -1; // By Claude on 05/07/2026: motion sentinel — tile tracked but not yet processed by LMA
public static final int FAIL_NONE = 0;
......
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