Commit c09cca3b authored by Andrey Filippov's avatar Andrey Filippov

Starting dual-boost centered processing

parent a86749dc
......@@ -2674,7 +2674,8 @@ public class CuasMotion {
double k = Math.PI/2/(half_range_boosted + 0.5);
for (int i = 1; i <= half_range_boosted; i ++) {
window_full[half_range_boosted + i] = smooth ? (Math.cos(i*k)):1.0;
s0+=2 * window_full[half_range_boosted + i];
window_full[half_range_boosted - i] = smooth ? (Math.cos(i*k)):1.0; // By Claude on 05/11/2026
s0+=2 * window_full[half_range_boosted + i];
}
for (int i = 0; i < window_full.length; i ++) {
window_full[i] /= s0;
......@@ -2754,7 +2755,7 @@ public class CuasMotion {
// may be faster if process only where vector_field[nseq][ntile] is not null
for (int nSeq = ai.getAndIncrement(); nSeq < frames_accum.length; nSeq = ai.getAndIncrement()) {
for (int i = 0; i < frames_accum[nSeq].length; i++) {
frames_accum[nSeq][i] *=-1;
frames_accum[nSeq][i] *=-0.625; // By Claude on 05/11/2026: restore pre-fix amplitude (window fix doubled it)
if (zero_fill && Double.isNaN(frames_accum[nSeq][i])){
frames_accum[nSeq][i] = 0f;
}
......@@ -8242,199 +8243,205 @@ public class CuasMotion {
cuasMotion.tilesX); // int tilesX) {
parentCLT.saveImagePlusInModelDirectory(imp_ext);
}
// perform new accumulations of shifted non-conflicting tiles
float [][] fpixels_accumulated = cuasMotion.shiftAndRenderAccumulate(
clt_parameters, // CLTParameters clt_parameters,
true, // false, // final boolean center, // why is it false here?
false, // final boolean fill_zeros,
fpixels_accum, // By Claude on 05/07/2026: LPF'd with accum_ra (was fpixels_tum)
extended_scan, // final double [][][] vector_field,
frame0, // final int frame0, // for vector_field[0]
corr_inc, // final int frame_step, // keep for slow
half_accum_range, // final int half_range, // scale for slow
boost_accum_pairs,// final double boost_pairs,
smooth, // final boolean smooth,
corr_offset, // final int corr_offset, // interframe distance for correlation
true); // final boolean batch_mode) {
if (save_filtered_high) {
String title = model_prefix+"-ACCUMULATED-CENTERED-n"+niter;
if (boost_accum_pairs > 1.0) {
title+="-BOOST"+boost_accum_pairs;
// double [][][][] targets_new_multi = null;
int num_new = 0;
{
// perform new accumulations of shifted non-conflicting tiles
float [][] fpixels_accumulated = cuasMotion.shiftAndRenderAccumulate(
clt_parameters, // CLTParameters clt_parameters,
true, // false, // final boolean center, // why is it false here?
false, // final boolean fill_zeros,
fpixels_accum, // By Claude on 05/07/2026: LPF'd with accum_ra (was fpixels_tum)
extended_scan, // final double [][][] vector_field,
frame0, // final int frame0, // for vector_field[0]
corr_inc, // final int frame_step, // keep for slow
half_accum_range, // final int half_range, // scale for slow
boost_accum_pairs,// final double boost_pairs,
smooth, // final boolean smooth,
corr_offset, // final int corr_offset, // interframe distance for correlation
true); // final boolean batch_mode) {
if (save_filtered_high) {
String title = model_prefix+"-ACCUMULATED-CENTERED-n"+niter;
if (boost_accum_pairs > 1.0) {
title+="-BOOST"+boost_accum_pairs;
}
ImagePlus imp_acc = ShowDoubleFloatArrays.makeArrays(
fpixels_accumulated, // double[][] pixels,
cuasMotion.gpu_max_width,
cuasMotion.gpu_max_height,
title, // model_prefix+"-ACCUMULATED-CENTERED-n"+niter, // String title,
slice_titles);
imp_acc.getProcessor().setMinAndMax(-input_range/2, input_range/2);
if (!batch_mode) {
imp_acc.show();
}
parentCLT.saveImagePlusInModelDirectory(imp_acc); // ImagePlus imp)
}
ImagePlus imp_acc = ShowDoubleFloatArrays.makeArrays(
fpixels_accumulated, // double[][] pixels,
cuasMotion.gpu_max_width,
cuasMotion.gpu_max_height,
title, // model_prefix+"-ACCUMULATED-CENTERED-n"+niter, // String title,
slice_titles);
imp_acc.getProcessor().setMinAndMax(-input_range/2, input_range/2);
if (!batch_mode) {
imp_acc.show();
// replace center frames with the accumulated ones
if (debugLevel > -4) {
System.out.println("Starting render, iteration = "+niter);
}
parentCLT.saveImagePlusInModelDirectory(imp_acc); // ImagePlus imp)
}
// replace center frames with the accumulated ones
if (debugLevel > -4) {
System.out.println("Starting render, iteration = "+niter);
}
// show just fpixels_accumulated
// move outside? compare to slice_titles known
// Calculate both centroid and LMA target parametes, return both
// targets_new will contain motion vectors, centroid, and LMA results combined
//save_filtered_high
// show just fpixels_accumulated
// move outside? compare to slice_titles known
// Calculate both centroid and LMA target parametes, return both
// targets_new will contain motion vectors, centroid, and LMA results combined
//save_filtered_high
float [][] accum_debug = save_filtered_high? new float [num_corr_samples][]:null; //fpixels_accumulated.length]
boolean keep_failed = false; // keep failed targets
double [][][][] targets_new_multi = getAccumulatedCoordinatesMulti(
keep_failed, // final boolean keep_failed, // keep failed targets
niter, // final int when, // set if >=0 for failures
true, // final boolean centered,
targets_nonoverlap, // final double [][][] vector_fields, // centers
fpixels_accumulated, // final double [][] accum_data, // should be around 0, no low-freq
lmax_fraction, // final double cuas_lmax_fraction, // 0.7; // Check if local maximum is separated from tye surrounding by this fraction of the maximum value
lmax_flt_neglim, // final double lmax_flt_neglim, // -0.3; // limit negative data to reduce ridge influence (make -10 to disable)
lmax_flt_hsigma, // final double lmax_flt_hsigma, // 1.0 // HPF (~UM) subtract GB with this sigma from the data tile
lmax_flt_lsigma, // final double lmax_flt_lsigma, // 1.0 // LPF - GB result of the previous subtraction
lmax_flt_scale, // final double lmax_flt_scale, // 5.0 // scale filtering result
cuasMotion.sky_mask, // final double sky_mask,
sky_threshold, // final double sky_threshold, // 0.9 // minimal value of the sky mask where target is possible
target_horizon+filter_below_horizon, // final double lma_horizon,
lmax_hack_ridge, // final double lmax_hack_ridge, // 0.45; // Hack for ridges: remove horizontal streaks, where average(abs()) for the line exceeds fraction of abs max 0.32-good, 0.55 - bad
lmax_radius, // final int cuas_lmax_radius, // 3; // look inside cuas_lmax_radius* 2 + 1 square for the local maximum isolation
lmax_radius, // final double centered_radius,
0.5, // final double centered_radius_blur,
1.0, // final double pix_tolerance, //
// lmax_zero, // final boolean cuas_lmax_zero, // true; // zero all data outside this radius from the maximum
target_radius, // final double centroid_radius,
n_recenter, // final int n_recenter, // re-center window around new maximum. 0 -no refines (single-pass)
cuasMotion.tilesX, // final int tilesX){
no_border, // final boolean no_border,
// Moving target LMA
lma_sigma, // final double lma_sigma,
wnd_pedestal, // final double wnd_pedestal,
lma_r0, // final double lma_r0,
lma_ovrsht, // final double lma_ovrsht,
// CUAS Motion LMA parameters
lma_fit_xy, // final boolean lma_fit_xy,
lma_fit_a, // final boolean lma_fit_a,
lma_fit_c, // final boolean lma_fit_c,
lma_fit_r, // final boolean lma_fit_r,
lma_fit_k, // final boolean lma_fit_k,
lambda, // final double lambda,
lambda_good, // final double lambda_good,
lambda_bad, // final double lambda_bad,
lambda_max, // final double lambda_max,
rms_diff, // final double rms_diff,
num_iter, // final int num_iter,0, // final double pre_min_a, // pre-filter minimal LMA-A (half finbal?)
lma_pre_mina*lma_mina,// final double pre_min_a, // 0.5 //scale cuas_lma_mina to filter initial candidates (if there are > one of them)
min_keep, // final int min_keep, // 2; // keep at least this number of candidates before using cuas_lma_pre_mina filter
accum_debug, // final float [][] accum_debug,
parentCLT, // final QuadCLT parentCLT, // debug only, maybe null in other cases
debugLevel); // final int debugLevel);
if (accum_debug != null) {
String title = model_prefix+"-ACCUMULATED_FILTERED-CENTERED-MULTI-n"+niter;
if (boost_accum_pairs > 1.0) {
title+="-BOOST"+boost_accum_pairs;
}
ImagePlus imp_acc = ShowDoubleFloatArrays.makeArrays(
accum_debug, // double[][] pixels,
cuasMotion.gpu_max_width,
cuasMotion.gpu_max_height,
title, // model_prefix+"-ACCUMULATED_FILTERED-CENTERED-MULTI-n"+niter, // String title,
slice_titles);
imp_acc.getProcessor().setMinAndMax(-input_range/2, input_range/2);
if (!batch_mode) {
imp_acc.show();
float [][] accum_debug = save_filtered_high? new float [num_corr_samples][]:null; //fpixels_accumulated.length]
boolean keep_failed = false; // keep failed targets
double [][][][] targets_new_multi = getAccumulatedCoordinatesMulti(
keep_failed, // final boolean keep_failed, // keep failed targets
niter, // final int when, // set if >=0 for failures
true, // final boolean centered,
targets_nonoverlap, // final double [][][] vector_fields, // centers
fpixels_accumulated, // final double [][] accum_data, // should be around 0, no low-freq
lmax_fraction, // final double cuas_lmax_fraction, // 0.7; // Check if local maximum is separated from tye surrounding by this fraction of the maximum value
lmax_flt_neglim, // final double lmax_flt_neglim, // -0.3; // limit negative data to reduce ridge influence (make -10 to disable)
lmax_flt_hsigma, // final double lmax_flt_hsigma, // 1.0 // HPF (~UM) subtract GB with this sigma from the data tile
lmax_flt_lsigma, // final double lmax_flt_lsigma, // 1.0 // LPF - GB result of the previous subtraction
lmax_flt_scale, // final double lmax_flt_scale, // 5.0 // scale filtering result
cuasMotion.sky_mask, // final double sky_mask,
sky_threshold, // final double sky_threshold, // 0.9 // minimal value of the sky mask where target is possible
target_horizon+filter_below_horizon, // final double lma_horizon,
lmax_hack_ridge, // final double lmax_hack_ridge, // 0.45; // Hack for ridges: remove horizontal streaks, where average(abs()) for the line exceeds fraction of abs max 0.32-good, 0.55 - bad
lmax_radius, // final int cuas_lmax_radius, // 3; // look inside cuas_lmax_radius* 2 + 1 square for the local maximum isolation
lmax_radius, // final double centered_radius,
0.5, // final double centered_radius_blur,
1.0, // final double pix_tolerance, //
// lmax_zero, // final boolean cuas_lmax_zero, // true; // zero all data outside this radius from the maximum
target_radius, // final double centroid_radius,
n_recenter, // final int n_recenter, // re-center window around new maximum. 0 -no refines (single-pass)
cuasMotion.tilesX, // final int tilesX){
no_border, // final boolean no_border,
// Moving target LMA
lma_sigma, // final double lma_sigma,
wnd_pedestal, // final double wnd_pedestal,
lma_r0, // final double lma_r0,
lma_ovrsht, // final double lma_ovrsht,
// CUAS Motion LMA parameters
lma_fit_xy, // final boolean lma_fit_xy,
lma_fit_a, // final boolean lma_fit_a,
lma_fit_c, // final boolean lma_fit_c,
lma_fit_r, // final boolean lma_fit_r,
lma_fit_k, // final boolean lma_fit_k,
lambda, // final double lambda,
lambda_good, // final double lambda_good,
lambda_bad, // final double lambda_bad,
lambda_max, // final double lambda_max,
rms_diff, // final double rms_diff,
num_iter, // final int num_iter,0, // final double pre_min_a, // pre-filter minimal LMA-A (half finbal?)
lma_pre_mina*lma_mina,// final double pre_min_a, // 0.5 //scale cuas_lma_mina to filter initial candidates (if there are > one of them)
min_keep, // final int min_keep, // 2; // keep at least this number of candidates before using cuas_lma_pre_mina filter
accum_debug, // final float [][] accum_debug,
parentCLT, // final QuadCLT parentCLT, // debug only, maybe null in other cases
debugLevel); // final int debugLevel);
if (accum_debug != null) {
String title = model_prefix+"-ACCUMULATED_FILTERED-CENTERED-MULTI-n"+niter;
if (boost_accum_pairs > 1.0) {
title+="-BOOST"+boost_accum_pairs;
}
ImagePlus imp_acc = ShowDoubleFloatArrays.makeArrays(
accum_debug, // double[][] pixels,
cuasMotion.gpu_max_width,
cuasMotion.gpu_max_height,
title, // model_prefix+"-ACCUMULATED_FILTERED-CENTERED-MULTI-n"+niter, // String title,
slice_titles);
imp_acc.getProcessor().setMinAndMax(-input_range/2, input_range/2);
if (!batch_mode) {
imp_acc.show();
}
parentCLT.saveImagePlusInModelDirectory(imp_acc); // ImagePlus imp)
}
parentCLT.saveImagePlusInModelDirectory(imp_acc); // ImagePlus imp)
}
// no need to to evaluate scores now - can be done all at once when all non-centered will be replaced by centered, removed (almost) duplicates
// evaluating scores, but it is not needed
// 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()
// no need to to evaluate scores now - can be done all at once when all non-centered will be replaced by centered, removed (almost) duplicates
// evaluating scores, but it is not needed
// 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-MULTI-n"+niter;
if (boost_accum_pairs > 1.0) {
title+="-BOOST"+boost_accum_pairs;
}
if (save_filtered_low && debug_more) {
String title = model_prefix+"-NEW-TARGETS-CENTERED-MULTI-n"+niter;
if (boost_accum_pairs > 1.0) {
title+="-BOOST"+boost_accum_pairs;
ImagePlus imp_new = showTargetSequence(
targets_new_multi, // final double [][][][] targets_multi,
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
title, // model_prefix+"-NEW-TARGETS-CENTERED-MULTI-n"+niter,// String title,
good_only, // final boolean good_only,
show_empty, // final boolean show_empty, // show scenes with no (valid) targets
!batch_mode, // boolean show,
cuasMotion.tilesX); // int tilesX) {
parentCLT.saveImagePlusInModelDirectory(imp_new); // ImagePlus imp)
}
ImagePlus imp_new = showTargetSequence(
targets_new_multi, // final double [][][][] targets_multi,
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
title, // model_prefix+"-NEW-TARGETS-CENTERED-MULTI-n"+niter,// String title,
good_only, // final boolean good_only,
show_empty, // final boolean show_empty, // show scenes with no (valid) targets
!batch_mode, // boolean show,
cuasMotion.tilesX); // int tilesX) {
parentCLT.saveImagePlusInModelDirectory(imp_new); // ImagePlus imp)
}
// evaluate scores here to reduce the number of attempts for centered targets
getEffectiveStrengthLMA(
targets_new_multi, // final double [][][] target_coords, // LMA
target_strength, // final double target_strength,
target_frac, // final double [][] target_frac, // pairs - strength, minimal fraction for that strength
lma_rms, // final double lma_rms, // = 1.5; // Maximal RMS (should always match, regardless if A)
lma_arms, // final double lma_arms, // = 0.06; // Maximal absolute RMS (should match one of cuas_lma_arms OR cuas_lma_rrms (0.484)
lma_rrms, // final double lma_rrms, // = 0.15; // Maximal relative to A rms. OK is when (RMS < cuas_lma_arms) || (RMS < cuas_lma_rrms * A)
lma_mina, // final double lma_mina, // = 1.0; // Minimal A (amplitude)
lma_maxr, // final double lma_maxr, // = 5.0; // Minimal K (overshoot) = 3.0
lma_minr1, // final double lma_minr1,// = 1.0; // Minimal R1 (radius of positive peak)
lma_mink, // final double lma_mink, // = 0.0; // Minimal K (overshoot) = 1.0
lma_maxk, // final double lma_maxk, // = 5.0; // Minimal K (overshoot) = 3.0// final double lma_a2a,
lma_a2a, // final double lma_a2a,
0, // max_mismatch, // final double max_mismatch, apply only during final, when mismatch scores are calculated
slow_fast_mismatch,// final double slow_fast_mismatch, // // 1.5; allow larger mismatch between slow and fast
fail_mismatch, // final boolean fail_mismatch,
offcenter, // final double offcenter,
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,
int [] remain_es_centered = getScore(
targets_new_multi, // final double [][][] target_sequence, // modifies certain fields (scores)
factor_lim, // final double importance_limit,
factor_pow, // final double importance_power, // Raise each factor to this power before combining
score_coeff, // final double [] importance, // for now (each - squared?): [0] - Amplitude (A/A0), 1 - RMS (RMS0/RMS), 2 - RRMS((RMS/A0) / (RMS/A)
slow_score, // final double slow_score, // multiply total score for targets detected in slow target mode
cuasMotion.tilesX); // final int tilesX,
// evaluate scores here to reduce the number of attempts for centered targets
getEffectiveStrengthLMA(
targets_new_multi, // final double [][][] target_coords, // LMA
target_strength, // final double target_strength,
target_frac, // final double [][] target_frac, // pairs - strength, minimal fraction for that strength
lma_rms, // final double lma_rms, // = 1.5; // Maximal RMS (should always match, regardless if A)
lma_arms, // final double lma_arms, // = 0.06; // Maximal absolute RMS (should match one of cuas_lma_arms OR cuas_lma_rrms (0.484)
lma_rrms, // final double lma_rrms, // = 0.15; // Maximal relative to A rms. OK is when (RMS < cuas_lma_arms) || (RMS < cuas_lma_rrms * A)
lma_mina, // final double lma_mina, // = 1.0; // Minimal A (amplitude)
lma_maxr, // final double lma_maxr, // = 5.0; // Minimal K (overshoot) = 3.0
lma_minr1, // final double lma_minr1,// = 1.0; // Minimal R1 (radius of positive peak)
lma_mink, // final double lma_mink, // = 0.0; // Minimal K (overshoot) = 1.0
lma_maxk, // final double lma_maxk, // = 5.0; // Minimal K (overshoot) = 3.0// final double lma_a2a,
lma_a2a, // final double lma_a2a,
0, // max_mismatch, // final double max_mismatch, apply only during final, when mismatch scores are calculated
slow_fast_mismatch,// final double slow_fast_mismatch, // // 1.5; allow larger mismatch between slow and fast
fail_mismatch, // final boolean fail_mismatch,
offcenter, // final double offcenter,
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,
int [] remain_es_centered = getScore(
targets_new_multi, // final double [][][] target_sequence, // modifies certain fields (scores)
factor_lim, // final double importance_limit,
factor_pow, // final double importance_power, // Raise each factor to this power before combining
score_coeff, // final double [] importance, // for now (each - squared?): [0] - Amplitude (A/A0), 1 - RMS (RMS0/RMS), 2 - RRMS((RMS/A0) / (RMS/A)
slow_score, // final double slow_score, // multiply total score for targets detected in slow target mode
cuasMotion.tilesX); // final int tilesX,
if (save_filtered_low) {
String title = model_prefix+"-NEW-TARGETS_CENTERED_SCORES_MULTI-n"+niter;
if (boost_accum_pairs > 1.0) {
title+="-BOOST"+boost_accum_pairs;
}
if (save_filtered_low) {
String title = model_prefix+"-NEW-TARGETS_CENTERED_SCORES_MULTI-n"+niter;
if (boost_accum_pairs > 1.0) {
title+="-BOOST"+boost_accum_pairs;
ImagePlus imp_new_scores = showTargetSequence(
targets_new_multi, // double [][][] vector_fields_sequence,
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,
good_only, // final boolean good_only,
show_empty, // final boolean show_empty, // show scenes with no (valid) targets
!batch_mode, // boolean show,
cuasMotion.tilesX); // int tilesX) {
parentCLT.saveImagePlusInModelDirectory(imp_new_scores); // ImagePlus imp)
}
ImagePlus imp_new_scores = showTargetSequence(
targets_new_multi, // double [][][] vector_fields_sequence,
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,
good_only, // final boolean good_only,
show_empty, // final boolean show_empty, // show scenes with no (valid) targets
!batch_mode, // boolean show,
cuasMotion.tilesX); // int tilesX) {
parentCLT.saveImagePlusInModelDirectory(imp_new_scores); // ImagePlus imp)
}
int num_new = addNewResults(
target_sequence_multi, // final double [][][] target_sequence, // will only process non-nulls here
targets_new_multi, // final double [][][] new_sequence,
// add just one best here?
1, // final int num_best, // if >0, limit number of best results to add
niter, // final int when_iter,
debugLevel); // final 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,
// add just one best here?
1, // final int num_best, // if >0, limit number of best results to add
niter, // final int when_iter,
debugLevel); // final int debugLevel);
if (debugLevel > -4) {
System.out.println("Added "+num_new+" new tiles as good/bad at iteration "+niter+".");
if (debugLevel > -4) {
System.out.println("Added "+num_new+" new tiles as good/bad at iteration "+niter+".");
}
}
if (save_filtered_low) {
String title = model_prefix+"-ADDED_NEW_CENTERED_MULTI-n"+niter;
if (boost_accum_pairs > 1.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