Commit 58970e5a authored by Andrey Filippov's avatar Andrey Filippov

continue on correlation with averaging

parent c5a13cd6
......@@ -26,10 +26,11 @@ import java.util.Properties;
public class BiQuadParameters {
public boolean rig_mode_debug = true;
public boolean no_int_x0 = true; // do not offset window to integer maximum for the rig - used when averaging low textures to avoid "jumps" for very wide maximums
public boolean use_poly = true;
public boolean use_xy_poly = true;
public double min_poly_strength = 0.2;
public double min_poly_strength = 0.2; // never
public double min_xy_poly_strength = 1.0; // never
public double inf_min_strength_main = 0.12;
public double inf_min_strength_aux = 0.12;
......@@ -72,6 +73,7 @@ public class BiQuadParameters {
public double trusted_tolerance = 1.0; // Trusted tolerance for small baseline camera(s)
// rig LT (poor textured areas)
public int lt_avg_radius = 0; // average multiple tiles disparity (only used in certain modes)
public double lt_min_disparity = 0.0; // apply low texture to near objects
public double lt_trusted_strength = 0.2; // strength sufficient without neighbors
public double lt_strength_rfloor = 0.28; // fraction of trusted strength to subtract
......@@ -146,7 +148,21 @@ public class BiQuadParameters {
public double pf_new_diff = 0.5; // Minimal disparity (in master camera pixels) difference between the new suggested and the already tried/measured one
public int pf_min_new = 5; // Minimal number of he new tiles during rig refine for plane filter
public boolean ltavg_en = true; // apply low texture correlation averaging
public int ltavg_radius = 1; // low texture averaging radius
public boolean ltavg_dens_strong = true; // density calculation - consider only strong tiles
public int ltavg_dens_tiles = 20; // density calculation - number of required tiles
public int ltavg_dens_radius = 20; // density calculation - maximal radius to look for occupied tiles
// filtering lt candidates
public double ltavg_min_disparity = -1.0; // any
public double ltavg_max_density = 0.1;
public int ltavg_grow = 4; // each 2 add 8 directions step. Odd have last step in 4 ortho directions only.
public int ltavg_shrink = 2; // shrink after expanding. Combination of both fills small gaps
// smoothing parameters
public boolean ltavg_smooth_strength = false; // provide tile strength when smoothing target disparity
public double ltavg_neib_pull = 0.2; // pull to weighted average relative to pull to the original disparity value. If 0.0 - will only update former NaN-s
public int ltavg_max_iter = 20; //
public double ltavg_min_change = 0.01; //
// Rig ltfar - recovering far objects that could not be resolved with just a single quad camera
public boolean ltfar_en = true; // Enable recovering far objects over infinity area
......@@ -205,6 +221,9 @@ public class BiQuadParameters {
public void dialogQuestions(GenericJTabbedDialog gd) {
gd.addCheckbox ("Debug rig/bi-camera functionality ", this.rig_mode_debug,"Enable debugging of the methods related to dual camera rig");
gd.addCheckbox ("Do not offset window to integer maximum for the rig (CM mode)", this.no_int_x0,
"For the very wide/low strength maximums changing window from integer maximum causes \"jumps\" in the result, so this offset is automatically disabled in refine mode."+
" It is still useful for large offsets, and can be manually disabled with this parameter (rig only, not used for a single quad camera)");
gd.addCheckbox ("Use poly for main/aux/rig correlations (false - CM)", this.use_poly,"Use LMA/polynomial if correlation is strong enough");
gd.addCheckbox ("Use poly for rig X/Y mismatch measurements", this.use_xy_poly,"Use polynomial forX/Y offset measurements if correlation is strong enough");
......@@ -286,6 +305,8 @@ public class BiQuadParameters {
gd.addTab("Rig LT","Deal with the low textured areas");
gd.addNumericField("Average multiple tiles disparity (only used in certain modes)", this.lt_avg_radius, 0,3,"",
"Replace bi-quad correlation/strength with average over a sample square : 0 - avg off, 1 - 3x3, 2 - 5x5, ...");
gd.addNumericField("Apply low texture to near objects (disparity above)", this.lt_min_disparity, 3,6,"pix",
"Handle low textured objects with disparity (main camera pixels) above this threshold");
gd.addNumericField("Inter-camera correlation strength sufficient without neighbors", this.lt_trusted_strength, 3,6,"",
......@@ -424,6 +445,33 @@ public class BiQuadParameters {
gd.addNumericField("Minimal refined tiles during plane filter", this.pf_min_new, 0,3,"",
"Repeat refine antill less tiles are updated");
gd.addTab("LT Avg","Low texture correlatinaveraging");
gd.addCheckbox ("Apply low texture correlation averaging", this.ltavg_en,
"Improve low textures by averaging 2-d correlation results");
gd.addNumericField("Low texture correlation averaging radius", this.ltavg_radius, 0,3,"tiles",
"Averaging will be over a square (2 * radius + 1) * (2 * radius + 1) tiles");
gd.addCheckbox ("Consider only strong tiles during density calculation", this.ltavg_dens_strong,
"Low textured areas have low density of trusted disparities. Checked - consider only strong tiles, unchecked - any trusted tiles");
gd.addNumericField("Number of trusted tiles needed to calculate density", this.ltavg_dens_tiles, 0,3,"",
"Density is calculated over a spiral around the processed tile until this number of trusted tiles are traversed");
gd.addNumericField("Maximal radius of a spiral to look for occupied tiles", this.ltavg_dens_radius, 0,3,"tiles",
"Abandon spiral if it grows to big");
gd.addNumericField("Only try to process low textures closer than certain disparity", this.ltavg_min_disparity, 4,6,"pix",
"May be used to mask out infinity background");
gd.addNumericField("Maximal density to consider it to be low textured area", this.ltavg_max_density, 4,6,"",
"Select areas with lower density");
gd.addNumericField("Grow selection, each two units get expanion in 8 directions", this.ltavg_grow, 0,3,"",
"Two steps give one-tile expansion in 8 directions, odd numbers expand only in 4 ortho directions on the last expansion");
gd.addNumericField("Shrink selection after growing", this.ltavg_shrink, 0,3,"",
"Grow followed by shring fill small gaps");
gd.addCheckbox ("Use tile strengths when filling gaps/smoothing", this.ltavg_smooth_strength,
"Unchecked - consider all tiles to have the same strength");
gd.addNumericField("Relative pull of the nieghbor tiles compared to the original disparity" , this.ltavg_neib_pull, 4,6,"",
"If set to 0.0 - only gaps will be filled, defined disparities will not be modified");
gd.addNumericField("Maximal number of smoothing / gap filling iterations to perform", this.ltavg_max_iter, 0,3,"",
"Safety limit for smoothing iterations ");
gd.addNumericField("Minimal disparity change to continue smoothing", this.ltavg_min_change, 4,6,"pix","");
gd.addTab("Rig Far","Parameters related to the ML files generation for the dual-quad camera rig");
gd.addCheckbox ("Enable recovering far objects over infinity area", this.ltfar_en,
......@@ -512,6 +560,7 @@ public class BiQuadParameters {
}
public void dialogAnswers(GenericJTabbedDialog gd) {
this.rig_mode_debug= gd.getNextBoolean();
this.no_int_x0= gd.getNextBoolean();
this.use_poly= gd.getNextBoolean();
this.use_xy_poly= gd.getNextBoolean();
this.min_poly_strength= gd.getNextNumber();
......@@ -553,6 +602,7 @@ public class BiQuadParameters {
this.num_near_refine= (int) gd.getNextNumber();
this.min_trusted_strength= gd.getNextNumber();
this.trusted_tolerance= gd.getNextNumber();
this.lt_avg_radius= (int) gd.getNextNumber();
this.lt_min_disparity= gd.getNextNumber();
this.lt_trusted_strength= gd.getNextNumber();
......@@ -621,6 +671,20 @@ public class BiQuadParameters {
this.pf_new_diff= gd.getNextNumber();
this.pf_min_new= (int) gd.getNextNumber();
this.ltavg_en= gd.getNextBoolean();
this.ltavg_radius= (int) gd.getNextNumber();
this.ltavg_dens_strong= gd.getNextBoolean();
this.ltavg_dens_tiles= (int) gd.getNextNumber();
this.ltavg_dens_radius= (int) gd.getNextNumber();
this.ltavg_min_disparity= gd.getNextNumber();
this.ltavg_max_density= gd.getNextNumber();
this.ltavg_grow= (int) gd.getNextNumber();
this.ltavg_shrink= (int) gd.getNextNumber();
this.ltavg_smooth_strength= gd.getNextBoolean();
this.ltavg_neib_pull= gd.getNextNumber();
this.ltavg_max_iter= (int) gd.getNextNumber();
this.ltavg_min_change= gd.getNextNumber();
this.ltfar_en= gd.getNextBoolean();
this.ltfar_auto_floor= gd.getNextBoolean();
this.ltfar_min_disparity= gd.getNextNumber();
......@@ -663,6 +727,7 @@ public class BiQuadParameters {
public void setProperties(String prefix,Properties properties){
properties.setProperty(prefix+"rig_mode_debug", this.rig_mode_debug+"");
properties.setProperty(prefix+"no_int_x0", this.no_int_x0+"");
properties.setProperty(prefix+"use_poly", this.use_poly+"");
properties.setProperty(prefix+"use_xy_poly", this.use_xy_poly+"");
properties.setProperty(prefix+"min_poly_strength", this.min_poly_strength+"");
......@@ -707,6 +772,7 @@ public class BiQuadParameters {
properties.setProperty(prefix+"min_trusted_strength", this.min_trusted_strength+"");
properties.setProperty(prefix+"trusted_tolerance", this.trusted_tolerance+"");
properties.setProperty(prefix+"lt_avg_radius", this.lt_avg_radius+"");
properties.setProperty(prefix+"lt_min_disparity", this.lt_min_disparity+"");
properties.setProperty(prefix+"lt_trusted_strength", this.lt_trusted_strength+"");
properties.setProperty(prefix+"lt_strength_rfloor", this.lt_strength_rfloor+"");
......@@ -771,6 +837,22 @@ public class BiQuadParameters {
properties.setProperty(prefix+"pf_discard_strong", this.pf_discard_strong+"");
properties.setProperty(prefix+"pf_new_diff", this.pf_new_diff+"");
properties.setProperty(prefix+"pf_min_new", this.pf_min_new+"");
properties.setProperty(prefix+"ltavg_en", this.ltavg_en+"");
properties.setProperty(prefix+"ltavg_radius", this.ltavg_radius+"");
properties.setProperty(prefix+"ltavg_dens_strong", this.ltavg_dens_strong+"");
properties.setProperty(prefix+"ltavg_dens_tiles", this.ltavg_dens_tiles+"");
properties.setProperty(prefix+"ltavg_dens_radius", this.ltavg_dens_radius+"");
properties.setProperty(prefix+"ltavg_min_disparity", this.ltavg_min_disparity+"");
properties.setProperty(prefix+"ltavg_max_density", this.ltavg_max_density+"");
properties.setProperty(prefix+"ltavg_grow", this.ltavg_grow+"");
properties.setProperty(prefix+"ltavg_shrink", this.ltavg_shrink+"");
properties.setProperty(prefix+"ltavg_smooth_strength", this.ltavg_smooth_strength+"");
properties.setProperty(prefix+"ltavg_neib_pull", this.ltavg_neib_pull+"");
properties.setProperty(prefix+"ltavg_max_iter", this.ltavg_max_iter+"");
properties.setProperty(prefix+"ltavg_min_change", this.ltavg_min_change+"");
properties.setProperty(prefix+"ltfar_en", this.ltfar_en+"");
properties.setProperty(prefix+"ltfar_auto_floor", this.ltfar_auto_floor+"");
properties.setProperty(prefix+"ltfar_min_disparity", this.ltfar_min_disparity+"");
......@@ -813,6 +895,7 @@ public class BiQuadParameters {
}
public void getProperties(String prefix,Properties properties){
if (properties.getProperty(prefix+"rig_mode_debug")!=null) this.rig_mode_debug=Boolean.parseBoolean(properties.getProperty(prefix+"rig_mode_debug"));
if (properties.getProperty(prefix+"no_int_x0")!=null) this.no_int_x0=Boolean.parseBoolean(properties.getProperty(prefix+"no_int_x0"));
if (properties.getProperty(prefix+"use_poly")!=null) this.use_poly=Boolean.parseBoolean(properties.getProperty(prefix+"use_poly"));
if (properties.getProperty(prefix+"use_xy_poly")!=null) this.use_xy_poly=Boolean.parseBoolean(properties.getProperty(prefix+"use_xy_poly"));
if (properties.getProperty(prefix+"min_poly_strength")!=null) this.min_poly_strength=Double.parseDouble(properties.getProperty(prefix+"min_poly_strength"));
......@@ -853,8 +936,8 @@ public class BiQuadParameters {
if (properties.getProperty(prefix+"num_near_refine")!=null) this.num_near_refine=Integer.parseInt(properties.getProperty(prefix+"num_near_refine"));
if (properties.getProperty(prefix+"min_trusted_strength")!=null) this.min_trusted_strength=Double.parseDouble(properties.getProperty(prefix+"min_trusted_strength"));
if (properties.getProperty(prefix+"trusted_tolerance")!=null) this.trusted_tolerance=Double.parseDouble(properties.getProperty(prefix+"trusted_tolerance"));
if (properties.getProperty(prefix+"ml_hwidth")!=null) this.ml_hwidth=Integer.parseInt(properties.getProperty(prefix+"ml_hwidth"));
if (properties.getProperty(prefix+"lt_avg_radius")!=null) this.lt_avg_radius=Integer.parseInt(properties.getProperty(prefix+"lt_avg_radius"));
if (properties.getProperty(prefix+"lt_min_disparity")!=null) this.lt_min_disparity=Double.parseDouble(properties.getProperty(prefix+"lt_min_disparity"));
if (properties.getProperty(prefix+"lt_trusted_strength")!=null) this.lt_trusted_strength=Double.parseDouble(properties.getProperty(prefix+"lt_trusted_strength"));
if (properties.getProperty(prefix+"lt_strength_rfloor")!=null) this.lt_strength_rfloor=Double.parseDouble(properties.getProperty(prefix+"lt_strength_rfloor"));
......@@ -922,6 +1005,23 @@ public class BiQuadParameters {
if (properties.getProperty(prefix+"pf_new_diff")!=null) this.pf_new_diff=Double.parseDouble(properties.getProperty(prefix+"pf_new_diff"));
if (properties.getProperty(prefix+"pf_min_new")!=null) this.pf_min_new=Integer.parseInt(properties.getProperty(prefix+"pf_min_new"));
if (properties.getProperty(prefix+"ltavg_en")!=null) this.ltavg_en=Boolean.parseBoolean(properties.getProperty(prefix+"ltavg_en"));
if (properties.getProperty(prefix+"ltavg_radius")!=null) this.ltavg_radius=Integer.parseInt(properties.getProperty(prefix+"ltavg_radius"));
if (properties.getProperty(prefix+"ltavg_dens_strong")!=null) this.ltavg_dens_strong=Boolean.parseBoolean(properties.getProperty(prefix+"ltavg_dens_strong"));
if (properties.getProperty(prefix+"ltavg_dens_tiles")!=null) this.ltavg_dens_tiles=Integer.parseInt(properties.getProperty(prefix+"ltavg_dens_tiles"));
if (properties.getProperty(prefix+"ltavg_dens_radius")!=null) this.ltavg_dens_radius=Integer.parseInt(properties.getProperty(prefix+"ltavg_dens_radius"));
if (properties.getProperty(prefix+"ltavg_min_disparity")!=null) this.ltavg_min_disparity=Double.parseDouble(properties.getProperty(prefix+"ltavg_min_disparity"));
if (properties.getProperty(prefix+"ltavg_max_density")!=null) this.ltavg_max_density=Double.parseDouble(properties.getProperty(prefix+"ltavg_max_density"));
if (properties.getProperty(prefix+"ltavg_grow")!=null) this.ltavg_grow=Integer.parseInt(properties.getProperty(prefix+"ltavg_grow"));
if (properties.getProperty(prefix+"ltavg_shrink")!=null) this.ltavg_shrink=Integer.parseInt(properties.getProperty(prefix+"ltavg_shrink"));
if (properties.getProperty(prefix+"ltavg_smooth_strength")!=null) this.ltavg_smooth_strength=Boolean.parseBoolean(properties.getProperty(prefix+"ltavg_smooth_strength"));
if (properties.getProperty(prefix+"ltavg_neib_pull")!=null) this.ltavg_neib_pull=Double.parseDouble(properties.getProperty(prefix+"ltavg_neib_pull"));
if (properties.getProperty(prefix+"ltavg_max_iter")!=null) this.ltavg_max_iter=Integer.parseInt(properties.getProperty(prefix+"ltavg_max_iter"));
if (properties.getProperty(prefix+"ltavg_min_change")!=null) this.ltavg_min_change=Double.parseDouble(properties.getProperty(prefix+"ltavg_min_change"));
if (properties.getProperty(prefix+"ltfar_en")!=null) this.ltfar_en=Boolean.parseBoolean(properties.getProperty(prefix+"ltfar_en"));
if (properties.getProperty(prefix+"ltfar_auto_floor")!=null) this.ltfar_auto_floor=Boolean.parseBoolean(properties.getProperty(prefix+"ltfar_auto_floor"));
if (properties.getProperty(prefix+"ltfar_min_disparity")!=null) this.ltfar_min_disparity=Double.parseDouble(properties.getProperty(prefix+"ltfar_min_disparity"));
......@@ -949,6 +1049,7 @@ public class BiQuadParameters {
if (properties.getProperty(prefix+"rf_min_disp")!=null) this.rf_min_disp=Double.parseDouble(properties.getProperty(prefix+"rf_min_disp"));
if (properties.getProperty(prefix+"rf_remove_unselected")!=null) this.rf_remove_unselected=Boolean.parseBoolean(properties.getProperty(prefix+"rf_remove_unselected"));
if (properties.getProperty(prefix+"ml_hwidth")!=null) this.ml_hwidth=Integer.parseInt(properties.getProperty(prefix+"ml_hwidth"));
if (properties.getProperty(prefix+"ml_disparity_sweep")!=null) this.ml_disparity_sweep=Double.parseDouble(properties.getProperty(prefix+"ml_disparity_sweep"));
if (properties.getProperty(prefix+"ml_sweep_steps")!=null) this.ml_sweep_steps=Integer.parseInt(properties.getProperty(prefix+"ml_sweep_steps"));
if (properties.getProperty(prefix+"ml_keep_aux")!=null) this.ml_keep_aux=Boolean.parseBoolean(properties.getProperty(prefix+"ml_keep_aux"));
......@@ -965,6 +1066,7 @@ public class BiQuadParameters {
public BiQuadParameters clone() throws CloneNotSupportedException {
BiQuadParameters bqp = new BiQuadParameters();
bqp.rig_mode_debug= this.rig_mode_debug;
bqp.no_int_x0= this.no_int_x0;
bqp.use_poly= this.use_poly;
bqp.use_xy_poly= this.use_xy_poly;
bqp.min_poly_strength = this.min_poly_strength;
......@@ -1006,6 +1108,7 @@ public class BiQuadParameters {
bqp.min_trusted_strength= this.min_trusted_strength;
bqp.trusted_tolerance= this.trusted_tolerance;
bqp.lt_avg_radius= this.lt_avg_radius;
bqp.lt_min_disparity= this.lt_min_disparity;
bqp.lt_trusted_strength= this.lt_trusted_strength;
bqp.lt_strength_rfloor= this.lt_strength_rfloor;
......@@ -1072,6 +1175,20 @@ public class BiQuadParameters {
bqp.pf_new_diff= this.pf_new_diff;
bqp.pf_min_new= this.pf_min_new;
bqp.ltavg_en= this.ltavg_en;
bqp.ltavg_radius= this.ltavg_radius;
bqp.ltavg_dens_strong= this.ltavg_dens_strong;
bqp.ltavg_dens_tiles= this.ltavg_dens_tiles;
bqp.ltavg_dens_radius= this.ltavg_dens_radius;
bqp.ltavg_min_disparity= this.ltavg_min_disparity;
bqp.ltavg_max_density= this.ltavg_max_density;
bqp.ltavg_grow= this.ltavg_grow;
bqp.ltavg_shrink= this.ltavg_shrink;
bqp.ltavg_smooth_strength= this.ltavg_smooth_strength;
bqp.ltavg_neib_pull= this.ltavg_neib_pull;
bqp.ltavg_max_iter= this.ltavg_max_iter;
bqp.ltavg_min_change= this.ltavg_min_change;
bqp.ltfar_en= this.ltfar_en;
bqp.ltfar_auto_floor= this.ltfar_auto_floor;
bqp.ltfar_min_disparity= this.ltfar_min_disparity;
......
......@@ -190,6 +190,7 @@ public class BiScan {
double [][] ds = new double[2][num_tiles];
for (int i = 0; i < num_tiles; i++) ds[0][i] = Double.NaN;
// double boost_low_density = 0.8; // 1.0; //0.2;
suggestNewScan(
disparityStrength, // final double [][] disparityStrength,
......@@ -489,6 +490,7 @@ public class BiScan {
* @param strength_pow raise strength to thyis power (normally just 1.0)
* @param smpl_radius sample "radius", square side is 2 * smpl_radius + 1
* @param smpl_num minimal absolute number of samples required to try fit a plane and validate a tile
* If smpl_num == 0, faster calculation (single pass) using only *_narrow settings
* @param smpl_fract minimal fraction number of the neighbor samples that fit the rms filter required to try fit a plane and validate a tile
* @param smpl_num_narrow minimal absolute number of samples for preliminary fitting plane to trhe center area
* @param max_adiff maximal absolute difference from the center tile for initial neighbors selection
......@@ -675,9 +677,8 @@ public class BiScan {
}
int fin_samples= (int) ( nall * smpl_fract);
if (fin_samples < smpl_num) fin_samples = smpl_num;
// int fin_samples_narrow= (int) ( nall * smpl_fract_narrow);
// if (fin_samples_narrow < smpl_num) fin_samples_narrow = smpl_num_narrow;
// smpl_num == 0 - special (fast) case do not use wide selection at all
if ((smpl_num == 0) || (fin_samples < smpl_num)) fin_samples = smpl_num;
// fit plane to mostly centertiles
int nsmpls = nall;
......@@ -695,6 +696,7 @@ public class BiScan {
smpl_p, // double [] smpl_p, // will be set if provided
smpl_num_narrow, // int fin_samples, // remove until this number remain
goal_fraction_rms*max_rms, // double fin_rms,
false, // boolean keep_center, // do not remove center tile - it is the tile that should be verified by neighbors
fourq_min, // int fourq_min, // each of the 4 corners should have at least this number of tiles.
fourq_corner, // int [] fourq_corner, // array specifying corner number (0..3), -1 - gap. null when not used
debugLevel); // int debugLevel)
......@@ -729,6 +731,7 @@ public class BiScan {
smpl_p, // double [] smpl_p, // will be set if provided
smpl_num_narrow, // int fin_samples, // remove until this number remain
goal_fraction_rms*max_rms, // double fin_rms,
false, // boolean keep_center, // do not remove center tile - it is the tile that should be verified by neighbors
fourq_min, // int fourq_min, // each of the 4 corners should have at least this number of tiles.
fourq_corner, // int [] fourq_corner, // array specifying corner number (0..3), -1 - gap. null when not used
debugLevel); // int debugLevel)
......@@ -751,6 +754,7 @@ public class BiScan {
smpl_d, // double [] smpl_d,
smpl_p); // double [] smpl_p);
} //if (use_alt) {
// re-select tiles to fit the plane and use wide weights
double max_diff = max_adiff + max_rdiff * disp_mean; // no provisions for tilt (or add a fraction)?
nsmpls = 0;
......@@ -761,26 +765,29 @@ public class BiScan {
smpl_w[indxs] = 0.0;
}
}
if (fin_samples > 0) {
if (nsmpls < fin_samples) { // no tiles even to satrt
continue; //
}
fit_rslt = fitPlaneRemoveOutliers(
smpl_radius, // int smpl_radius,
max_tilt, // double max_tilt,
damp_tilt, // double damp_tilt, // = 0.001; // Tilt cost for damping insufficient plane data
true, // boolean full_plane,
smpl_d, // double [] smpl_d,
smpl_w, // double [] smpl_w, // will be modified,
smpl_p, // double [] smpl_p, // will be set if provided
fin_samples, // int fin_samples, // remove until this number remain
goal_fraction_rms*max_rms, // double fin_rms,
fourq_min, // int fourq_min, // each of the 4 corners should have at least this number of tiles.
fourq_corner, // int [] fourq_corner, // array specifying corner number (0..3), -1 - gap. null when not used
debugLevel); // int debugLevel)
// if ( (fit_rslt == null) || (fit_rslt[0] > (smpl_arms + smpl_rrms * fit_rslt[1]))){
if ( (fit_rslt == null) || (fit_rslt[0] > max_rms)){
continue; // narrow selection - too high rms
if (nsmpls < fin_samples) { // no tiles even to satrt
continue; //
}
fit_rslt = fitPlaneRemoveOutliers(
smpl_radius, // int smpl_radius,
max_tilt, // double max_tilt,
damp_tilt, // double damp_tilt, // = 0.001; // Tilt cost for damping insufficient plane data
true, // boolean full_plane,
smpl_d, // double [] smpl_d,
smpl_w, // double [] smpl_w, // will be modified,
smpl_p, // double [] smpl_p, // will be set if provided
fin_samples, // int fin_samples, // remove until this number remain
goal_fraction_rms*max_rms, // double fin_rms,
false, // boolean keep_center, // do not remove center tile - it is the tile that should be verified by neighbors
fourq_min, // int fourq_min, // each of the 4 corners should have at least this number of tiles.
fourq_corner, // int [] fourq_corner, // array specifying corner number (0..3), -1 - gap. null when not used
debugLevel); // int debugLevel)
// if ( (fit_rslt == null) || (fit_rslt[0] > (smpl_arms + smpl_rrms * fit_rslt[1]))){
if ( (fit_rslt == null) || (fit_rslt[0] > max_rms)){
continue; // narrow selection - too high rms
}
}
boolean valid_suggestion = true;
if ((disparityStrength == null) && (new_diff > 0.0)) {
......@@ -1139,6 +1146,7 @@ public class BiScan {
double [] smpl_d = new double [smpl_len];
double [] smpl_w = new double [smpl_len];
double [] smpl_p = new double [smpl_len]; // plane disparity,
boolean [] smpl_trusted = new boolean [smpl_len];
// copy neighbor tiles
double disp_center = ds[0][nTile];
double max_diff = max_adiff + max_rdiff * disp_center;
......@@ -1155,10 +1163,11 @@ public class BiScan {
for (int dx = -smpl_radius; dx <= smpl_radius; dx++) {
int nTile1 = tnImage.getNeibIndex(nTile, dx, dy);
if ((nTile1 >= 0) && cond_trusted[nTile1]) {
nall++;
int adx = (dx > 0)? dx:(-dx);
double max_fdiff = max_diff + (ady+adx) * max_tilt;
int smpl_indx = smpl_center + dy*smpl_side + dx;
smpl_trusted[smpl_indx] = true;
nall++;
if (Math.abs(ds[0][nTile1] - disp_center) <= max_fdiff) {
// smpl_sel[smpl_indx] = true;
smpl_d[smpl_indx] = ds[0][nTile1];
......@@ -1186,6 +1195,7 @@ public class BiScan {
smpl_p, // double [] smpl_p, // will be set if provided
fin_samples, // int fin_samples, // remove until this number remain
goal_fraction_rms*max_rms, // double fin_rms,
true, // boolean keep_center, // do not remove center tile - it is the tile that should be verified by neighbors
0, // int fourq_min, // each of the 4 corners should have at least this number of tiles.
null, // int [] fourq_corner, // array specifying corner number (0..3), -1 - gap. null when not used
debugLevel); // int debugLevel)
......@@ -1197,10 +1207,43 @@ public class BiScan {
continue;
}
// try 8 "halves" around the tile - it may be weak background close to the strong foreground (or stray FG tile)
for (int dir = 0; dir < halves.length; dir++) {
nsmpls = 0;
nall = 0;
smpl_w = new double [smpl_len];
for (int indxs = 0; indxs < smpl_len; indxs++) if (halves[dir][indxs]) {
if (smpl_trusted[indxs]) nall++;
if (smpl_w_persistent[indxs] > 0.0) {
smpl_w[indxs] = smpl_w_persistent[indxs];
nsmpls++;
}
}
fin_samples= (int) ( nall * smpl_fract);
if (fin_samples < smpl_num) fin_samples = smpl_num;
if (nsmpls >= fin_samples) {
fit_rslt = fitPlaneRemoveOutliers(
smpl_radius, // int smpl_radius,
max_tilt, // double max_tilt,
damp_tilt, // double damp_tilt, // = 0.001; // Tilt cost for damping insufficient plane data
false, // boolean full_plane,
smpl_d, // double [] smpl_d,
smpl_w, // double [] smpl_w, // will be modified,
smpl_p, // double [] smpl_p, // will be set if provided
fin_samples, // int fin_samples, // remove until this number remain
goal_fraction_rms*max_rms, // double fin_rms,
true, // boolean keep_center, // do not remove center tile - it is the tile that should be verified by neighbors
0, // int fourq_min, // each of the 4 corners should have at least this number of tiles.
null, // int [] fourq_corner, // array specifying corner number (0..3), -1 - gap. null when not used
debugLevel); // int debugLevel)
if ((fit_rslt != null) && (fit_rslt[0] < max_rms)){
// Trusted tile, save it
trusted[nTile] = true;
num_trusted_plane.getAndIncrement();
break; // from for (int dir = 0; dir < halves.length; dir++) {
}
}
}
}
}
}
};
......@@ -1388,6 +1431,7 @@ public class BiScan {
smpl_p, // double [] smpl_p, // will be set if provided
fin_samples, // int fin_samples, // remove until this number remain
goal_fraction_rms*max_rms, // double fin_rms,
true, // boolean keep_center, // do not remove center tile - it is the tile that should be verified by neighbors
0, // int fourq_min, // each of the 4 corners should have at least this number of tiles.
null, // int [] fourq_corner, // array specifying corner number (0..3), -1 - gap. null when not used
debugLevel); // int debugLevel)
......@@ -1549,6 +1593,7 @@ public class BiScan {
* @param smpl_p approximated disparity values, may be null. When provided (not null), will have calculated disparity approximation
* @param fin_samples remove until this number of tiles remain
* @param fin_rms - OK RMS - exit if it is below (set to 0.0 if unknown yet)
* @param keep_center do not remove center tile - it is the tile that should be verified by neighbors
* @param fourq_min each of the 4 corners should have at least this number of tiles.
* @param fourq_corner array specifying corner number (0..3), -1 - gap. null when not used
* @param debugLevel debug level
......@@ -1564,11 +1609,13 @@ public class BiScan {
double [] smpl_p, // will be set if provided
int fin_samples, // remove until this number remain
double fin_rms,
boolean keep_center, // do not remove center tile - it is the tile that should be verified by neighbors
int fourq_min,
int [] fourq_corner,
int debugLevel)
{
int [] num_in_corners = ((fourq_corner == null) || (fourq_min == 0)) ? null: new int [5]; // last is not used
final int keep_tile = keep_center? (2*smpl_radius*(smpl_radius+1)): -1; // do not remove tile with this number
double [] disp_tilts = null;
final int smpl_side = 2 * smpl_radius + 1; // Sample size (side of a square)
int num_in_sample = 0;
......@@ -1620,6 +1667,9 @@ public class BiScan {
int iworst = -1;
double dworst2 = 0.0;
for (int indxs = 0; indxs < smpl_len; indxs++) if (smpl_w[indxs] > 0.0) {
if (indxs == keep_tile) { // it was the center tile disabled from removing
continue;
}
// verify that the worst tile will not leave the corner too empty
int num_corner = 4; // unused, gap
if (num_in_corners != null) {
......@@ -1818,6 +1868,246 @@ public class BiScan {
return rslt;
}
public double [] getDensity(
final boolean strong_only,
final int need_tiles,
final int max_radius,
final int dbg_x,
final int dbg_y,
final int debugLevel )
{
final int [][][] incr = {
{{ 1,-1},{ 0, 1}}, // top right corner, going down
{{ 1, 1},{-1, 0}}, // bottom right corner, going left
{{-1, 1},{ 0,-1}}, // bottom left corner, going up
{{-1,-1},{ 1, 0}}}; // top left corner, going right
final TileNeibs tnImage = biCamDSI.tnImage;
final int dbg_tile = (debugLevel > -2)? (dbg_y * tnImage.sizeX + dbg_x):-1;
final boolean [] en = strong_only ? strong_trusted: trusted;
final int num_tiles = en.length;
final double [] density = new double[num_tiles];
final Thread[] threads = ImageDtt.newThreadArray(biCamDSI.threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
public void run() {
for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) {
if (nTile == dbg_tile) {
System.out.println("getDensity(): nTile="+nTile);
}
// int num_tried = 0, num_found =0;
int sd = 0, sdr2 = 0, s0=0, sr2 = 0;
int dx = 0,dy = 0;
int r = 0;
label_snail: {
for (; r <= max_radius; r++) {
int nd = (r == 0) ? 1: 4;
int nl = (r == 0) ? 1: (2 * r);
for (int dir = 0; dir < nd; dir ++) {
for (int l = 0; l < nl; l++) {
dx = r * incr[dir][0][0] + l * incr[dir][1][0];
dy = r * incr[dir][0][1] + l * incr[dir][1][1];
int nTile1 = tnImage.getNeibIndex(nTile, dx,dy);
if (nTile1 >= 0) {
int r2 = dx*dx + dy*dy;
s0++;
sr2 += r2;
if (en[nTile1]) {
sd++;
sdr2 += r2;
}
// num_found++;
if (sd >= need_tiles) {
break label_snail;
}
}
}
}
}
}
int r02 = 2 * r * r;
int num = r02 * sd - sdr2;
int denom = r02 * s0 - sr2;
// int num = sd;
// int denom = s0;
if (denom > 0) {
density[nTile] = (1.0* num) / denom;
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return density;
}
/**
* Select low-textured tiles for averaging measurements
* @param min_disparity minimal disparity to accept
* @param max_density maximal trusted tile density (density varies from 0.0 to 1.0)
* @param grow grow selection. When combined with shrink, fills small gaps. Both grow and shrink step
* advances either horizontally or vertically (alternating), so to expand by 1 pixel in all directions
* the value should be set to 2,
* @param shrink shrink selection after expanding to fill small gaps
* @param density per-tile values of the density of trusted tiles around it.
* @param src_disparity - source disparity array
* @return selection of the low-textured tiles to be processed with averaging correlation (3x3 or 5x5 tiles)
*/
public boolean [] selectLowTextures(
double min_disparity,
double max_density,
int grow,
int shrink,
double [] density,
double [] src_disparity)
{
boolean [] selection = new boolean [density.length];
for (int nTile = 0; nTile < selection.length; nTile++) {
if ((src_disparity[nTile] >= min_disparity) && (density[nTile] <= max_density)) { // disparity has NaN-s, they will fail comparisons
selection[nTile] = true;
}
}
final TileNeibs tnImage = biCamDSI.tnImage;
tnImage.growSelection(
grow, // int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
selection, // boolean [] tiles,
null); // boolean [] prohibit)
return selection;
}
/**
* Fill the gaps (where provided src_disparity is NaN) and optionally smooth it using pull to the weighted average of 8 neighbors
* @param src_disparity source disparity values, some may be undefined (Double.NaN)
* @param src_strength optional strengths of the initial values (should be with floor subtracted)
* @param selection tile selection to process
* @param neib_pull pull of the average neighbor weight relative to the original disparity value of a tile. If 0 - only gaps
* (Double.NaN) values are filled, all the defined disparities remain as they were provided
* @param max_iterations Maximal number of the iteration steps
* @param min_change exit iterations when the maximal disparity change to a tile is less than this value
* @param dbg_x debug tile X coordinate
* @param dbg_y debug tile Y coordinate
* @param debugLevel debug level
* @return processed disparity and optional strength array. Normally only unselected tiles should remain Double.NaN, all other should be interpolated
*/
public double [][] fillAndSmooth(
final double [] src_disparity,
final double [] src_strength, // if not null will be used for weighted pull
final boolean [] selection,
final double neib_pull, // pull to weighted average relative to pull to the original disparity value. If 0.0 - will only update former NaN-s
final int max_iterations,
final double min_change,
final int dbg_x,
final int dbg_y,
final int debugLevel) {
final double [] weights = {1.0, 0.7}; // {ortho, corners},
final boolean adjust_all = (neib_pull > 0.0);
final double fneib_pull = adjust_all ? neib_pull: 1.0;
final TileNeibs tnImage = biCamDSI.tnImage;
final int dbg_tile = (debugLevel > -2)? (dbg_y * tnImage.sizeX + dbg_x):-1;
final int num_tiles = src_disparity.length;
final Thread[] threads = ImageDtt.newThreadArray(biCamDSI.threadsMax);
// max_changes may have Double.NaN value (here meaning larger than any)
final double [] max_changes = new double [biCamDSI.threadsMax]; // Each thread provides its own maximal change, then they are combined
final double [] disparity = src_disparity.clone();
final double [] new_disparity = src_disparity.clone();
final double [] strength = (src_strength != null)? src_strength: null; // new double [src_disparity.length];
final double [] new_strength = (src_strength != null)? src_disparity.clone(): null;
// if (src_strength == null) for (int i = 0; i < strength.length; i++) if (selection[i] && !Double.isNaN(src_disparity[i])) strength[i] = 1.0;
final AtomicInteger ai = new AtomicInteger(0);
final AtomicInteger ai_numThread = new AtomicInteger(0);
for (int num_iter = 0; num_iter < max_iterations; num_iter++) {
ai.set(0);
ai_numThread.set(0);
for (int i = 0; i < max_changes.length; i++) max_changes[i] = 0.0;
final int fnum_iter = num_iter;
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
public void run() {
int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to max_changes[numThread]
// max_changes[numThread]
for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) if (selection[nTile]){
if (nTile == dbg_tile) {
System.out.println("fillAndSmooth(): iteration "+fnum_iter+" nTile="+nTile);
}
if (!adjust_all && !Double.isNaN(src_disparity[nTile])) {
// nothing to do - new_disparity and new_strength are already same as new_*
} else {
double sw=0.0, swd =0.0, sww = 0.0;
for (int dir = 0; dir < 8; dir++) {
int nTile1 = tnImage.getNeibIndex(nTile, dir);
if (nTile1 >= 0) {
double w = weights[dir & 1];
double s = (strength == null) ? 1.0 : (Math.max(strength[nTile1], 0.0));
double d = disparity[nTile1];
double ww = w * s;
if ((ww > 0.0) && !Double.isNaN(d)) {
sw += w;
sww += ww;
swd += ww * d;
}
}
}
if (sww > 0.0) { // then sw
double d_mean = swd/sww;
double w_mean = sww/sw;
if (Double.isNaN(src_disparity[nTile])) {
new_disparity[nTile] = d_mean;
if (strength != null) {
new_strength[nTile] = w_mean;
}
} else {
double pull_origin = (strength==null)? 1.0: strength[nTile];
new_disparity[nTile] = (d_mean *(neib_pull * w_mean) + src_disparity[nTile] * pull_origin)/((neib_pull * w_mean) + pull_origin);
if (strength != null) {
new_strength[nTile] = (w_mean * neib_pull + src_strength[nTile])/(neib_pull + 1);
}
}
double adiff = Math.abs(new_disparity[nTile] - disparity[nTile]); // disparity[nTile] may be NaN then adiff will be NaN as intended
if (!(adiff < max_changes[numThread])) {
max_changes[numThread] = adiff; // NaN will be copied
}
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
System.arraycopy(new_disparity, 0, disparity, 0, num_tiles);
if (strength != null) {
System.arraycopy(new_strength, 0, strength, 0, num_tiles);
}
double change = 0.0;
for (int i = 0; i < ai_numThread.get(); i++) {
if (Double.isNaN(max_changes[i]) || (change < max_changes[i])) { // max_changes[i] may be NaN
change = max_changes[i];
if (!(change <= min_change)) { // change may be NaN
if (debugLevel < -2) {
// may exit here, continue to get debug info
break;
}
}
}
}
if (debugLevel > -2) {
System.out.println("fillAndSmooth(): iteration "+fnum_iter+" change="+change+" (min_change="+min_change+")");
}
if (change <= min_change) { // change may be NaN
break; // from the main loop
}
}
double [][] ds = {disparity,strength}; // strength may be null
return ds;
}
}
......@@ -5100,8 +5100,11 @@ private Panel panel1,
TWO_QUAD_CLT.showBiScan(
QUAD_CLT, // QuadCLT quadCLT_main, // tiles should be set
QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
CLT_PARAMETERS, // EyesisCorrectionParameters.CLTParameters clt_parameters,
DEBUG_LEVEL); // final int debugLevel) // throws Exception
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel);
return true;
}
public boolean processPoles() {
......
......@@ -7194,7 +7194,9 @@ public class ImageDtt {
* @param debugLevel debug level
* @return
*/
public double [] tileInterCamCorrs(
final boolean no_int_x0, // do not offset window to integer - used when averaging low textures to avoid "jumps" for very wide
final EyesisCorrectionParameters.CLTParameters clt_parameters,
final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
final Correlation2d corr2d,
......@@ -7209,8 +7211,6 @@ public class ImageDtt {
final int tileX, // only used in debug output
final int tileY,
final int debugLevel) {
int strip_hight = notch_mode? clt_parameters.img_dtt.corr_strip_notch : clt_parameters.img_dtt.corr_strip_hight;
double [] result = {Double.NaN, 0.0, Double.NaN, Double.NaN};
double [] inter_cam_corr = corr2d.correlateInterCamerasFD(
clt_data_tile_main, // double [][][][] clt_data_tile_main,
clt_data_tile_aux, // double [][][][] clt_data_tile_aux,
......@@ -7218,12 +7218,76 @@ public class ImageDtt {
col_weights, // double [] col_weights,
fatzero); // double fat_zero)
return tileInterCamCorrs(
no_int_x0, // do not offset window to integer - used when averaging low textures to avoid "jumps" for very wide
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
inter_cam_corr, // final double [] inter_cam_corr,
corr2d, // final Correlation2d corr2d,
ml_hwidth, // final int ml_hwidth,
ml_center_corr, // final double [] ml_center_corr,
tcorr_combo, // final double [][] tcorr_combo,
notch_mode, // final boolean notch_mode,
tileX, // final int tileX, // only used in debug output
tileY, // final int tileY,
debugLevel); // final int debugLevel);
}
public double [] tileInterCamCorrs(
final boolean no_int_x0, // do not offset window to integer - used when averaging low textures to avoid "jumps" for very wide
// maximums. That reduces the residual disparity, but works continuously when it is known the maximum should be near zero
final EyesisCorrectionParameters.CLTParameters clt_parameters,
final double [] inter_cam_corr,
final Correlation2d corr2d,
final int ml_hwidth,
final double [] ml_center_corr,
final double [][] tcorr_combo,
final boolean notch_mode,
final int tileX, // only used in debug output
final int tileY,
final int debugLevel) {
int strip_hight = notch_mode? clt_parameters.img_dtt.corr_strip_notch : clt_parameters.img_dtt.corr_strip_hight;
double [] result = {Double.NaN, 0.0, Double.NaN, Double.NaN};
// using exacltly as for main/aux
int all_pairs = 1;
double [][] corrs = { inter_cam_corr}; // single-channel
double [][] strips = corr2d.scaleRotateInterpoateCorrelations(
corrs, // double [][] correlations,
all_pairs, // int pairs_mask,
clt_parameters.img_dtt.corr_strip_hight, //); // int hwidth);
(debugLevel > 0) ? all_pairs:0); // debugMax);
// Combine strips for selected pairs. Now using only for all available pairs.
// Other combinations are used only if requested (clt_corr_partial != null)
double [] stripe_combo = corr2d.combineInterpolatedCorrelations(
strips, // double [][] strips,
all_pairs, // int pairs_mask,
clt_parameters.img_dtt.corr_offset, // double offset);
clt_parameters.img_dtt.twice_diagonal); // boolean twice_diagonal)
// calculate CM maximums for all mixed channels
// First get integer correlation center, relative to the center
int [] ixy_combo = corr2d.getMaxXYInt( // find integer pair or null if below threshold
stripe_combo, // double [] data,
true, // boolean axis_only,
// reduce minimal weight when averaging
(no_int_x0?0.5:1.0) * clt_parameters.img_dtt.min_corr, // double minMax, // minimal value to consider (at integer location, not interpolated)
debugLevel > 0); // boolean debug);
double [] stripe_inter = stripe_combo;
int [] ixy = ixy_combo;
/*
double [] stripe_inter = corr2d. scaleRotateInterpoateSingleCorrelation(
inter_cam_corr, // double [] corr,
strip_hight, // int hwidth,
Correlation2d.PAIR_HORIZONTAL, // int dir, // 0 - hor, 1 - vert, 2 - parallel to row = col (main) diagonal (0->3), 3 -2->1
1, // int ss,
(debugLevel > 0)); // boolean debug
*/
if (ml_center_corr != null) {
corr2d.corrCenterValues(
ml_hwidth,
......@@ -7244,11 +7308,13 @@ public class ImageDtt {
// First get integer correlation center, relative to the center
// TODO: multiply/acummulate by Y window?
/*
int [] ixy = corr2d.getMaxXYInt( // find integer pair or null if below threshold
stripe_inter, // double [] data,
true, // boolean axis_only, for strip it is always true
clt_parameters.img_dtt.min_corr, // double minMax, // minimal value to consider (at integer location, not interpolated)
debugLevel > 0); // boolean debug);
*/
double [] corr_stat = null;
// if integer argmax was strong enough, calculate CM argmax
// will not fill out DISPARITY_INDEX_INT+1, DISPARITY_INDEX_CM+1, DISPARITY_INDEX_POLY+1
......@@ -7267,14 +7333,14 @@ public class ImageDtt {
if (notch_mode) {
corr_stat = corr2d.getMaxXCmNotch( // get fractional center as a "center of mass" inside circle/square from the integer max
stripe_inter, // double [] data, // [data_size * data_size]
ixy[0], // int ixcenter, // integer center x
0, // ixy[0], // int ixcenter, // integer center x
// corr_wndy, // double [] window_y, // (half) window function in y-direction(perpendicular to disparity: for row0 ==1
// corr_wndx, // double [] window_x, // half of a window function in x (disparity) direction
(debugLevel > 0)); // boolean debug);
} else {
corr_stat = corr2d.getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max
stripe_inter, // double [] data, // [data_size * data_size]
ixy[0], // int ixcenter, // integer center x
(no_int_x0 ? 0:ixy[0]), // 0, // ixy[0], // int ixcenter, // integer center x
// corr_wndy, // double [] window_y, // (half) window function in y-direction(perpendicular to disparity: for row0 ==1
// corr_wndx, // double [] window_x, // half of a window function in x (disparity) direction
(debugLevel > 0)); // boolean debug);
......@@ -7288,7 +7354,7 @@ public class ImageDtt {
}
disparity = -corr_stat[0];
disparity = -corr_stat[0]; // yes, uses this value
result[INDEX_DISP] = disparity;
double eff_radius = corr_stat[2] * clt_parameters.img_dtt.cm_max_normalization;
strength = corr_stat[1]/(eff_radius * eff_radius); // total mass by square effective radius
......@@ -7342,7 +7408,7 @@ public class ImageDtt {
clt_parameters.img_dtt, // ImageDttParameters imgdtt_params,
inter_cam_corr, // double [] corr,
// See if -disparity should be here as in mismatch
0.0, // double xcenter, // -disparity to compare. use 0?
0.0, // double xcenter, // -disparity to compare. use 0? //-ixy[0], //
clt_parameters.max_corr_radius, // double vasw_pwr, // value as weight to this power,
debugLevel, // int debug_level,
tileX, // int tileX,
......@@ -7730,6 +7796,8 @@ public class ImageDtt {
final EyesisCorrectionParameters.CLTParameters clt_parameters,
final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
final int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using (2*notch_mode+1)^2 square
final boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
final int [][] tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile
final double [][] disparity_array, // [tilesY][tilesX] - individual per-tile expected disparity
final double [][][] image_data_main, // first index - number of image in a quad
......@@ -7774,6 +7842,8 @@ public class ImageDtt {
clt_bidata[1] = new double[quad_aux][nChn][tilesY][tilesX][][];
}
final double [][] lt_corr = (lt_rad > 0)? (new double [nTilesInChn][]):null; // will keep inter-camera combo correlation, later combined in a separate multi-thread run
final Thread[] threads = newThreadArray(threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
final double [] col_weights= new double [numcol]; // colors are RBG
......@@ -8195,22 +8265,31 @@ public class ImageDtt {
if (clt_corr_combo != null) { // [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
tcorr_combo = new double [TCORR_TITLES.length][corr_size * corr_size];
}
double [] inter_cam_corr = corr2d.correlateInterCamerasFD(
clt_data_main, // double [][][][] clt_data_tile_main,
clt_data_aux, // double [][][][] clt_data_tile_aux,
filter, // double [] lpf,
col_weights, // double [] col_weights,
fatzero); // double fat_zero)
double [] inter_corrs_dxy = tileInterCamCorrs(
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
fatzero, // final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
corr2d, // final Correlation2d corr2d,
clt_data_main, // double [][][][] clt_data_tile_main,
clt_data_aux, // double [][][][] clt_data_tile_aux,
filter, // final double [] filter,
col_weights, // final double [] col_weights,
ml_hwidth, // final int ml_hwidth,
ml_data_inter, // final double [] ml_center_corr,
tcorr_combo, // double [][] tcorr_combo,
notch_mode, // final boolean notch_mode,
no_int_x0, // final boolean no_int_x0, // do not offset window to integer - used when averaging low textures to avoid "jumps" for very wide
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
inter_cam_corr, // final double [] inter_cam_corr,
corr2d, // final Correlation2d corr2d,
ml_hwidth, // final int ml_hwidth,
ml_data_inter, // final double [] ml_center_corr,
tcorr_combo, // double [][] tcorr_combo,
notch_mode, // final boolean notch_mode,
tileX, // final int tileX, // only used in debug output
tileY, // final int tileY,
tile_lma_debug_level); // final int debugLevel)
if (lt_corr != null) {
lt_corr[tIndex] = inter_cam_corr;
}
if (inter_corrs_dxy != null) {
disparity_bimap[BI_DISP_CROSS_INDEX][nTile] = inter_corrs_dxy[INDEX_DISP];
disparity_bimap[BI_STR_CROSS_INDEX][nTile] = inter_corrs_dxy[INDEX_STRENGTH];
......@@ -8254,7 +8333,7 @@ public class ImageDtt {
ML_INTER_INDEX, // int ml_layer,
ml_data_inter, // double [] ml_tile,
tilesX); // int tilesX);
// save oter data (just 1 value)
// save other data (just 1 value)
/*
corr2d.saveMlTile(
tileX, // int tileX,
......@@ -8277,6 +8356,7 @@ public class ImageDtt {
if (ml_data_dbg1 != null) {
tileInterCamCorrs(
false, // final boolean no_int_x0, // do not offset window to integer - used when averaging low textures to avoid "jumps" for very wide
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
fatzero, // final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
......@@ -8365,16 +8445,116 @@ public class ImageDtt {
};
}
startAndJoin(threads);
/*
if (dbg_ports_coords != null) {
(new showDoubleFloatArrays()).showArrays(dbg_ports_coords, tilesX, tilesY, true, "ports_coordinates", dbg_titles);
// If it was low-texture mode, use lt_corr to average bi-quad inter-correlation between neighbor tiles and then calculate disparity/strength
if (lt_corr != null) {
// prepare weights for neighbors
final double [][] neib_weights = new double[lt_rad+1][lt_rad+1];
for (int i = 0; i <= lt_rad; i++) {
for (int j = 0; j <= lt_rad; j++) {
neib_weights[i][j] = Math.cos(Math.PI * i /(2 * lt_rad + 1)) * Math.cos(Math.PI * j /(2 * lt_rad + 1)); // no need to normalize - it will need to skip empty tiles anyway
}
}
// final int corr_size = clt_parameters.transform_size * 2 -1;
final TileNeibs tnImage = new TileNeibs(tilesX, tilesY);
ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
public void run() {
double [] ml_data_inter = (ml_data != null)? new double [(2*ml_hwidth +1)*(2*ml_hwidth +1)]:null;
double [][] tcorr_combo = null; // [15*15] pixel space
Correlation2d corr2d = new Correlation2d(
clt_parameters.img_dtt, // ImageDttParameters imgdtt_params,
clt_parameters.transform_size, // int transform_size,
2.0, // double wndx_scale, // (wndy scale is always 1.0)
(globalDebugLevel > -1)); // boolean debug)
for (int nTile = ai.getAndIncrement(); nTile < nTilesInChn; nTile = ai.getAndIncrement()) if (lt_corr[nTile] != null){ // center must be non-null (from tile_op)
int tileX = nTile % tilesX;
int tileY = nTile / tilesX;
double [] tile_corrs = new double [corr_size * corr_size];
double sw = 0.0;
for (int dy = -lt_rad; dy <= lt_rad; dy++) {
int ady = (dy > 0)? dy:(-dy);
for (int dx = -lt_rad; dx <= lt_rad; dx++) {
int nTile1 = tnImage.getNeibIndex(nTile, dx, dy);
if (nTile1 >= 0) {
double [] ot_corr = lt_corr[nTile1];
if (ot_corr != null) {
int adx = (dx > 0)? dx:(-dx);
double nw = neib_weights[ady][adx];
for (int i = 0; i < tile_corrs.length; i++) {
tile_corrs[i] += nw * ot_corr[i];
}
sw+=nw;
}
}
}
}
if (sw > 0.0) { // with the current window should always be so, as te center tile is non-null
double s = 1.0/sw;
for (int i = 0; i < tile_corrs.length; i++) {
tile_corrs[i] *= s;
}
if (clt_corr_combo != null) { // [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
tcorr_combo = new double [TCORR_TITLES.length][corr_size * corr_size];
}
int tile_lma_debug_level = ((tileX == debug_tileX) && (tileY == debug_tileY))? clt_parameters.img_dtt.lma_debug_level : -1;
double [] inter_corrs_dxy = tileInterCamCorrs(
true, // final boolean no_int_x0, // do not offset window to integer - used when averaging low textures to avoid "jumps" for very wide
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
tile_corrs, // final double [] inter_cam_corr,
corr2d, // final Correlation2d corr2d,
ml_hwidth, // final int ml_hwidth,
ml_data_inter, // final double [] ml_center_corr,
tcorr_combo, // double [][] tcorr_combo,
notch_mode, // final boolean notch_mode,
tileX, // final int tileX, // only used in debug output
tileY, // final int tileY,
tile_lma_debug_level); // final int debugLevel)
if (inter_corrs_dxy != null) {
disparity_bimap[BI_DISP_CROSS_INDEX][nTile] = inter_corrs_dxy[INDEX_DISP];
disparity_bimap[BI_STR_CROSS_INDEX][nTile] = inter_corrs_dxy[INDEX_STRENGTH];
disparity_bimap[BI_DISP_CROSS_DX_INDEX][nTile] = inter_corrs_dxy[INDEX_DX];
disparity_bimap[BI_DISP_CROSS_DY_INDEX][nTile] = inter_corrs_dxy[INDEX_DY];
// TODO: Use strength for the same residual disparity
disparity_bimap[BI_STR_ALL_INDEX][nTile] =
Math.pow(inter_corrs_dxy[INDEX_STRENGTH]*
disparity_bimap[BI_STR_FULL_INDEX][nTile]*
disparity_bimap[BI_ASTR_FULL_INDEX][nTile], 1.0/3);
}
if (tcorr_combo != null) { // [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
for (int i = 0; i < tcorr_combo.length; i++) {
clt_corr_combo[i][tileY][tileX] = tcorr_combo[i];
}
}
if (ml_data != null) {
// save inter-camera correlation
corr2d.saveMlTile(
tileX, // int tileX,
tileY, // int tileY,
ml_hwidth, // int ml_hwidth,
ml_data, // double [][] ml_data,
ML_INTER_INDEX, // int ml_layer,
ml_data_inter, // double [] ml_tile,
tilesX); // int tilesX);
}
// TODO: save ml_data_inter, tcorr_combo
}
}
}
};
}
startAndJoin(threads);
}
*/
return clt_bidata;
}
public void clt_bi_macro(
public void clt_bi_macro( // not yet operational
final EyesisCorrectionParameters.CLTParameters clt_parameters,
final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
final int macro_scale,
......@@ -8657,6 +8837,7 @@ public class ImageDtt {
// * @param clt_data_tile_main aberration-corrected FD CLT data for one tile of the main quad camera [sub-camera][color][quadrant][index]
double [] inter_corrs_dxy = tileInterCamCorrs(
false, // final boolean no_int_x0, // do not offset window to integer - used when averaging low textures to avoid "jumps" for very wide
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
fatzero, // final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
corr2d, // final Correlation2d corr2d,
......
......@@ -222,7 +222,10 @@ public class TwoQuadCLT {
rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters,
scaleExposures_main, // double [] scaleExposures_main, // probably not needed here - restores brightness of the final image
scaleExposures_aux, // double [] scaleExposures_aux, // probably not needed here - restores brightness of the final image
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
// averages measurements
clt_parameters.rig.lt_avg_radius,// final int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// final boolean apply_corr, // calculate and apply additional fine geometry correction
// final boolean infinity_corr, // calculate and apply geometry correction at infinity
threadsMax, // final int threadsMax, // maximal number of threads to launch
......@@ -262,6 +265,7 @@ public class TwoQuadCLT {
double [] scaleExposures_main, // probably not needed here - restores brightness of the final image
double [] scaleExposures_aux, // probably not needed here - restores brightness of the final image
boolean notch_mode, // use pole-detection mode for inter-camera correlation
final int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel){
......@@ -339,9 +343,11 @@ public class TwoQuadCLT {
image_dtt.clt_bi_quad (
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_parameters.fat_zero, // final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
notch_mode, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
notch_mode, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
lt_rad, // final int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// first measurement - use default setting
clt_parameters.rig.no_int_x0, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
tile_op_main, // final int [][] tile_op_main, // [tilesY][tilesX] - what to do - 0 - nothing for this tile
// tile_op_aux, // final int [][] tile_op_aux, // [tilesY][tilesX] - what to do - 0 - nothing for this tile
disparity_array_main, // final double [][] disparity_array, // [tilesY][tilesX] - individual per-tile expected disparity
quadCLT_main.image_data, // final double [][][] image_data_main, // first index - number of image in a quad
quadCLT_aux.image_data, // final double [][][] image_data_aux, // first index - number of image in a quad
......@@ -865,6 +871,9 @@ public class TwoQuadCLT {
null, // ArrayList<Integer> tile_list, // or null. If non-null - do not remeasure members of the list
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// first measurement - use default setting
clt_parameters.rig.no_int_x0, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -1018,6 +1027,9 @@ if (debugLevel > -100) return true; // temporarily !
tile_list, // ArrayList<Integer> tile_list, // or null. If non-null - do not remeasure members of the list
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// first measurement - use default setting
clt_parameters.rig.no_int_x0, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -1052,6 +1064,9 @@ if (debugLevel > -100) return true; // temporarily !
num_new, // int [] num_new,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// refine mode - no window offset
true, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -1087,6 +1102,9 @@ if (debugLevel > -100) return true; // temporarily !
num_new, // int [] num_new,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// refine mode - no window offset
true, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -1139,6 +1157,9 @@ if (debugLevel > -100) return true; // temporarily !
num_new, // int [] num_new,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// refine mode - disable window offset
true, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -1468,6 +1489,9 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_parameters.fat_zero, // final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// does not matter here
true, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
tile_op, // final int [][] tile_op_main, // [tilesY][tilesX] - what to do - 0 - nothing for this tile
disparity_array, // final double [][] disparity_array, // [tilesY][tilesX] - individual per-tile expected disparity
quadCLT_main.image_data, // final double [][][] image_data_main, // first index - number of image in a quad
......@@ -1551,6 +1575,8 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_parameters.rig.ml_hwidth, // int ml_hwidth
clt_parameters.rig.ml_fatzero, // double fatzero,
//change if needed?
0, // int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using (2*notch_mode+1)^2 square
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -1618,6 +1644,9 @@ if (debugLevel > -100) return true; // temporarily !
null, // ArrayList<Integer> tile_list, // or null. If non-null - do not remeasure members of the list
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// first measurement - use as set in parameters
clt_parameters.rig.no_int_x0, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -1662,6 +1691,9 @@ if (debugLevel > -100) return true; // temporarily !
num_new, // int [] num_new,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// refine - no window offset
true, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -1770,6 +1802,9 @@ if (debugLevel > -100) return true; // temporarily !
num_new, // int [] num_new,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// refine - no window offset
true, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -1872,6 +1907,9 @@ if (debugLevel > -100) return true; // temporarily !
disparity_bimap[ImageDtt.BI_TARGET_INDEX], // double [] disparity, // Double.NaN - skip, ohers - measure
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
true, // boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// any - in notch mode it is disabled
clt_parameters.rig.no_int_x0, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // +4); // final int debugLevel);
......@@ -1901,7 +1939,9 @@ if (debugLevel > -100) return true; // temporarily !
trusted_near, // tile_list, // ArrayList<Integer> tile_list, // or null
num_new, // int [] num_new,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
true, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
true, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
true, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -2204,7 +2244,7 @@ if (debugLevel > -100) return true; // temporarily !
// measure and refine
double [] target_disparity = biCamDSI.getTargetDisparity(-1); // get last
// Measure provided tiles (brdeak after, if it was the last cycle)
// Measure provided tiles (break after, if it was the last cycle)
disparity_bimap = measureNewRigDisparity(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
......@@ -2212,6 +2252,9 @@ if (debugLevel > -100) return true; // temporarily !
target_disparity, // double [] disparity, // Double.NaN - skip, ohers - measure
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// first measurement - use default value:
clt_parameters.rig.no_int_x0, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -2256,6 +2299,9 @@ if (debugLevel > -100) return true; // temporarily !
num_new, // int [] num_new,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// disable window preset in refine mode
true, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -2359,7 +2405,10 @@ if (debugLevel > -100) return true; // temporarily !
public boolean showBiScan(
QuadCLT quadCLT_main, // tiles should be set
QuadCLT quadCLT_aux, // tiles should be set
EyesisCorrectionParameters.CLTParameters clt_parameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel) // throws Exception
{
......@@ -2378,13 +2427,13 @@ if (debugLevel > -100) return true; // temporarily !
boolean keep_unreliable = false;
boolean keep_weak = false;
boolean keep_strong = false;
double center_weight = 1.0;
double center_weight = 1.0;
// from clt_parameters.rig
double trusted_strength = clt_parameters.rig.pf_trusted_strength;
double cond_rtrusted = clt_parameters.rig.pf_cond_rtrusted;
double strength_rfloor = clt_parameters.rig.pf_strength_rfloor;
double strength_pow = clt_parameters.rig.pf_strength_pow;
int smpl_radius = clt_parameters.rig.pf_smpl_radius;
int smpl_radius = 9; // clt_parameters.rig.pf_smpl_radius;
int smpl_num = clt_parameters.rig.pf_smpl_num;
int smpl_num_narrow = clt_parameters.rig.pf_smpl_num_narrow;
double smpl_fract = clt_parameters.rig.pf_smpl_fract;
......@@ -2404,10 +2453,28 @@ if (debugLevel > -100) return true; // temporarily !
int fourq_min = clt_parameters.rig.pf_fourq_min;
int fourq_gap = clt_parameters.rig.pf_fourq_gap;
double min_disparity = 0.0;
boolean run_avg = false; //ltavg_en
int lt_radius = clt_parameters.rig.ltavg_radius;
boolean strong_only = clt_parameters.rig.ltavg_dens_strong;
int need_tiles = clt_parameters.rig.ltavg_dens_tiles;
int max_radius = clt_parameters.rig.ltavg_dens_radius;
double min_disparity = clt_parameters.rig.ltavg_min_disparity;
double max_density = clt_parameters.rig.ltavg_max_density;
int grow = clt_parameters.rig.ltavg_grow; // each 2 add 8 directions step. Odd have last step in 4 ortho directions only.
int shrink = clt_parameters.rig.ltavg_shrink; // shrink after expanding. Combination of both fills small gaps
// smoothing parameters
boolean smooth_strength = clt_parameters.rig.ltavg_smooth_strength; // provide tile strength when smoothing target disparity
double neib_pull = clt_parameters.rig.ltavg_neib_pull; // pull to weighted average relative to pull to the original disparity value. If 0.0 - will only update former NaN-s
int max_iter = clt_parameters.rig.ltavg_max_iter; //
double min_change = clt_parameters.rig.ltavg_min_change; //
GenericJTabbedDialog gd = new GenericJTabbedDialog("Set CLT parameters",900,1100);
gd.addTab("Genearl","Select bi-scan to show and process");
GenericJTabbedDialog gd = new GenericJTabbedDialog("Set CLT parameters",800,900);
gd.addNumericField("Scan index (0..."+(biCamDSI_persistent.biScans.size()-1), scan_index, 0, 2, "", "Display scan by index");
gd.addCheckbox ("Show smooth disparity/strength for the selected scan", show_smooth, "Unchecked - just as is");
......@@ -2416,8 +2483,6 @@ if (debugLevel > -100) return true; // temporarily !
gd.addCheckbox ("Keep strng trusted tiles", keep_strong, "Unchecked - overwrite with smooth data");
gd.addNumericField("Center weight - relative weight of the existing tile ", center_weight, 4,6,"",
"0.0 - suggest new disparity over existing tiles without ant regard to the original value, 1.0 - same influence as any other tile");
gd.addNumericField("Minimal disparity to apply filter", min_disparity, 4,6,"pix",
"Farther objects will not be filtered");
gd.addMessage ("Parameters that are copied from the CLT parameters");
gd.addNumericField("Strength sufficient without neighbors", trusted_strength, 4,6,"",
......@@ -2466,6 +2531,34 @@ if (debugLevel > -100) return true; // temporarily !
gd.addNumericField("Four corners center gap half-width (1 - 1 tile, 2 - 3 tiles, 3 - 5 tiles, ...", fourq_gap, 0,3,"",
"Specifies corners of the sample square that should have tiles remain, after removing centre columns and center rows");
gd.addTab("LT Avg","Low texture correlatinaveraging");
gd.addCheckbox ("Measure with tile averaging", run_avg, "");
gd.addNumericField("Averaging radius (1 - 3x3 square, 2 - 5x5, ...", lt_radius, 0,3,"", "");
gd.addCheckbox ("Calculate density of strong trusted only (false include weak trusted)", strong_only, "");
gd.addNumericField("Minimal number tiles to calculate density)", need_tiles, 0,3,"", "");
gd.addNumericField("Maximal radius for measuruing density)", max_radius, 0,3,"", "");
gd.addNumericField("Minimal disparity to apply filter", min_disparity, 4,6,"pix",
"Farther objects will not be filtered");
gd.addNumericField("Maximal density to consider it to be low textured area", max_density, 4,6,"",
"Select areas with lower density");
gd.addNumericField("Grow selection, each two units get expanion in 8 directions", grow, 0,3,"",
"Two steps give one-tile expansion in 8 directions, odd numbers expand only in 4 ortho directions on the last expansion");
gd.addNumericField("Shrink selection after growing", shrink, 0,3,"",
"Grow followed by shring fill small gaps");
gd.addCheckbox ("Use tile strengths when filling gaps/smoothing", smooth_strength,
"Unchecked - consider all tiles to have the same strength");
gd.addNumericField("Relative pull of the nieghbor tiles compared to the original disparity" , neib_pull, 4,6,"",
"If set to 0.0 - only gaps will be filled, defined disparities will not be modified");
gd.addNumericField("Maximal number of smoothing / gap filling iterations to perform", max_iter, 0,3,"",
"Safety limit for smoothing iterations ");
gd.addNumericField("Minimal disparity change to continue smoothing", min_change, 4,6,"pix","");
// boolean run_avg = false;
// int lt_radius = 1;
gd.showDialog();
if (gd.wasCanceled()) return false;
scan_index = (int) gd.getNextNumber();
......@@ -2474,7 +2567,6 @@ if (debugLevel > -100) return true; // temporarily !
keep_weak = gd.getNextBoolean();
keep_strong = gd.getNextBoolean();
center_weight = gd.getNextNumber();
min_disparity = gd.getNextNumber();
// from clt_parameters.rig
trusted_strength = gd.getNextNumber();
cond_rtrusted = gd.getNextNumber();
......@@ -2501,6 +2593,24 @@ if (debugLevel > -100) return true; // temporarily !
fourq_min= (int) gd.getNextNumber();
fourq_gap= (int) gd.getNextNumber();
// gd.addTab("LT Avg","Low texture correlatinaveraging");
run_avg = gd.getNextBoolean();
lt_radius= (int) gd.getNextNumber();
strong_only = gd.getNextBoolean();
need_tiles= (int) gd.getNextNumber();
max_radius= (int) gd.getNextNumber();
min_disparity = gd.getNextNumber();
max_density = gd.getNextNumber();
grow= (int) gd.getNextNumber();
shrink= (int) gd.getNextNumber();
smooth_strength = gd.getNextBoolean();
neib_pull = gd.getNextNumber();
max_iter= (int) gd.getNextNumber();
min_change = gd.getNextNumber();
System.out.println(" === showBiScan( parameters : =====");
System.out.println(" scan_index= "+scan_index);
System.out.println(" show_smooth= "+show_smooth);
......@@ -2508,7 +2618,6 @@ if (debugLevel > -100) return true; // temporarily !
System.out.println(" keep_weak= "+keep_weak);
System.out.println(" keep_strong= "+keep_strong);
System.out.println(" center_weight= "+center_weight);
System.out.println(" min_disparity= "+min_disparity);
System.out.println(" trusted_strength= "+trusted_strength);
System.out.println(" cond_rtrusted= "+cond_rtrusted);
......@@ -2535,6 +2644,20 @@ if (debugLevel > -100) return true; // temporarily !
System.out.println(" fourq_min= "+fourq_min);
System.out.println(" fourq_gap= "+fourq_gap);
System.out.println(" run_avg= "+run_avg);
System.out.println(" lt_radius= "+lt_radius);
System.out.println(" strong_only= "+strong_only);
System.out.println(" need_tiles= "+need_tiles);
System.out.println(" max_radius= "+max_radius);
System.out.println(" min_disparity= "+min_disparity);
System.out.println(" max_density= "+max_density);
System.out.println(" grow= "+grow);
System.out.println(" shrink= "+shrink);
System.out.println(" smooth_strength= "+smooth_strength);
System.out.println(" neib_pull= "+neib_pull);
System.out.println(" max_iter= "+max_iter);
System.out.println(" min_change= "+min_change);
BiScan biScan = biCamDSI_persistent.biScans.get(scan_index);
double [][] ds = null;
......@@ -2585,14 +2708,14 @@ if (debugLevel > -100) return true; // temporarily !
strength_rfloor, // final double strength_rfloor, // strength floor - relative to trusted
!keep_unreliable, // final boolean discard_unreliable,// replace v
!keep_weak, // final boolean discard_weak, // consider weak trusted tiles (not promoted to trusted) as empty
!keep_strong, // final boolean discard_strong, // suggest new disparitieas even for strong tiles
!keep_strong, // final boolean discard_strong, // suggest new disparities even for strong tiles
strength_pow, // final double strength_pow, // raise strength-floor to this power
null, // final double [] smpl_radius_array, // space-variant radius
smpl_radius, // final int smpl_radius,
smpl_num, // final int smpl_num, // = 3; // Number after removing worst (should be >1)
smpl_fract, // final double smpl_fract, // Number of friends among all neighbors
smpl_num_narrow, // final int smpl_num_narrow, // = 3; // Number after removing worst (should be >1)
max_adiff, // final double max_adiff, // Maximal absolute difference betweenthe center tile and friends
max_adiff, // final double max_adiff, // Maximal absolute difference between the center tile and friends
max_rdiff, // final double max_rdiff, // Maximal relative difference between the center tile and friends
max_atilt, // final double max_atilt, // = 2.0; // pix per tile
max_rtilt, // final double max_rtilt, // = 0.2; // (pix / disparity) per tile
......@@ -2610,8 +2733,159 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters.tileX, // final int dbg_x,
clt_parameters.tileY, // final int dbg_y,
debugLevel+2); // final int debugLevel
biScan.showScan(quadCLT_main.image_name+"-BiScan-"+scan_index,ds);
double [] density = biScan.getDensity(
strong_only, // final boolean strong_only,
need_tiles, // 20, // 10, // final int need_tiles,
max_radius, // 20, // 15, // final int max_radius,
clt_parameters.tileX, // final int dbg_x,
clt_parameters.tileY, // final int dbg_y,
debugLevel+2); // final int debugLevel
double [][] dbg_dens_str = {density, ds[1]};
biScan.showScan(quadCLT_main.image_name+"-density-"+scan_index,dbg_dens_str);
boolean [] lt_select = biScan.selectLowTextures(
min_disparity, // double min_disparity,
max_density, // double max_density,
grow, // int grow,
shrink, // int shrink,
density, // double [] density,
ds[0]); // double [] src_disparity);
double [][] ds1 = {ds[0].clone(), ds[1].clone()} ;
for (int i = 0; i < lt_select.length; i++) if (!lt_select[i]) {
ds1[0][i] = Double.NaN;
ds1[1][i] = 0.0;
}
biScan.showScan(quadCLT_main.image_name+"-selection-"+scan_index,ds1);
double [] lt_strength = smooth_strength? ds1[1]:null;
double [][] ds2 = biScan.fillAndSmooth(
ds1[0], // final double [] src_disparity,
lt_strength, // final double [] src_strength, // if not null will be used for weighted pull
lt_select, // final boolean [] selection,
neib_pull, // final double neib_pull, // pull to weighted average relative to pull to the original disparity value. If 0.0 - will only update former NaN-s
max_iter, // final int max_iterations,
min_change, // final double min_change,
clt_parameters.tileX, // final int dbg_x,
clt_parameters.tileY, // final int dbg_y,
debugLevel+2); // final int debugLevel
biScan.showScan(quadCLT_main.image_name+"-smooth-"+scan_index,ds2);
if (run_avg) {
int tilesX = quadCLT_main.tp.getTilesX();
double [][] disparity_bimap = measureNewRigDisparity(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
ds2[0], // double [] disparity, // Double.NaN - skip, ohers - measure
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
lt_radius, // int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using (2*notch_mode+1)^2 square
// use set from parameters
clt_parameters.rig.no_int_x0, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel)
(new showDoubleFloatArrays()).showArrays(
disparity_bimap,
tilesX,
disparity_bimap[0].length/tilesX,
true,
quadCLT_main.image_name+"LPF"+lt_radius,
ImageDtt.BIDISPARITY_TITLES);
// try to refine
int [] num_new = new int[1];
/*
boolean [] trusted_measurements = getTrustedDisparity(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
clt_parameters.rig.min_trusted_strength, // double min_combo_strength, // check correlation strength combined for all 3 correlations
clt_parameters.grow_disp_trust, // double max_trusted_disparity, // 4.0 -> change to rig_trust
clt_parameters.rig.trusted_tolerance, // double trusted_tolerance,
null, // boolean [] was_trusted,
disparity_bimap); // double [][] bimap // current state of measurements
*/
double [][] prev_bimap = null;
final int refine_inter = 2; // 3; // 3 - dx, 2 - disparity
double [] scale_bad = new double [ds2[0].length];
for (int i = 0; i < scale_bad.length; i++) scale_bad[i] = 1.0;
// for (int nref = 0; nref < 5; nref++) { // clt_parameters.rig.num_inf_refine; nref++) {
for (int nref = 0; nref < clt_parameters.rig.num_inf_refine; nref++) {
// refine infinity using inter correlation
double [][] disparity_bimap_new = refineRigSel(
quadCLT_main, // QuadCLT quadCLT_main, // tiles should be set
quadCLT_aux, // QuadCLT quadCLT_aux,
disparity_bimap, // double [][] src_bimap, // current state of measurements (or null for new measurement)
prev_bimap, // double [][] prev_bimap, // previous state of measurements or null
scale_bad, // double [] scale_bad,
refine_inter, // int refine_mode, // 0 - by main, 1 - by aux, 2 - by inter
false, // boolean keep_inf, // keep expected disparity 0.0 if it was so
0.0, // clt_parameters.rig.refine_min_strength , // double refine_min_strength, // do not refine weaker tiles
0.0, // clt_parameters.rig.refine_tolerance , // double refine_tolerance, // do not refine if absolute disparity below
lt_select, // trusted_measurements, // tile_list, // ArrayList<Integer> tile_list, // or null
num_new, // int [] num_new,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
lt_radius, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// disable window preset in refine mode
true, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
prev_bimap = disparity_bimap;
disparity_bimap = disparity_bimap_new;
// re-smooth target disparity
if (debugLevel > 10) {(new showDoubleFloatArrays()).showArrays(
disparity_bimap,
tilesX,
disparity_bimap[0].length/tilesX,
true,
quadCLT_main.image_name+"RE-MEASURED,R"+lt_radius,
ImageDtt.BIDISPARITY_TITLES);
}
double [][] ds3 = biScan.fillAndSmooth(
disparity_bimap[ImageDtt.BI_TARGET_INDEX], // ds1[0], // final double [] src_disparity,
null, // lt_strength, // final double [] src_strength, // if not null will be used for weighted pull
lt_select, // final boolean [] selection,
neib_pull, // final double neib_pull, // pull to weighted average relative to pull to the original disparity value. If 0.0 - will only update former NaN-s
max_iter, // final int max_iterations,
min_change, // final double min_change,
clt_parameters.tileX, // final int dbg_x,
clt_parameters.tileY, // final int dbg_y,
debugLevel+2); // final int debugLevel
if (debugLevel > 10) {
biScan.showScan(quadCLT_main.image_name+"-resmooth-"+nref,ds3);
}
/*
trusted_measurements = getTrustedDisparityInter(
0.0, // clt_parameters.rig.lt_trusted_strength*clt_parameters.rig.lt_need_friends, // double min_inter_strength, // check correlation strength combined for all 3 correlations
clt_parameters.grow_disp_trust, // double max_trusted_disparity,
trusted_measurements, // boolean [] was_trusted,
disparity_bimap ); // double [][] bimap // current state of measurements
*/
if (debugLevel > -2) {
System.out.println("groundTruthByRigPlanes(): refinement step="+nref+" num_new= "+num_new[0]+" tiles");
}
if (num_new[0] < clt_parameters.rig.pf_min_new) break;
}
(new showDoubleFloatArrays()).showArrays(
disparity_bimap,
tilesX,
disparity_bimap[0].length/tilesX,
true,
quadCLT_main.image_name+"CORR-AVG"+lt_radius,
ImageDtt.BIDISPARITY_TITLES);
}
} else {
biScan.showScan(quadCLT_main.image_name+"BiScan-"+scan_index,ds);
}
biScan.showScan("BiScan-"+scan_index,ds);
return true;
}
......@@ -2692,7 +2966,9 @@ if (debugLevel > -100) return true; // temporarily !
null, // ArrayList<Integer> tile_list, // or null. If non-null - do not remeasure members of the list
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// use default mode:
clt_parameters.rig.no_int_x0, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -2737,6 +3013,9 @@ if (debugLevel > -100) return true; // temporarily !
num_new, // int [] num_new,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// refine mode - disable window preset:
true, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -2844,6 +3123,10 @@ if (debugLevel > -100) return true; // temporarily !
num_new, // int [] num_new,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// disable window preset in refine mode
true, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -3114,6 +3397,9 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_aux, // QuadCLT quadCLT_aux,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// first measurement - use default value:
clt_parameters.rig.no_int_x0, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -3151,6 +3437,10 @@ if (debugLevel > -100) return true; // temporarily !
num_new, // int [] num_new,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
// in refine mode disable int preset of the window
true, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -3518,6 +3808,8 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_parameters.fat_zero, // double fatzero,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
0, // final int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
clt_parameters.rig.no_int_x0, // final boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -3543,6 +3835,8 @@ if (debugLevel > -100) return true; // temporarily !
QuadCLT quadCLT_aux,
EyesisCorrectionParameters.CLTParameters clt_parameters,
boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using (2*notch_mode+1)^2 square
boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel){
......@@ -3570,6 +3864,8 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_parameters.fat_zero, // double fatzero,
notch_mode, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
lt_rad, // final int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
no_int_x0, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
......@@ -3655,23 +3951,24 @@ if (debugLevel > -100) return true; // temporarily !
* @return results of the new measurements combined with the old results
*/
public double [][] refineRig(
QuadCLT quadCLT_main, // tiles should be set
QuadCLT quadCLT_aux,
double [][] src_bimap, // current state of measurements
double [][] prev_bimap, // previous state of measurements or null
double [] scale_bad,
int refine_mode, // 0 - by main, 1 - by aux, 2 - by inter
boolean keep_inf, // keep expected disparity 0.0 if it was so
double refine_min_strength, // do not refine weaker tiles
double refine_tolerance, // do not refine if absolute disparity below
ArrayList<Integer> tile_list, // or null
int [] num_new,
EyesisCorrectionParameters.CLTParameters clt_parameters,
boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel){
QuadCLT quadCLT_main, // tiles should be set
QuadCLT quadCLT_aux,
double [][] src_bimap, // current state of measurements
double [][] prev_bimap, // previous state of measurements or null
double [] scale_bad,
int refine_mode, // 0 - by main, 1 - by aux, 2 - by inter
boolean keep_inf, // keep expected disparity 0.0 if it was so
double refine_min_strength, // do not refine weaker tiles
double refine_tolerance, // do not refine if absolute disparity below
ArrayList<Integer> tile_list, // or null
int [] num_new,
EyesisCorrectionParameters.CLTParameters clt_parameters,
boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using (2*notch_mode+1)^2 square
final boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel){
boolean [] selection = null;
if (tile_list != null) {
selection = new boolean [quadCLT_main.tp.getTilesX() * quadCLT_main.tp.getTilesY()];
......@@ -3691,6 +3988,8 @@ if (debugLevel > -100) return true; // temporarily !
num_new,
clt_parameters,
notch_mode, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
lt_rad, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
no_int_x0, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
......@@ -3709,7 +4008,9 @@ if (debugLevel > -100) return true; // temporarily !
boolean [] selection,
int [] num_new,
EyesisCorrectionParameters.CLTParameters clt_parameters,
final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
final int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using (2*notch_mode+1)^2 square
final boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel){
......@@ -3727,6 +4028,7 @@ if (debugLevel > -100) return true; // temporarily !
int nTile = tileY * tilesX + tileX;
if (((selection == null) || selection[nTile]) && !Double.isNaN(src_bimap[ImageDtt.BI_TARGET_INDEX][nTile])) {
if (prepRefineTile(
(lt_rad > 0),
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
tile_op_all, // int tile_op_all,
src_bimap, // double [][] src_bimap, // current state of measurements
......@@ -3760,6 +4062,8 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_parameters.fat_zero, // double fatzero,
notch_mode, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
lt_rad, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
no_int_x0, // final boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel)
......@@ -3807,6 +4111,8 @@ if (debugLevel > -100) return true; // temporarily !
ArrayList<Integer> tile_list, // or null. If non-null - do not remeasure members of the list
EyesisCorrectionParameters.CLTParameters clt_parameters,
boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using (2*notch_mode+1)^2 square
boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel){
......@@ -3843,6 +4149,8 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_parameters.fat_zero, // double fatzero,
notch_mode, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
lt_rad, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
no_int_x0, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel)
......@@ -3896,6 +4204,8 @@ if (debugLevel > -100) return true; // temporarily !
double [] disparity, // Double.NaN - skip, ohers - measure
EyesisCorrectionParameters.CLTParameters clt_parameters,
boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using (2*notch_mode+1)^2 square
boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel){
......@@ -3923,6 +4233,8 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_parameters.fat_zero, // double fatzero,
notch_mode, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
lt_rad, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
no_int_x0, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel)
......@@ -3933,6 +4245,7 @@ if (debugLevel > -100) return true; // temporarily !
private boolean prepRefineTile(
boolean remeasure_nan, // use old suggestion if result of the measurement was NaN
EyesisCorrectionParameters.CLTParameters clt_parameters,
int tile_op_all,
double [][] src_bimap, // current state of measurements
......@@ -3990,6 +4303,17 @@ if (debugLevel > -100) return true; // temporarily !
strength = src_bimap[ImageDtt.BI_STR_CROSS_INDEX][nTile];
disp_scale = disp_scale_inter;
}
if (Double.isNaN(diff_disp)) {
if (remeasure_nan) {
tile_op[tileY][tileX] = tile_op_all;
disparity_array[tileY][tileX] = src_bimap[ImageDtt.BI_TARGET_INDEX][nTile]; // repeat previous - only makes sense with averaging
return true;
} else {
return false;
}
}
// strong enough?
if (strength < refine_min_strength) return false;
// residual disparity large enough to bother
......@@ -4031,7 +4355,6 @@ if (debugLevel > -100) return true; // temporarily !
// if (Math.abs((new_disp - ref_target)/new_disp) < refine_tolerance) return false;
if (Math.abs(new_disp - ref_target) < refine_tolerance) return false;
disparity_array[tileY][tileX] = new_disp;
tile_op[tileY][tileX] = tile_op_all;
return true;
......@@ -4039,17 +4362,19 @@ if (debugLevel > -100) return true; // temporarily !
private double [][] measureRig(
QuadCLT quadCLT_main, // tiles should be set
QuadCLT quadCLT_aux,
int [][] tile_op, // common for both amin and aux
double [][] disparity_array,
double [][] ml_data, // data for ML - 10 layers - 4 center areas (3x3, 5x5,..) per camera-per direction, 1 - composite, and 1 with just 1 data (target disparity)
EyesisCorrectionParameters.CLTParameters clt_parameters,
double fatzero,
boolean notch_mode, // use pole-detection mode for inter-camera correlation
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel){
QuadCLT quadCLT_main, // tiles should be set
QuadCLT quadCLT_aux,
int [][] tile_op, // common for both amin and aux
double [][] disparity_array,
double [][] ml_data, // data for ML - 10 layers - 4 center areas (3x3, 5x5,..) per camera-per direction, 1 - composite, and 1 with just 1 data (target disparity)
EyesisCorrectionParameters.CLTParameters clt_parameters,
double fatzero,
boolean notch_mode, // use pole-detection mode for inter-camera correlation
int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using (2*notch_mode+1)^2 square
boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel){
ImageDtt image_dtt = new ImageDtt();
double [][] disparity_bimap = new double [ImageDtt.BIDISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) last 4 - max pixel differences
......@@ -4057,7 +4382,9 @@ if (debugLevel > -100) return true; // temporarily !
image_dtt.clt_bi_quad (
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
fatzero, // final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
notch_mode, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
notch_mode, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
lt_rad, // final int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
no_int_x0, // final boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
tile_op, // final int [][] tile_op_main, // [tilesY][tilesX] - what to do - 0 - nothing for this tile
disparity_array, // final double [][] disparity_array, // [tilesY][tilesX] - individual per-tile expected disparity
quadCLT_main.image_data, // final double [][][] image_data_main, // first index - number of image in a quad
......@@ -4093,6 +4420,7 @@ if (debugLevel > -100) return true; // temporarily !
EyesisCorrectionParameters.CLTParameters clt_parameters,
int ml_hwidth,
double fatzero,
int lt_rad, // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using (2*notch_mode+1)^2 square
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel){
......@@ -4160,6 +4488,8 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
fatzero, // double fatzero,
false, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
lt_rad, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
true, // whatever here. final boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very
threadsMax, // maximal number of threads to launch // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel)
......
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