Commit bd27e7b0 authored by Andrey Filippov's avatar Andrey Filippov

Implemented combining of the interscene 2D correlations amon tile and

its 8 immediate neighbors - significant improvement in matching
parent af9b88ff
...@@ -226,6 +226,15 @@ public class IntersceneMatchParameters { ...@@ -226,6 +226,15 @@ public class IntersceneMatchParameters {
public double pd_weight = 0.5; // correlations (post) accumulated in PD public double pd_weight = 0.5; // correlations (post) accumulated in PD
public boolean td_nopd_only = false; // true; // only use TD accumulated data if no safe PD is available for the tile. public boolean td_nopd_only = false; // true; // only use TD accumulated data if no safe PD is available for the tile.
// averaging with neighbors for interscene matching
public boolean use_neibs = true; // false; // true;
public boolean neibs_nofpn_only = false; // consolidate neighbors fot non-fpn tiles only!
public boolean redo_both = true; // use average of neighbors for both pd,td if any of the center tile tests (td, pd) fails
public int min_num_neibs = 4; // plus center, total number >= (min_num_neibs+1)
public double scale_neibs_pd = 0.5; // scale threshold for the pixel-domain average maximums
public double scale_neibs_td = 0.5; // scale threshold for the transform-domain average maximums
public double scale_avg_weight = 0.5; // reduce influence of the averaged correlations compared to the single-tile ones
public double min_str_fpn = 0.2; // 0.25; // minimal correlation strength for all but TD-accumulated layer public double min_str_fpn = 0.2; // 0.25; // minimal correlation strength for all but TD-accumulated layer
public double min_str_sum_fpn = 0.5; // 0.8; // minimal correlation strength for TD-accumulated layer public double min_str_sum_fpn = 0.5; // 0.8; // minimal correlation strength for TD-accumulated layer
...@@ -739,6 +748,24 @@ public class IntersceneMatchParameters { ...@@ -739,6 +748,24 @@ public class IntersceneMatchParameters {
"Mix argmax from PD-accumulated correlation."); "Mix argmax from PD-accumulated correlation.");
gd.addCheckbox ("TD when no PD only", this.td_nopd_only, gd.addCheckbox ("TD when no PD only", this.td_nopd_only,
"Use argmax from TD only if PD data is not available for this tile."); "Use argmax from TD only if PD data is not available for this tile.");
gd.addMessage ("Averaging inter-scene 2D correlations with 8 immediate neighbors");
gd.addCheckbox ("Use averaging neighbors", this.use_neibs,
"Average tile 2D correlation with 8 immediate neighbors if single-tile correlation is not strong enough.");
// TODO: Consider/Implement pure TD averaging
gd.addCheckbox ("No-FPN averaging only", this.neibs_nofpn_only,
"Use averaging with neighbors only if tile offset is large enough not to have FPN interference.");
gd.addCheckbox ("Use averaging for both PD and TD", this.redo_both,
"Recalculate tile average for both TD and PD if at least one of them is not strong enough.");
gd.addNumericField("Minimal neighbors to average", this.min_num_neibs, 0,3,"",
"Minimal number of defined (non-null) neighbors 2D correlations (of 8) to use averaging.");
gd.addNumericField("Scale PD thershold", this.scale_neibs_pd, 5,7,"",
"Use averaging for tiles that are stronger than scaled threshold for a single-tile motion vector for pixel-domain values.");
gd.addNumericField("Scale TD threshold", this.scale_neibs_td, 5,7,"",
"Use averaging for tiles that are stronger than scaled threshold for a single-tile motion vector for transform-domain values.");
gd.addNumericField("Scale averaged strengths", this.scale_avg_weight, 5,7,"",
"Scale averaged motion vector strengths (for each of the TD and PD).");
gd.addMessage ("Filtering motion vectors"); gd.addMessage ("Filtering motion vectors");
gd.addNumericField("Minimal correlation strength (non-sum)", this.min_str, 5,7,"", gd.addNumericField("Minimal correlation strength (non-sum)", this.min_str, 5,7,"",
"Minimal correlation strength for individual correlation and for pixel-domain averaged one. Weeker tiles results are removed."); "Minimal correlation strength for individual correlation and for pixel-domain averaged one. Weeker tiles results are removed.");
...@@ -1166,6 +1193,15 @@ public class IntersceneMatchParameters { ...@@ -1166,6 +1193,15 @@ public class IntersceneMatchParameters {
this.td_weight = gd.getNextNumber(); this.td_weight = gd.getNextNumber();
this.pd_weight = gd.getNextNumber(); this.pd_weight = gd.getNextNumber();
this.td_nopd_only = gd.getNextBoolean(); this.td_nopd_only = gd.getNextBoolean();
this.use_neibs = gd.getNextBoolean();
this.neibs_nofpn_only = gd.getNextBoolean();
this.redo_both = gd.getNextBoolean();
this.min_num_neibs = (int) gd.getNextNumber();
this.scale_neibs_pd = gd.getNextNumber();
this.scale_neibs_td = gd.getNextNumber();
this.scale_avg_weight = gd.getNextNumber();
this.min_str = gd.getNextNumber(); this.min_str = gd.getNextNumber();
this.min_str_fpn = gd.getNextNumber(); this.min_str_fpn = gd.getNextNumber();
this.min_str_sum = gd.getNextNumber(); this.min_str_sum = gd.getNextNumber();
...@@ -1505,6 +1541,15 @@ public class IntersceneMatchParameters { ...@@ -1505,6 +1541,15 @@ public class IntersceneMatchParameters {
properties.setProperty(prefix+"td_weight", this.td_weight+""); // double properties.setProperty(prefix+"td_weight", this.td_weight+""); // double
properties.setProperty(prefix+"pd_weight", this.pd_weight+""); // double properties.setProperty(prefix+"pd_weight", this.pd_weight+""); // double
properties.setProperty(prefix+"td_nopd_only", this.td_nopd_only+""); // boolean properties.setProperty(prefix+"td_nopd_only", this.td_nopd_only+""); // boolean
properties.setProperty(prefix+"use_neibs", this.use_neibs+""); // boolean
properties.setProperty(prefix+"neibs_nofpn_only", this.neibs_nofpn_only+""); // boolean
properties.setProperty(prefix+"redo_both", this.redo_both+""); // boolean
properties.setProperty(prefix+"min_num_neibs", this.min_num_neibs+""); // int
properties.setProperty(prefix+"scale_neibs_pd", this.scale_neibs_pd+""); // double
properties.setProperty(prefix+"scale_neibs_td", this.scale_neibs_td+""); // double
properties.setProperty(prefix+"scale_avg_weight", this.scale_avg_weight+""); // double
properties.setProperty(prefix+"min_str", this.min_str+""); // double properties.setProperty(prefix+"min_str", this.min_str+""); // double
properties.setProperty(prefix+"min_str_fpn", this.min_str_fpn+""); // double properties.setProperty(prefix+"min_str_fpn", this.min_str_fpn+""); // double
properties.setProperty(prefix+"min_str_sum", this.min_str_sum+""); // double properties.setProperty(prefix+"min_str_sum", this.min_str_sum+""); // double
...@@ -1799,6 +1844,15 @@ public class IntersceneMatchParameters { ...@@ -1799,6 +1844,15 @@ public class IntersceneMatchParameters {
if (properties.getProperty(prefix+"td_weight")!=null) this.td_weight=Double.parseDouble(properties.getProperty(prefix+"td_weight")); if (properties.getProperty(prefix+"td_weight")!=null) this.td_weight=Double.parseDouble(properties.getProperty(prefix+"td_weight"));
if (properties.getProperty(prefix+"pd_weight")!=null) this.pd_weight=Double.parseDouble(properties.getProperty(prefix+"pd_weight")); if (properties.getProperty(prefix+"pd_weight")!=null) this.pd_weight=Double.parseDouble(properties.getProperty(prefix+"pd_weight"));
if (properties.getProperty(prefix+"td_nopd_only")!=null) this.td_nopd_only=Boolean.parseBoolean(properties.getProperty(prefix+"td_nopd_only")); if (properties.getProperty(prefix+"td_nopd_only")!=null) this.td_nopd_only=Boolean.parseBoolean(properties.getProperty(prefix+"td_nopd_only"));
if (properties.getProperty(prefix+"use_neibs")!=null) this.use_neibs=Boolean.parseBoolean(properties.getProperty(prefix+ "use_neibs"));
if (properties.getProperty(prefix+"neibs_nofpn_only")!=null) this.neibs_nofpn_only=Boolean.parseBoolean(properties.getProperty(prefix+"neibs_nofpn_only"));
if (properties.getProperty(prefix+"redo_both")!=null) this.redo_both=Boolean.parseBoolean(properties.getProperty(prefix+ "redo_both"));
if (properties.getProperty(prefix+"min_num_neibs")!=null) this.min_num_neibs=Integer.parseInt(properties.getProperty(prefix+ "min_num_neibs"));
if (properties.getProperty(prefix+"scale_neibs_pd")!=null) this.scale_neibs_pd=Double.parseDouble(properties.getProperty(prefix+ "scale_neibs_pd"));
if (properties.getProperty(prefix+"scale_neibs_td")!=null) this.scale_neibs_td=Double.parseDouble(properties.getProperty(prefix+ "scale_neibs_td"));
if (properties.getProperty(prefix+"scale_avg_weight")!=null) this.scale_avg_weight =Double.parseDouble(properties.getProperty(prefix+ "scale_avg_weight"));
if (properties.getProperty(prefix+"min_str")!=null) this.min_str=Double.parseDouble(properties.getProperty(prefix+"min_str")); if (properties.getProperty(prefix+"min_str")!=null) this.min_str=Double.parseDouble(properties.getProperty(prefix+"min_str"));
if (properties.getProperty(prefix+"min_str_fpn")!=null) this.min_str_fpn=Double.parseDouble(properties.getProperty(prefix+"min_str_fpn")); if (properties.getProperty(prefix+"min_str_fpn")!=null) this.min_str_fpn=Double.parseDouble(properties.getProperty(prefix+"min_str_fpn"));
if (properties.getProperty(prefix+"min_str_sum")!=null) this.min_str_sum=Double.parseDouble(properties.getProperty(prefix+"min_str_sum")); if (properties.getProperty(prefix+"min_str_sum")!=null) this.min_str_sum=Double.parseDouble(properties.getProperty(prefix+"min_str_sum"));
...@@ -2104,6 +2158,15 @@ public class IntersceneMatchParameters { ...@@ -2104,6 +2158,15 @@ public class IntersceneMatchParameters {
imp.td_weight = this.td_weight; imp.td_weight = this.td_weight;
imp.pd_weight = this.pd_weight; imp.pd_weight = this.pd_weight;
imp.td_nopd_only = this.td_nopd_only; imp.td_nopd_only = this.td_nopd_only;
imp.use_neibs = this.use_neibs;
imp.neibs_nofpn_only = this.neibs_nofpn_only;
imp.redo_both = this.redo_both;
imp.min_num_neibs = this.min_num_neibs;
imp.scale_neibs_pd = this.scale_neibs_pd;
imp.scale_neibs_td = this.scale_neibs_td;
imp.scale_avg_weight = this.scale_avg_weight;
imp.min_str = this.min_str; imp.min_str = this.min_str;
imp.min_str_fpn = this.min_str_fpn; imp.min_str_fpn = this.min_str_fpn;
imp.min_str_sum = this.min_str_sum; imp.min_str_sum = this.min_str_sum;
......
...@@ -4539,6 +4539,7 @@ public class OpticalFlow { ...@@ -4539,6 +4539,7 @@ public class OpticalFlow {
int max_num_scenes = clt_parameters.imp.max_num_scenes; // cut longer series int max_num_scenes = clt_parameters.imp.max_num_scenes; // cut longer series
double boost_max_short = 2.0; // double boost_max_short = 2.0; //
double boost_zoom_short = 1.5; //
...@@ -4694,8 +4695,11 @@ public class OpticalFlow { ...@@ -4694,8 +4695,11 @@ public class OpticalFlow {
boolean rot_to_transl = after_spiral && clt_parameters.ilp.ilma_translation_priority; boolean rot_to_transl = after_spiral && clt_parameters.ilp.ilma_translation_priority;
double [] reg_weights = rot_to_transl? clt_parameters.ilp.ilma_regularization_weights0 : clt_parameters.ilp.ilma_regularization_weights; double [] reg_weights = rot_to_transl? clt_parameters.ilp.ilma_regularization_weights0 : clt_parameters.ilp.ilma_regularization_weights;
min_max[1] = max_offset; min_max[1] = max_offset;
//boost_zoom_short
double max_z_change_scaled = max_z_change;
if ((ref_index - scene_index) < min_num_scenes) { if ((ref_index - scene_index) < min_num_scenes) {
min_max[1] = boost_max_short * max_offset; min_max[1] = boost_max_short * max_offset;
max_z_change_scaled = max_z_change * boost_zoom_short;
if (debugLevel > -3) { if (debugLevel > -3) {
System.out.println("As the current series ("+(ref_index - scene_index)+ System.out.println("As the current series ("+(ref_index - scene_index)+
" scenes) is shorter than minimal ("+min_num_scenes+"), the maximal shift is scaled by "+ " scenes) is shorter than minimal ("+min_num_scenes+"), the maximal shift is scaled by "+
...@@ -4705,6 +4709,7 @@ public class OpticalFlow { ...@@ -4705,6 +4709,7 @@ public class OpticalFlow {
} }
if ((scene_index - earliest_scene) < min_num_scenes) { if ((scene_index - earliest_scene) < min_num_scenes) {
min_max[1] = boost_max_short * max_offset; min_max[1] = boost_max_short * max_offset;
max_z_change_scaled = max_z_change * boost_zoom_short;
if (debugLevel > -3) { if (debugLevel > -3) {
System.out.println("As the remaining number of scenes to process ("+(scene_index - earliest_scene + 1)+ System.out.println("As the remaining number of scenes to process ("+(scene_index - earliest_scene + 1)+
") is less than minimal ("+min_num_scenes+"), the maximal shift is scaled by "+ ") is less than minimal ("+min_num_scenes+"), the maximal shift is scaled by "+
...@@ -4741,8 +4746,14 @@ public class OpticalFlow { ...@@ -4741,8 +4746,14 @@ public class OpticalFlow {
} }
if (max_zoom_diff > 0) { // ignore if set to if (max_zoom_diff > 0) { // ignore if set to
if (Math.abs(scenes_xyzatr[scene_index][0][2]) > max_z_change) { if (Math.abs(scenes_xyzatr[scene_index][0][2]) > max_z_change) {
if (Math.abs(scenes_xyzatr[scene_index][0][2]) > max_z_change_scaled) {
fail_reason[0] = FAIL_REASON_ZOOM; fail_reason[0] = FAIL_REASON_ZOOM;
adjust_OK = false; adjust_OK = false;
} else {
System.out.println("Z-change "+Math.abs(scenes_xyzatr[scene_index][0][2])+
"m exceeds limit of "+max_z_change+"m, but as it is beginning/end of the series, limit is raised to "+
max_z_change_scaled+"m");
}
} }
} }
} }
...@@ -13131,6 +13142,15 @@ public class OpticalFlow { ...@@ -13131,6 +13142,15 @@ public class OpticalFlow {
if (mb_en && (mb_vectors!=null)) { // increase fat zero when there is motion blur if (mb_en && (mb_vectors!=null)) { // increase fat zero when there is motion blur
corr_fz_inter *= 8; corr_fz_inter *= 8;
} }
boolean use_neibs = clt_parameters.imp.use_neibs; // false; // true;
boolean neibs_nofpn_only = clt_parameters.imp.neibs_nofpn_only; // consolidate neighbors fot non-fpn tiles only!
boolean redo_both = clt_parameters.imp.redo_both; // use average of neighbors for both pd,td if any of the center tile tests (td, pd) fails
int min_num_neibs = clt_parameters.imp.min_num_neibs; // plus center, total number >= (min_num_neibs+1)
double scale_neibs_pd = use_neibs? clt_parameters.imp.scale_neibs_pd : 0; // scale threshold for the pixel-domain average maximums
double scale_neibs_td = use_neibs? clt_parameters.imp.scale_neibs_td : 0; // scale threshold for the transform-domain average maximums
double scale_avg_weight = clt_parameters.imp.scale_avg_weight; // reduce influence of the averaged correlations compared to the single-tile ones
coord_motion = image_dtt.clt_process_tl_interscene( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td coord_motion = image_dtt.clt_process_tl_interscene( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
// only used here to keep extra array element for disparity difference // only used here to keep extra array element for disparity difference
...@@ -13166,6 +13186,14 @@ public class OpticalFlow { ...@@ -13166,6 +13186,14 @@ public class OpticalFlow {
clt_parameters.imp.weight_zero_neibs, // final double weight_zero_neibs,// 0.2; // Reduce weight for no-neib (1.0 for all 8) clt_parameters.imp.weight_zero_neibs, // final double weight_zero_neibs,// 0.2; // Reduce weight for no-neib (1.0 for all 8)
half_disparity, // final double half_disparity, // 5.0; // Reduce weight twice for this disparity half_disparity, // final double half_disparity, // 5.0; // Reduce weight twice for this disparity
clt_parameters.imp.half_avg_diff, // final double half_avg_diff, // 0.2; // when L2 of x,y difference from average of neibs - reduce twice clt_parameters.imp.half_avg_diff, // final double half_avg_diff, // 0.2; // when L2 of x,y difference from average of neibs - reduce twice
neibs_nofpn_only, // final boolean neibs_nofpn_only, // consolidate neighbors fot non-fpn tiles only!
redo_both, //final boolean redo_both, // use average of neighbors for both pd,td if any of the center tile tests (td, pd) fails
min_num_neibs, //final int min_num_neibs, // plus center, total number >= (min_num_neibs+1)
scale_neibs_pd, //final double scale_neibs_pd, // scale threshold for the pixel-domain average maximums
scale_neibs_td, //final double scale_neibs_td, // scale threshold for the transform-domain average maximums
scale_avg_weight, //final double scale_avg_weight, // reduce influence of the averaged correlations compared to the single-tile ones
clt_parameters.tileX, // final int debug_tileX, clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY, clt_parameters.tileY, // final int debug_tileY,
THREADS_MAX, // final int threadsMax, // maximal number of threads to launch THREADS_MAX, // final int threadsMax, // maximal number of threads to launch
...@@ -13268,10 +13296,10 @@ public class OpticalFlow { ...@@ -13268,10 +13296,10 @@ public class OpticalFlow {
} }
} }
// seems that fclt_corr and fclt_corr1 are both not needed w/o debug // seems that fclt_corr and fclt_corr1 are both not needed w/o debug
if (show_2d_correlations) { // visualize prepare ref_scene correlation data
float [][][] fclt_corr1 = ImageDtt.convertFcltCorr( // partial length, matching corr_indices = gpuQuad.getCorrIndices(); // also sets num_corr_tiles float [][][] fclt_corr1 = ImageDtt.convertFcltCorr( // partial length, matching corr_indices = gpuQuad.getCorrIndices(); // also sets num_corr_tiles
dcorr_tiles, // double [][][] dcorr_tiles,// [tile][sparse, correlation pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate dcorr_tiles, // double [][][] dcorr_tiles,// [tile][sparse, correlation pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
fclt_corr); // float [][][] fclt_corr) // new float [tilesX * tilesY][][] or null fclt_corr); // float [][][] fclt_corr) // new float [tilesX * tilesY][][] or null
if (show_2d_correlations) { // visualize prepare ref_scene correlation data
float [][] dbg_corr_rslt_partial = ImageDtt.corr_partial_dbg( // not used in lwir float [][] dbg_corr_rslt_partial = ImageDtt.corr_partial_dbg( // not used in lwir
fclt_corr1, // final float [][][] fcorr_data, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate fclt_corr1, // final float [][][] fcorr_data, // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
image_dtt.getGPU().getCorrIndices(), // tp_tasks, // final TpTask [] tp_tasks, // image_dtt.getGPU().getCorrIndices(), // tp_tasks, // final TpTask [] tp_tasks, //
...@@ -15157,7 +15185,7 @@ public class OpticalFlow { ...@@ -15157,7 +15185,7 @@ public class OpticalFlow {
ers_scene.ers_watr_center_dt = ers_ref.ers_watr_center_dt.clone(); ers_scene.ers_watr_center_dt = ers_ref.ers_watr_center_dt.clone();
ers_scene.ers_wxyz_center_dt = ers_ref.ers_wxyz_center_dt.clone(); ers_scene.ers_wxyz_center_dt = ers_ref.ers_wxyz_center_dt.clone();
if (clt_parameters.imp.debug_level > -2) { if (clt_parameters.imp.debug_level > -2) {
System.out.print("adjustPairsLMAInterscene(): insufficeinet data for ERS, skipping. "); System.out.print("adjustPairsLMAInterscene(): insufficient data for ERS, skipping. ");
System.out.println ("quad_defined = ["+((int)quad_strengths[0][0])+"," System.out.println ("quad_defined = ["+((int)quad_strengths[0][0])+","
+((int)quad_strengths[0][1])+","+((int)quad_strengths[0][2])+","+((int)quad_strengths[0][3])+"] (needed = "+ +((int)quad_strengths[0][1])+","+((int)quad_strengths[0][2])+","+((int)quad_strengths[0][3])+"] (needed = "+
min_quad_tiles +"), rel_strengths = [" min_quad_tiles +"), rel_strengths = ["
......
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