Commit 9196f324 authored by Andrey Filippov's avatar Andrey Filippov

Found but not yet fixed getHalfBeforeAfterPixXY() velocities to

coordinates relation
parent cd4e13ef
...@@ -97,13 +97,14 @@ public class CuasMotion { ...@@ -97,13 +97,14 @@ public class CuasMotion {
final static public int TARGET_ID = 15; final static public int TARGET_ID = 15;
final static public int TARGET_LENGTH = TARGET_ID+1; final static public int TARGET_LENGTH = TARGET_ID+1;
final static public int IMPORTANCE_A = 0; final static public int IMPORTANCE_MV = 0;
final static public int IMPORTANCE_RMS = 1; final static public int IMPORTANCE_A = 1;
final static public int IMPORTANCE_RMS_A = 2; final static public int IMPORTANCE_RMS = 2;
final static public int IMPORTANCE_CENTER = 3; final static public int IMPORTANCE_RMS_A = 3;
final static public int IMPORTANCE_MISMATCH = 4; final static public int IMPORTANCE_CENTER = 4;
final static public int IMPORTANCE_MATCH_LEN= 5; final static public int IMPORTANCE_MISMATCH = 5;
final static public int IMPORTANCE_TRAVEL= 6; final static public int IMPORTANCE_MATCH_LEN= 6;
final static public int IMPORTANCE_TRAVEL= 7;
final static public int IMPORTANCE_LENGTH = IMPORTANCE_TRAVEL + 1; final static public int IMPORTANCE_LENGTH = IMPORTANCE_TRAVEL + 1;
final static public int TOTALS_ALL = 0; final static public int TOTALS_ALL = 0;
...@@ -2137,7 +2138,7 @@ public class CuasMotion { ...@@ -2137,7 +2138,7 @@ public class CuasMotion {
debugLevel); // final int debug_level debugLevel); // final int debug_level
// Indices into TDCorrTile.getMismatchVector() result {vx, vy, strength, fraction} // By Claude on 05/08/2026 // Indices into TDCorrTile.getMismatchVector() result {vx, vy, strength, fraction} // By Claude on 05/08/2026
final int INDX_VX = 0, INDX_VY = 1, INDX_STRENGTH = 2, INDX_FRAC = 3; // final int INDX_VX = 0, INDX_VY = 1, INDX_STRENGTH = 2, INDX_FRAC = 3;
double [][] vector_field = TDCorrTile.getMismatchVector( // full tiles in gpu (512*512) double [][] vector_field = TDCorrTile.getMismatchVector( // full tiles in gpu (512*512)
corr_tiles_pd, // final double[][] tiles, corr_tiles_pd, // final double[][] tiles,
rstr, // double rmax, rstr, // double rmax,
...@@ -2149,10 +2150,10 @@ public class CuasMotion { ...@@ -2149,10 +2150,10 @@ public class CuasMotion {
double [] target = CuasMotionLMA.getEmpty(); double [] target = CuasMotionLMA.getEmpty();
// Store the raw displacement over one correlation-pair separation // Store the raw displacement over one correlation-pair separation
// (cuas_corr_offset scenes). Convert later with getFrameVelocityScale() // (cuas_corr_offset scenes). Convert later with getFrameVelocityScale()
target[CuasMotionLMA.RSLT_VX] = vector_field[ntile][INDX_VX] * scale_vxy; target[CuasMotionLMA.RSLT_VX] = vector_field[ntile][TDCorrTile.INDX_VX] * scale_vxy;
target[CuasMotionLMA.RSLT_VY] = vector_field[ntile][INDX_VY] * scale_vxy; target[CuasMotionLMA.RSLT_VY] = vector_field[ntile][TDCorrTile.INDX_VY] * scale_vxy;
target[CuasMotionLMA.RSLT_VSTR] = vector_field[ntile][INDX_STRENGTH]; target[CuasMotionLMA.RSLT_VSTR] = vector_field[ntile][TDCorrTile.INDX_STR];
target[CuasMotionLMA.RSLT_VFRAC] = vector_field[ntile][INDX_FRAC]; target[CuasMotionLMA.RSLT_VFRAC] = vector_field[ntile][TDCorrTile.INDX_FRAC];
target[CuasMotionLMA.RSLT_VBOOST] = boost_pairs; // save what boost for the number of pairs was used target[CuasMotionLMA.RSLT_VBOOST] = boost_pairs; // save what boost for the number of pairs was used
targets[nscan][ntile] = target; targets[nscan][ntile] = target;
} }
...@@ -2195,6 +2196,11 @@ public class CuasMotion { ...@@ -2195,6 +2196,11 @@ public class CuasMotion {
int corr_offset, // inter-frame distance for correlation pairs int corr_offset, // inter-frame distance for correlation pairs
int corr_offset_scale, int corr_offset_scale,
double mv_diff_max, // if > 0, fail for high MV correction double mv_diff_max, // if > 0, fail for high MV correction
// next 4 -to calulate RSLT_MSCORE, similar to setEffectiveStrengthMV
double min_score_mv,
double speed_min,
double speed_pref,
double speed_boost,
String dbg_suffix, String dbg_suffix,
int dbg_iter_index, // to generate different image names for different iteration to simplify "save as" images int dbg_iter_index, // to generate different image names for different iteration to simplify "save as" images
int debugLevel) { int debugLevel) {
...@@ -2217,8 +2223,8 @@ public class CuasMotion { ...@@ -2217,8 +2223,8 @@ public class CuasMotion {
final int corr_offset_eff = corr_offset * Math.max(1, Math.min(corr_offset_scale, corr_pairs_ref / corr_offset)); final int corr_offset_eff = corr_offset * Math.max(1, Math.min(corr_offset_scale, corr_pairs_ref / corr_offset));
// Hard-coded debug selectors: set >= 0 to enable per-scan/per-tile visualisation // Hard-coded debug selectors: set >= 0 to enable per-scan/per-tile visualisation
final int dbg_nseq = 161; // 36; // 28; // 97; // 40; // 41; // 157; // -(116); // 57; // 20; // -1; final int dbg_nseq = 125; // 100; // 161; // 36; // 28; // 97; // 40; // 41; // 157; // -(116); // 57; // 20; // -1;
final int dbg_tile = 55+38*80; // 51+38*80; // 54+38*80; //52+38*80; // 50+38*80; // 55+38*80; // -(17 + 33*80); // 48+32*80; // 50+38*80; // -1; final int dbg_tile = 15+33*80; // 12+37*80; //55+38*80; // 51+38*80; // 54+38*80; //52+38*80; // 50+38*80; // 55+38*80; // -(17 + 33*80); // 48+32*80; // 50+38*80; // -1;
final int corr_offset_scale_eff = corr_offset_eff / corr_offset; // actual scale after clamping final int corr_offset_scale_eff = corr_offset_eff / corr_offset; // actual scale after clamping
if ((dbg_nseq < 0) || (dbg_nseq >= targets_nonoverlap.length) || (dbg_tile < 0) || (dbg_tile >= targets_nonoverlap[dbg_nseq].length)) { if ((dbg_nseq < 0) || (dbg_nseq >= targets_nonoverlap.length) || (dbg_tile < 0) || (dbg_tile >= targets_nonoverlap[dbg_nseq].length)) {
debugLevel = -2; debugLevel = -2;
...@@ -2420,7 +2426,7 @@ public class CuasMotion { ...@@ -2420,7 +2426,7 @@ public class CuasMotion {
} }
// Indices into TDCorrTile.getMismatchVector() result {vx, vy, strength, fraction} // By Claude on 05/08/2026 // Indices into TDCorrTile.getMismatchVector() result {vx, vy, strength, fraction} // By Claude on 05/08/2026
final int INDX_VX = 0, INDX_VY = 1, INDX_STR=2; // final int INDX_VX = 0, INDX_VY = 1, INDX_STR=2, INDX_FRAC = 3;;
double[][] vector_field = TDCorrTile.getMismatchVector( double[][] vector_field = TDCorrTile.getMismatchVector(
corr_tiles_pd, corr_tiles_pd,
-rstr, // rmax < 0: no relative-strength filter (same convention as getTargetsFromCorr2d) -rstr, // rmax < 0: no relative-strength filter (same convention as getTargetsFromCorr2d)
...@@ -2435,20 +2441,29 @@ public class CuasMotion { ...@@ -2435,20 +2441,29 @@ public class CuasMotion {
double[] target = targets_nonoverlap[nseq][ntile]; double[] target = targets_nonoverlap[nseq][ntile];
if (target == null || Double.isNaN(target[CuasMotionLMA.RSLT_X])) continue; if (target == null || Double.isNaN(target[CuasMotionLMA.RSLT_X])) continue;
if (vector_field[ntile] == null) continue; if (vector_field[ntile] == null) continue;
double scaled_dvx = vector_field[ntile][INDX_VX] / corr_offset_scale; // By Claude on 05/13/2026 double scaled_dvx = vector_field[ntile][TDCorrTile.INDX_VX] / corr_offset_scale; // By Claude on 05/13/2026
double scaled_dvy = vector_field[ntile][INDX_VY] / corr_offset_scale; double scaled_dvy = vector_field[ntile][TDCorrTile.INDX_VY] / corr_offset_scale;
if (ntile == dbg_tile && debugLevel >= 0) { if (ntile == dbg_tile && debugLevel >= 0) {
System.out.printf("refineMotionVectors(): nseq=%3d ntile=%4d before: VX=%9.4f VY=%9.4f delta: dVX=%8.4f dVY=%8.4f after: VX1=%9.4f VY1=%9.4f VSTR=%9.4f\n", String nseq_mark = (nseq == dbg_nseq) ? "*": "";
System.out.printf("refineMotionVectors(): nseq=%3d ntile=%4d before: VX=%9.4f VY=%9.4f delta: dVX=%8.4f dVY=%8.4f after: VX1=%9.4f VY1=%9.4f VSTR=%9.4f %s\n",
nseq, ntile, nseq, ntile,
target[CuasMotionLMA.RSLT_VX], target[CuasMotionLMA.RSLT_VY], target[CuasMotionLMA.RSLT_VX], target[CuasMotionLMA.RSLT_VY],
scaled_dvx, scaled_dvy, scaled_dvx, scaled_dvy,
target[CuasMotionLMA.RSLT_VX] + scaled_dvx, target[CuasMotionLMA.RSLT_VX] + scaled_dvx,
target[CuasMotionLMA.RSLT_VY] + scaled_dvy, target[CuasMotionLMA.RSLT_VY] + scaled_dvy,
vector_field[ntile][INDX_STR]); vector_field[ntile][TDCorrTile.INDX_STR],
nseq_mark);
} }
target[CuasMotionLMA.RSLT_VX] += scaled_dvx; target[CuasMotionLMA.RSLT_VX] += scaled_dvx;
target[CuasMotionLMA.RSLT_VY] += scaled_dvy; target[CuasMotionLMA.RSLT_VY] += scaled_dvy;
target[CuasMotionLMA.RSLT_VSTR] = vector_field[ntile][INDX_STR]; target[CuasMotionLMA.RSLT_VSTR] = vector_field[ntile][TDCorrTile.INDX_STR];
double es = getEffectiveStrengthMV(
target, // double [] target,
speed_min, // double speed_min,
speed_pref, // double speed_pref,
speed_boost); //double speed_boost)
target[CuasMotionLMA.RSLT_MSCORE] = es;
target[CuasMotionLMA.RSLT_VFRAC] = vector_field[ntile][TDCorrTile.INDX_FRAC];
target[CuasMotionLMA.RSLT_VBOOST] = recalc_mv_boost; target[CuasMotionLMA.RSLT_VBOOST] = recalc_mv_boost;
target[CuasMotionLMA.RSLT_VCORR] = Math.sqrt(scaled_dvx*scaled_dvx + scaled_dvy*scaled_dvy); target[CuasMotionLMA.RSLT_VCORR] = Math.sqrt(scaled_dvx*scaled_dvx + scaled_dvy*scaled_dvy);
if ((mv_diff_max > 0) && (target[CuasMotionLMA.RSLT_VCORR] > mv_diff_max) && !(target[CuasMotionLMA.RSLT_FAIL] > 0 )) { if ((mv_diff_max > 0) && (target[CuasMotionLMA.RSLT_VCORR] > mv_diff_max) && !(target[CuasMotionLMA.RSLT_FAIL] > 0 )) {
...@@ -6592,8 +6607,14 @@ public class CuasMotion { ...@@ -6592,8 +6607,14 @@ public class CuasMotion {
ImageDtt.startAndJoin(threads); ImageDtt.startAndJoin(threads);
return; return;
} }
/**
public static int [] removeWeakerDuplicates( // needs sortMultiTargets and after * Removes weaker targets for (almost) same x,y. "Weaker" means later in the targets array, so it needs sortMultiTargets() before.
* It also needs sortMultiTargets() after - to compact the array and remove null targets
* @param target_multi
* @param pix_tolerance
* @return number of removed targets
*/
public static int [] removeWeakerDuplicates( // needs sortMultiTargets before (assuming earlier - stronger) and after (to remove null)
final double [][][][] target_multi, final double [][][][] target_multi,
final double pix_tolerance) { final double pix_tolerance) {
final double pix_tolerance2 = pix_tolerance * pix_tolerance; final double pix_tolerance2 = pix_tolerance * pix_tolerance;
...@@ -6610,20 +6631,24 @@ public class CuasMotion { ...@@ -6610,20 +6631,24 @@ public class CuasMotion {
for (int ntile = 0; ntile < num_tiles; ntile++) { for (int ntile = 0; ntile < num_tiles; ntile++) {
double [][] targets = target_multi[nSeq][ntile]; double [][] targets = target_multi[nSeq][ntile];
if (targets != null) { if (targets != null) {
for (int indx2 = 1; indx2 < targets.length; indx2++) if (targets[indx2] != null) { for (int indx2 = 1; indx2 < targets.length; indx2++) if ((targets[indx2] != null) && (targets[indx2][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE)) {
double tx2 = targets[indx2][CuasMotionLMA.RSLT_X]; double tx2 = targets[indx2][CuasMotionLMA.RSLT_X];
double ty2 = targets[indx2][CuasMotionLMA.RSLT_Y]; double ty2 = targets[indx2][CuasMotionLMA.RSLT_Y];
for (int indx1 = 0; indx1 < indx2; indx1++) if (targets[indx1] != null){ for (int indx1 = 0; indx1 < indx2; indx1++) if ((targets[indx1] != null) && (targets[indx1][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE)){
double tx1 = targets[indx1][CuasMotionLMA.RSLT_X]; double tx1 = targets[indx1][CuasMotionLMA.RSLT_X];
double ty1 = targets[indx1][CuasMotionLMA.RSLT_Y]; double ty1 = targets[indx1][CuasMotionLMA.RSLT_Y];
double dtx = tx2-tx1; double dtx = tx2-tx1;
double dty = ty2-ty1; double dty = ty2-ty1;
double dt2 = dtx*dtx+dty*dty; double dt2 = dtx*dtx+dty*dty;
if (dt2 < pix_tolerance2) {// indx2 is a duplicate, remove its reference from the list if (dt2 < pix_tolerance2) {// indx2 is a duplicate, remove its reference from the list
/*
if ((targets[indx2][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE) && if ((targets[indx2][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE) &&
(targets[indx2][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE)) { (targets[indx2][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE)) {
adup_good.getAndIncrement(); adup_good.getAndIncrement();
} }
*/
// FAIL_NONE for both is now tested above
adup_good.getAndIncrement();
targets[indx2] = null; targets[indx2] = null;
adup.getAndIncrement(); adup.getAndIncrement();
break; // for (int indx1 = 0; indx1 < indx2; indx1++) if (targets[indx1] != null){ break; // for (int indx1 = 0; indx1 < indx2; indx1++) if (targets[indx1] != null){
...@@ -8753,6 +8778,10 @@ public class CuasMotion { ...@@ -8753,6 +8778,10 @@ public class CuasMotion {
corr_offset, // int corr_offset, corr_offset, // int corr_offset,
recalc_mv_icorr, // int corr_offset_scale, recalc_mv_icorr, // int corr_offset_scale,
0, // double mv_diff_max, // if > 0, fail for high MV correction 0, // double mv_diff_max, // if > 0, fail for high MV correction
0, // min_score_mv, // 0, // final double min_score_mv,
speed_min, // double speed_min,
speed_pref, // double speed_pref,
speed_boost, // double speed_boost);
"-first", // String dbg_suffix, "-first", // String dbg_suffix,
niter - niter0, // int dbg_iter_index, niter - niter0, // int dbg_iter_index,
debugLevel); // -1); // debugLevel); // int debugLevel) debugLevel); // -1); // debugLevel); // int debugLevel)
...@@ -8773,6 +8802,10 @@ public class CuasMotion { ...@@ -8773,6 +8802,10 @@ public class CuasMotion {
corr_offset, // int corr_offset, corr_offset, // int corr_offset,
recalc_mv_icorr, // final int corr_offset_scale, recalc_mv_icorr, // final int corr_offset_scale,
recalc_mv_max2, // double mv_diff_max, // if > 0, fail for high MV correction recalc_mv_max2, // double mv_diff_max, // if > 0, fail for high MV correction
0, // min_score_mv, // 0, // final double min_score_mv,
speed_min, // double speed_min,
speed_pref, // double speed_pref,
speed_boost, // double speed_boost);
"-second", // String dbg_suffix, "-second", // String dbg_suffix,
niter - niter0, // int dbg_iter_index, niter - niter0, // int dbg_iter_index,
debugLevel); // -1); // debugLevel); // int debugLevel) debugLevel); // -1); // debugLevel); // int debugLevel)
...@@ -8909,6 +8942,10 @@ public class CuasMotion { ...@@ -8909,6 +8942,10 @@ public class CuasMotion {
corr_offset, // int corr_offset, corr_offset, // int corr_offset,
recalc_mv_icorr, // final int corr_offset_scale, recalc_mv_icorr, // final int corr_offset_scale,
0, // double mv_diff_max, // if > 0, fail for high MV correction 0, // double mv_diff_max, // if > 0, fail for high MV correction
0, // min_score_mv, // 0, // final double min_score_mv,
speed_min, // double speed_min,
speed_pref, // double speed_pref,
speed_boost, // double speed_boost);
"-first", // String dbg_suffix, "-first", // String dbg_suffix,
niter - niter0, // int dbg_iter_index, niter - niter0, // int dbg_iter_index,
debugLevel); // -1); // debugLevel); // int debugLevel) debugLevel); // -1); // debugLevel); // int debugLevel)
...@@ -8929,6 +8966,10 @@ public class CuasMotion { ...@@ -8929,6 +8966,10 @@ public class CuasMotion {
corr_offset, // int corr_offset, corr_offset, // int corr_offset,
recalc_mv_icorr, // final int corr_offset_scale, recalc_mv_icorr, // final int corr_offset_scale,
recalc_mv_max2, // double mv_diff_max, // if > 0, fail for high MV correction recalc_mv_max2, // double mv_diff_max, // if > 0, fail for high MV correction
0, // min_score_mv, // 0, // final double min_score_mv,
speed_min, // double speed_min,
speed_pref, // double speed_pref,
speed_boost, // double speed_boost);
"-second", // String dbg_suffix, "-second", // String dbg_suffix,
niter - niter0, // int dbg_iter_index, niter - niter0, // int dbg_iter_index,
debugLevel); // -1); // debugLevel); // int debugLevel) debugLevel); // -1); // debugLevel); // int debugLevel)
...@@ -9357,8 +9398,8 @@ public class CuasMotion { ...@@ -9357,8 +9398,8 @@ public class CuasMotion {
targets_new_multi, // double [][][] vector_fields_sequence, targets_new_multi, // double [][][] vector_fields_sequence,
cuasMotion.slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null cuasMotion.slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
title, // model_prefix+"-NEW-TARGETS_CENTERED_SCORES_MULTI-n"+niter,// String title, title, // model_prefix+"-NEW-TARGETS_CENTERED_SCORES_MULTI-n"+niter,// String title,
good_only, // final boolean good_only, false, // good_only, // final boolean good_only,
show_empty, // final boolean show_empty, // show scenes with no (valid) targets true, // show_empty, // final boolean show_empty, // show scenes with no (valid) targets
!batch_mode, // boolean show, !batch_mode, // boolean show,
cuasMotion.tilesX); // int tilesX) { cuasMotion.tilesX); // int tilesX) {
cuasMotion.parentCLT.saveImagePlusInModelDirectory(imp_new_scores); // ImagePlus imp) cuasMotion.parentCLT.saveImagePlusInModelDirectory(imp_new_scores); // ImagePlus imp)
...@@ -9785,6 +9826,7 @@ public class CuasMotion { ...@@ -9785,6 +9826,7 @@ public class CuasMotion {
double x = lma_rslts[CuasMotionLMA.RSLT_X]; double x = lma_rslts[CuasMotionLMA.RSLT_X];
double y = lma_rslts[CuasMotionLMA.RSLT_Y]; double y = lma_rslts[CuasMotionLMA.RSLT_Y];
double cxy = 1.0; double cxy = 1.0;
// double MV = lma_rslts[CuasMotionLMA.RSLT_Y];
/* /*
* Filtering by "far" (center belongs to the neighbor tile, not this one) worked well * Filtering by "far" (center belongs to the neighbor tile, not this one) worked well
* except very low above the skyline. In that case the tile below resulted in gross wrong motion vector * except very low above the skyline. In that case the tile below resulted in gross wrong motion vector
...@@ -9900,35 +9942,16 @@ public class CuasMotion { ...@@ -9900,35 +9942,16 @@ public class CuasMotion {
double inv_rms_lim = 1.0 / lma_arms; double inv_rms_lim = 1.0 / lma_arms;
double inv_rel_rms = 1.0 / RMSE_A; // A/RMSE; double inv_rel_rms = 1.0 / RMSE_A; // A/RMSE;
double inv_rel_rms_lim = 1.0 / lma_rrms; double inv_rel_rms_lim = 1.0 / lma_rrms;
quality_factors[IMPORTANCE_A] = Math.max(0,(A- lma_mina)/ lma_mina); quality_factors[IMPORTANCE_A] = Math.max(0,(A- lma_mina)/ lma_mina);
quality_factors[IMPORTANCE_RMS] = Math.max(0,(inv_rms - inv_rms_lim)/ inv_rms_lim); // only >0 for small max-es quality_factors[IMPORTANCE_RMS] = Math.max(0,(inv_rms - inv_rms_lim)/ inv_rms_lim); // only >0 for small max-es
quality_factors[IMPORTANCE_RMS_A] = Math.max(0,(inv_rel_rms - inv_rel_rms_lim)/ inv_rel_rms_lim); // only >0 for small max-es quality_factors[IMPORTANCE_RMS_A] = Math.max(0,(inv_rel_rms - inv_rel_rms_lim)/ inv_rel_rms_lim); // only >0 for small max-es
quality_factors[IMPORTANCE_CENTER] = cxy*cxy; quality_factors[IMPORTANCE_CENTER] = cxy*cxy;
// if (MM_BEFORE <= good_mismatch) {
// quality_factors[IMPORTANCE_MISMATCH] += Math.max(0,(good_mismatch - MM_BEFORE)/good_mismatch); // 0 .. 1
// }
// if (MM_AFTER <= good_mismatch) {
// quality_factors[IMPORTANCE_MISMATCH] += Math.max(0,(good_mismatch - MM_AFTER)/good_mismatch); // 0 .. 1
// }
/// quality_factors[IMPORTANCE_MATCH_LEN] = Math.pow(lma_rslts[CuasMotionLMA.RSLT_MATCH_LENGTH], match_len_pwr);// 1.0 if in every scene
/// quality_factors[IMPORTANCE_TRAVEL] = Math.max((lma_rslts[CuasMotionLMA.RSLT_SEQ_TRAVEL] - seq_travel)/seq_travel, 0);
// final double seq_travel,
} }
// save quality factors // save quality factors
lma_rslts[CuasMotionLMA.RSLT_QA] = quality_factors[IMPORTANCE_A]; lma_rslts[CuasMotionLMA.RSLT_QA] = quality_factors[IMPORTANCE_A];
lma_rslts[CuasMotionLMA.RSLT_QRMS] = quality_factors[IMPORTANCE_RMS]; lma_rslts[CuasMotionLMA.RSLT_QRMS] = quality_factors[IMPORTANCE_RMS];
lma_rslts[CuasMotionLMA.RSLT_QRMS_A] = quality_factors[IMPORTANCE_RMS_A]; lma_rslts[CuasMotionLMA.RSLT_QRMS_A] = quality_factors[IMPORTANCE_RMS_A];
/// lma_rslts[CuasMotionLMA.RSLT_QMATCH] = quality_factors[IMPORTANCE_MISMATCH];
lma_rslts[CuasMotionLMA.RSLT_QCENTER] = quality_factors[IMPORTANCE_CENTER]; lma_rslts[CuasMotionLMA.RSLT_QCENTER] = quality_factors[IMPORTANCE_CENTER];
/// lma_rslts[CuasMotionLMA.RSLT_QMATCH_LEN] = quality_factors[IMPORTANCE_MATCH_LEN];
/// lma_rslts[CuasMotionLMA.RSLT_QTRAVEL] = quality_factors[IMPORTANCE_TRAVEL];
} }
} }
} }
...@@ -9979,6 +10002,9 @@ public class CuasMotion { ...@@ -9979,6 +10002,9 @@ public class CuasMotion {
lma_rslts[CuasMotionLMA.RSLT_QSCORE] = 0; // CuasMotionLMA.FAIL_NONE; lma_rslts[CuasMotionLMA.RSLT_QSCORE] = 0; // CuasMotionLMA.FAIL_NONE;
if (lma_rslts[CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE) { if (lma_rslts[CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE) {
double [] quality_factors = new double [IMPORTANCE_LENGTH]; double [] quality_factors = new double [IMPORTANCE_LENGTH];
if (! Double.isNaN(lma_rslts[CuasMotionLMA.RSLT_MSCORE])) {
quality_factors[IMPORTANCE_MV] = lma_rslts[CuasMotionLMA.RSLT_MSCORE];
}
quality_factors[IMPORTANCE_A] = lma_rslts[CuasMotionLMA.RSLT_QA]; quality_factors[IMPORTANCE_A] = lma_rslts[CuasMotionLMA.RSLT_QA];
quality_factors[IMPORTANCE_RMS] = lma_rslts[CuasMotionLMA.RSLT_QRMS]; quality_factors[IMPORTANCE_RMS] = lma_rslts[CuasMotionLMA.RSLT_QRMS];
quality_factors[IMPORTANCE_RMS_A] = lma_rslts[CuasMotionLMA.RSLT_QRMS_A]; quality_factors[IMPORTANCE_RMS_A] = lma_rslts[CuasMotionLMA.RSLT_QRMS_A];
...@@ -9986,7 +10012,6 @@ public class CuasMotion { ...@@ -9986,7 +10012,6 @@ public class CuasMotion {
quality_factors[IMPORTANCE_CENTER] = lma_rslts[CuasMotionLMA.RSLT_QCENTER]; quality_factors[IMPORTANCE_CENTER] = lma_rslts[CuasMotionLMA.RSLT_QCENTER];
quality_factors[IMPORTANCE_MATCH_LEN]= lma_rslts[CuasMotionLMA.RSLT_QMATCH_LEN]; quality_factors[IMPORTANCE_MATCH_LEN]= lma_rslts[CuasMotionLMA.RSLT_QMATCH_LEN];
quality_factors[IMPORTANCE_TRAVEL]= lma_rslts[CuasMotionLMA.RSLT_QTRAVEL]; quality_factors[IMPORTANCE_TRAVEL]= lma_rslts[CuasMotionLMA.RSLT_QTRAVEL];
for (int i = 0; i < importance.length; i++) { for (int i = 0; i < importance.length; i++) {
if (Double.isNaN(quality_factors[i])) { if (Double.isNaN(quality_factors[i])) {
quality_factors[i] = 0.0; quality_factors[i] = 0.0;
...@@ -10341,13 +10366,49 @@ public class CuasMotion { ...@@ -10341,13 +10366,49 @@ public class CuasMotion {
// Used non-centered tiles are not needed anymore, mark them as failed to simplify processing // Used non-centered tiles are not needed anymore, mark them as failed to simplify processing
failUsed(targets_multi); // final double [][][][] target_sequence) { failUsed(targets_multi); // final double [][][][] target_sequence) {
boolean debug_extra = debugLevel > -5;
if (intermed_low && debug_more && debug_extra) {
ImagePlus imp_dup = showTargetSequence(
targets_multi, // double [][][] vector_fields_sequence,
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
model_prefix+"-AFTER_FAIL_USED",// String title,
false, // good_only, // final boolean good_only,
true, // show_empty, // final boolean show_empty, // show scenes with no (valid) targets
!batch_mode, // boolean show,
cuasMotion.tilesX); // int tilesX) {
parentCLT.saveImagePlusInModelDirectory(imp_dup);
}
sortMultiTargets( sortMultiTargets(
targets_multi, // final double [][][][] target_multi, targets_multi, // final double [][][][] target_multi,
trim_nulls); // final boolean trim_nulls) { // trim null targets trim_nulls); // final boolean trim_nulls) { // trim null targets
if (intermed_low && debug_more && debug_extra) {
ImagePlus imp_dup = showTargetSequence(
targets_multi, // double [][][] vector_fields_sequence,
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
model_prefix+"-AFTER_SORT_MULTI",// String title,
false, // good_only, // final boolean good_only,
true, // show_empty, // final boolean show_empty, // show scenes with no (valid) targets
!batch_mode, // boolean show,
cuasMotion.tilesX); // int tilesX) {
parentCLT.saveImagePlusInModelDirectory(imp_dup);
}
int [] num_duplicates = removeWeakerDuplicates( // needs sortMultiTargets and after int [] num_duplicates = removeWeakerDuplicates( // needs sortMultiTargets and after
targets_multi, // final double [][][][] target_multi, targets_multi, // final double [][][][] target_multi,
duplicate_tolerance); // final double pix_tolerance) duplicate_tolerance); // final double pix_tolerance)
if (intermed_low && debug_more && debug_extra) {
ImagePlus imp_dup = showTargetSequence(
targets_multi, // double [][][] vector_fields_sequence,
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
model_prefix+"-AFTER_DUP",// String title,
false, // good_only, // final boolean good_only,
true, // show_empty, // final boolean show_empty, // show scenes with no (valid) targets
!batch_mode, // boolean show,
cuasMotion.tilesX); // int tilesX) {
parentCLT.saveImagePlusInModelDirectory(imp_dup);
}
if (debugLevel > -4) System.out.println("Removed "+num_duplicates[1]+" good duplicate targets (total with bad - "+num_duplicates[0]+")."); if (debugLevel > -4) System.out.println("Removed "+num_duplicates[1]+" good duplicate targets (total with bad - "+num_duplicates[0]+").");
sortMultiTargets( sortMultiTargets(
targets_multi, // final double [][][][] target_multi, targets_multi, // final double [][][][] target_multi,
...@@ -10516,7 +10577,13 @@ public class CuasMotion { ...@@ -10516,7 +10577,13 @@ public class CuasMotion {
enough_seq, // final int enough_seq, // good regardless of scores enough_seq, // final int enough_seq, // good regardless of scores
seq_travel, // final double seq_travel, seq_travel, // final double seq_travel,
num_good); // final int [] remain){ num_good); // final int [] remain){
if (debugLevel > -4) printStatsLine("converted to single targets per tile", true, num_good); if (debugLevel > -4) {
printStatsLine("converted to single targets per tile before removing shorts", true, num_good);
System.out.println("min_score_lma="+min_score_lma);
System.out.println("enough_seq= "+enough_seq);
System.out.println("seq_travel= "+seq_travel);
}
if (intermed_low) { // save always if (intermed_low) { // save always
ImagePlus imp_failures = showTargetSequence( ImagePlus imp_failures = showTargetSequence(
...@@ -10559,7 +10626,12 @@ public class CuasMotion { ...@@ -10559,7 +10626,12 @@ public class CuasMotion {
enough_seq, // final int enough_seq, // good regardless of scores enough_seq, // final int enough_seq, // good regardless of scores
seq_travel, // final double seq_travel, seq_travel, // final double seq_travel,
num_good); // final int [] remain){ num_good); // final int [] remain){
if (debugLevel > -4) printStatsLine("converted to single targets per tile after removing shorts", true, num_good); if (debugLevel > -4) {
printStatsLine("converted to single targets per tile after removing shorts", true, num_good);
System.out.println("min_score_lma="+min_score_lma);
System.out.println("enough_seq= "+enough_seq);
System.out.println("seq_travel= "+seq_travel);
}
if (intermed_low) { // save always if (intermed_low) { // save always
ImagePlus imp_failures = showTargetSequence( ImagePlus imp_failures = showTargetSequence(
......
...@@ -924,7 +924,7 @@ min_str_neib_fpn 0.35 ...@@ -924,7 +924,7 @@ min_str_neib_fpn 0.35
public double cuas_score_lma = 1.6; // minimal score for the target LMA public double cuas_score_lma = 1.6; // minimal score for the target LMA
public double cuas_factor_lim = 5.0; // limit each individual score factor public double cuas_factor_lim = 5.0; // limit each individual score factor
public double cuas_factor_pow = 1.0; // raise score factor to this power before combining public double cuas_factor_pow = 1.0; // raise score factor to this power before combining
public double [] cuas_score_coeff = {1.0, 0.05, 0.7, 1.5, 2.0, 1.0, 1.0}; //weights of amplitude, RMSE and RMSE/amplitude, center, mismatch, match_length, travel public double [] cuas_score_coeff = {1.0, 0.05, 0.7, 1.5, 2.0, 1.0, 1.0, 1.0}; //weights of amplitude, RMSE and RMSE/amplitude, center, mismatch, match_length, travel, motion score
public boolean cuas_center_targ = true; // re-run target extraction with targets centered to their tiles public boolean cuas_center_targ = true; // re-run target extraction with targets centered to their tiles
public boolean cuas_multi_targ = true; // Use multi-target for each tile mode public boolean cuas_multi_targ = true; // Use multi-target for each tile mode
...@@ -2969,7 +2969,7 @@ min_str_neib_fpn 0.35 ...@@ -2969,7 +2969,7 @@ min_str_neib_fpn 0.35
gd.addNumericField("Raise score factor to this power", this.cuas_factor_pow, 5,8,"", gd.addNumericField("Raise score factor to this power", this.cuas_factor_pow, 5,8,"",
"Raise each score factor to this power before combining them."); "Raise each score factor to this power before combining them.");
gd.addStringField ("Score factors weights", IntersceneMatchParameters.doublesToString(cuas_score_coeff), 80, gd.addStringField ("Score factors weights", IntersceneMatchParameters.doublesToString(cuas_score_coeff), 80,
"Relative importance of LMA amplitude, RMSE and RMSE/ampitude, center, before/after match, sqrt(match length), travel."); "Relative importance of LMA amplitude, RMSE and RMSE/ampitude, center, before/after match, sqrt(match length), travel, motion score.");
gd.addCheckbox ("Center targets in their tiles", this.cuas_center_targ, gd.addCheckbox ("Center targets in their tiles", this.cuas_center_targ,
"Re-run target extraction placing the targets at the center of their tiles."); "Re-run target extraction placing the targets at the center of their tiles.");
gd.addCheckbox ("Multi-target mode", this.cuas_multi_targ, gd.addCheckbox ("Multi-target mode", this.cuas_multi_targ,
......
...@@ -32,6 +32,11 @@ import com.elphel.imagej.gpu.GPUTileProcessor; ...@@ -32,6 +32,11 @@ import com.elphel.imagej.gpu.GPUTileProcessor;
import com.elphel.imagej.gpu.GpuQuad; import com.elphel.imagej.gpu.GpuQuad;
public class TDCorrTile { public class TDCorrTile {
public static int INDX_VX = 0;
public static int INDX_VY = 1;
public static int INDX_STR = 2;
public static int INDX_FRAC = 3;
double weight; double weight;
final double [] data; final double [] data;
......
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