Commit db3deeef authored by Andrey Filippov's avatar Andrey Filippov

Developing dual-max LMA. Before simultaneous fitting

parent b9cc7d77
......@@ -547,7 +547,6 @@ public class Corr2dLMA {
}
}
// apply corrections
if (apply) {
for (int ncam = 0; ncam <num_cams; ncam++) {
......@@ -1636,7 +1635,28 @@ public class Corr2dLMA {
return xy_offsets;
}
/**
* Calculate offsets for multiple disparities, for each defined pair x,y expected offset, assuming only disparity, not lazy eye
* @param corrs - pairs 2D correlations (each in scanline order) - just to determine null/non-null
* @param disparity_strengths - expected {disparity, strength} pairs (e.g. from CM)
* @param disp_dist - per camera disparity matrix as a 1d (linescan order))
* @return array of per-disparity, per pair x,y expected center offset in 2D correlations or nulls for undefined pairs (or null if already set)
*/
public double [][][] getPairsOffsets(
double [][] corrs,
boolean [] pair_mask,
double [][] disparity_strengths,
double [][] disp_dist){ //
double [][][] pairs_offsets = new double [disparity_strengths.length][][];
for (int i = 0; i < pairs_offsets.length; i++) {
pairs_offsets[i] = getPairsOffsets(
corrs, // double [][] corrs,
pair_mask, // boolean [] pair_mask,
disparity_strengths[i][0], // double disparity,
disp_dist); // double [][] disp_dist)
}
return pairs_offsets;
}
public void printParams() { // not used in lwir
// to make sure it is updated
......@@ -2062,7 +2082,7 @@ public class Corr2dLMA {
double [][] maxmin_amp = getMaxMinAmpTile();
double [][] abc = getABCTile();
for (int tile = 0; tile < numTiles; tile++) {
ds[tile][0] = Double.NaN;
ds[tile][0] = Double.NaN + 0;
if (Double.isNaN(maxmin_amp[tile][0])) {
continue;
}
......
......@@ -2631,7 +2631,8 @@ public class ImageDtt extends ImageDttCPU {
if (debugTile1) {
correlation2d.corrLMA2DualMax( // null pointer
imgdtt_params, // ImageDttParameters imgdtt_params,
imgdtt_params.lmas_LY_single, // false, // boolean adjust_ly, // adjust Lazy Eye
1, // int combine_mode, // 0 - both, 1 - strongest, 2 - nearest to zero, 3 - FG, 4 - BG
// imgdtt_params.lmas_LY_single, // false, // boolean adjust_ly, // adjust Lazy Eye
corr_wnd, // double [][] corr_wnd, // correlation window to save on re-calculation of the window
corr_wnd_inv_limited, // corr_wnd_limited, // correlation window, limited not to be smaller than threshold - used for finding max/convex areas (or null)
corrs, // corrs, // double [][] corrs,
......@@ -2639,12 +2640,11 @@ public class ImageDtt extends ImageDttCPU {
rXY, // double [][] rXY, // non-distorted X,Y offset per nominal pixel of disparity
// all that are not null in corr_tiles
correlation2d.selectAll(), // longToArray(imgdtt_params.dbg_pair_mask), // int pair_mask, // which pairs to process
maxes, //double[][] disp_str_dual, // -preliminary center x in pixels for largest baseline
maxes, //double[][] disp_str_dual, // -preliminary center x in pixels for largest baseline
null, // poly_disp, // double[] poly_ds, // null or pair of disparity/strength
imgdtt_params.ortho_vasw_pwr, // double vasw_pwr, // value as weight to this power,
null, // debug_lma_tile, // double [] debug_lma_tile,
(debugTile0 ? 1: -2), // int debug_level,
// -2, //0, // tile_lma_debug_level, // +2, // int debug_level,
tileX, // int tileX, // just for debug output
tileY );
......
......@@ -77,6 +77,14 @@ public class ImageDttParameters {
public int dbg_pair_mask = 0x3f; // which pairs to combine
public int corr_strip_hight = 9; // number of rows to calculate
//bimax_
public double bimax_lpf_neib = 0.5; // if >0, add ortho neibs (corners - squared)
public double bimax_notch_pwr = 4.0; // calculating notch filter to suppress input data of the weaker maximum
public double bimax_adv_power = 2.0; // reduce weight from overlap with adversarial maximum
public int bimax_rad_convex_search = 2; // how far from predicted to search for maximums
public int bimax_min_num_samples = 4; // minimal number of samples per pair per maximum
public int bimax_min_num_pairs = 8; // minimal number of used pairs
//lmamask_
public boolean lmamask_dbg = false; // show LMA images, exit after single BG
public boolean lmamask_en = false; // Use disparity-based LMA samples filter
......@@ -450,6 +458,21 @@ public class ImageDttParameters {
gd.addNumericField("Number of correlation rows to combine (strip height)", this.corr_strip_hight, 0, 3, "",
"Number of rows to combine/interpolate correlation results. Rows are twice denser than pixels correponding to largest baseline disparity");
gd.addMessage("LMA prefiltering for dual disparities in a tile");
gd.addNumericField("LPF for combined maximums", this.bimax_lpf_neib, 6,8,"",
"0 - no LPF, >0 - add 4 scaled ortho neighbors and 4 corners bscaled as square of this value");
gd.addNumericField("Notch filter power", this.bimax_notch_pwr, 6,8,"",
"Reduce offending (other) correlation maximum by multiplying. High power reduces all < 1.0 values");
gd.addNumericField("Reduction of sample weight by the other maximum", this.bimax_adv_power, 6,8,"",
"If X= (this strength /other strength), scale by X/(1+X) to theis power");
gd.addNumericField("Convex max search around predicted disparity", this.bimax_rad_convex_search, 0, 3, "",
"How far from predicted to search for maximums");
gd.addNumericField("Minimal samples per pair per max", this.bimax_min_num_samples, 0, 3, "",
"Minimal number of samples per pair per maximum to use this pair by LMA (each of the maximums used)");
gd.addNumericField("Minimal number of used pairs", this.bimax_min_num_pairs, 0, 3, "",
"Do not use LMA if total number of used pairs is lower");
gd.addMessage("LMA samples filter based on estimated disparity");
gd.addCheckbox ("Debug LMA", this.lmamask_dbg,
"Generate debug images and exit after first clt_process_tl_correlations() while generating background image");
......@@ -856,9 +879,16 @@ public class ImageDttParameters {
this.min_corr = gd.getNextNumber();
this.dbg_pair_mask= (int) gd.getNextNumber();
this.corr_strip_hight= (int) gd.getNextNumber();
this.dbg_pair_mask= (int) gd.getNextNumber();
this.corr_strip_hight= (int) gd.getNextNumber();
this.bimax_lpf_neib = gd.getNextNumber();
this.bimax_notch_pwr = gd.getNextNumber();
this.bimax_adv_power = gd.getNextNumber();
this.bimax_rad_convex_search= (int) gd.getNextNumber();
this.bimax_min_num_samples= (int) gd.getNextNumber();
this.bimax_min_num_pairs= (int) gd.getNextNumber();
this.lmamask_dbg = gd.getNextBoolean();
this.lmamask_en = gd.getNextBoolean();
this.lmamask_magic = gd.getNextNumber();
......@@ -1077,6 +1107,13 @@ public class ImageDttParameters {
properties.setProperty(prefix+"dbg_pair_mask", this.dbg_pair_mask +"");
properties.setProperty(prefix+"corr_strip_hight", this.corr_strip_hight +"");
properties.setProperty(prefix+"bimax_lpf_neib", this.bimax_lpf_neib +"");
properties.setProperty(prefix+"bimax_notch_pwr", this.bimax_notch_pwr +"");
properties.setProperty(prefix+"bimax_adv_power", this.bimax_adv_power +"");
properties.setProperty(prefix+"bimax_rad_convex_search", this.bimax_rad_convex_search +"");
properties.setProperty(prefix+"bimax_min_num_samples", this.bimax_min_num_samples +"");
properties.setProperty(prefix+"bimax_min_num_pairs", this.bimax_min_num_pairs +"");
properties.setProperty(prefix+"lmamask_dbg", this.lmamask_dbg +"");
properties.setProperty(prefix+"lmamask_en", this.lmamask_en +"");
......@@ -1301,8 +1338,14 @@ public class ImageDttParameters {
if (properties.getProperty(prefix+"dbg_pair_mask")!=null) this.dbg_pair_mask=Integer.parseInt(properties.getProperty(prefix+"dbg_pair_mask"));
if (properties.getProperty(prefix+"corr_strip_hight")!=null) this.corr_strip_hight=Integer.parseInt(properties.getProperty(prefix+"corr_strip_hight"));
if (properties.getProperty(prefix+"bimax_lpf_neib")!=null) this.bimax_lpf_neib=Double.parseDouble(properties.getProperty(prefix+"bimax_lpf_neib"));
if (properties.getProperty(prefix+"bimax_notch_pwr")!=null) this.bimax_notch_pwr=Double.parseDouble(properties.getProperty(prefix+"bimax_notch_pwr"));
if (properties.getProperty(prefix+"bimax_adv_power")!=null) this.bimax_adv_power=Double.parseDouble(properties.getProperty(prefix+"bimax_adv_power"));
if (properties.getProperty(prefix+"bimax_rad_convex_search")!=null) this.bimax_rad_convex_search=Integer.parseInt(properties.getProperty(prefix+"bimax_rad_convex_search"));
if (properties.getProperty(prefix+"bimax_min_num_samples")!=null) this.bimax_min_num_samples=Integer.parseInt(properties.getProperty(prefix+"bimax_min_num_samples"));
if (properties.getProperty(prefix+"bimax_min_num_pairs")!=null) this.bimax_min_num_pairs=Integer.parseInt(properties.getProperty(prefix+"bimax_min_num_pairs"));
if (properties.getProperty(prefix+"lmamask_dbg")!=null) this.lmamask_dbg=Boolean.parseBoolean(properties.getProperty(prefix+"lmamask_dbg"));
if (properties.getProperty(prefix+"lmamask_dbg")!=null) this.lmamask_dbg=Boolean.parseBoolean(properties.getProperty(prefix+"lmamask_dbg"));
if (properties.getProperty(prefix+"lmamask_en")!=null) this.lmamask_en=Boolean.parseBoolean(properties.getProperty(prefix+"lmamask_en"));
if (properties.getProperty(prefix+"lmamask_magic")!=null) this.lmamask_magic=Double.parseDouble(properties.getProperty(prefix+"lmamask_magic"));
if (properties.getProperty(prefix+"lmamask_min_main")!=null) this.lmamask_min_main=Double.parseDouble(properties.getProperty(prefix+"lmamask_min_main"));
......@@ -1542,6 +1585,13 @@ public class ImageDttParameters {
idp.dbg_pair_mask= this.dbg_pair_mask;
idp.corr_strip_hight= this.corr_strip_hight;
idp.bimax_lpf_neib= this.bimax_lpf_neib;
idp.bimax_notch_pwr= this.bimax_notch_pwr;
idp.bimax_adv_power= this.bimax_adv_power;
idp.bimax_rad_convex_search= this.bimax_rad_convex_search;
idp.bimax_min_num_samples= this.bimax_min_num_samples;
idp.bimax_min_num_pairs= this.bimax_min_num_pairs;
idp.lmamask_dbg= this.lmamask_dbg;
idp.lmamask_en= this.lmamask_en;
idp.lmamask_magic= this.lmamask_magic;
......
......@@ -4361,7 +4361,9 @@ public class OpticalFlow {
// Save pair selection and minimize them for scanning, then restore;
int num_sensors =scenes[indx_ref].getNumSensors();
int save_pairs_selection = clt_parameters.img_dtt.getMcorr(num_sensors);
clt_parameters.img_dtt.setMcorr(num_sensors, 0 ); // remove all
// FIXME: uncomment next
System.out.println ("++++ Uncomment next line ++++");
//// clt_parameters.img_dtt.setMcorr(num_sensors, 0 ); // remove all
clt_parameters.img_dtt.setMcorrNeib(num_sensors,true);
clt_parameters.img_dtt.setMcorrSq (num_sensors,true); // remove even more?
clt_parameters.img_dtt.setMcorrDia (num_sensors,true); // remove even more?
......
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