// proceed only if CM correlation result is non-null // for compatibility with old code we need it to run regardless of the strength of the normal correlation
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[cTile],// double [][] corrs,
disp_dist[cTile],
rXY,// double [][] rXY, // non-distorted X,Y offset per nominal pixel of disparity
imgdtt_params.dbg_pair_mask,// int pair_mask, // which pairs to process
null,// disp_str[cTile], //corr_stat[0], // double xcenter, // preliminary center x in pixels for largest baseline
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,
tdl,// tile_lma_debug_level, //+2, // int debug_level,
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[cTile],// double [][] corrs,
disp_dist[cTile],
rXY,// double [][] rXY, // non-distorted X,Y offset per nominal pixel of disparity
imgdtt_params.dbg_pair_mask,// int pair_mask, // which pairs to process
// false, // boolean run_poly_instead, // true - run LMA, false - run 2d polynomial approximation
disp_str[cTile],//corr_stat[0], // double xcenter, // preliminary center x in pixels for largest baseline
imgdtt_params.ortho_vasw_pwr,// double vasw_pwr, // value as weight to this power,
tile_lma_debug_level,//+2, // int debug_level,
tileX,// int tileX, // just for debug output
tileY);// int tileY
disp_str[cTile]=null;
if(lma2!=null){
disp_str[cTile]=lma2.disparityStrength(
imgdtt_params.lma_max_rel_rms,// maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
imgdtt_params.lma_min_strength,// minimal composite strength (sqrt(average amp squared over absolute RMS)
imgdtt_params.lma_min_ac,// minimal of A and C coefficients maximum (measures sharpest point/line)
imgdtt_params.lma_str_scale,// convert lma-generated strength to match previous ones - scale
imgdtt_params.lma_str_offset// convert lma-generated strength to match previous ones - add to result
)[0];
if(tile_lma_debug_level>0){
double[][]ds_dbg={disp_str[cTile]};
lma2.printStats(ds_dbg,1);
}
}
}
}// end of if (corr_stat != null)
}
//} // end of if (corr_stat != null)
}// if (disparity_map != null){ // not null - calculate correlations
// only debug is left
}
}
}
}
if(debugCluster){
if(true){//debugCluster1) {
if(globalDebugLevel>0){
System.out.println("Will run new LMA for clustX="+clustX+", clustY="+clustY);
corr_wnd_inv_limited,// corr_wnd_inv_limited, // correlation window, limited not to be smaller than threshold - used for finding max/convex areas (or null)
corrs,// [tIndex], // double [][] corrs,
disp_dist,// [tIndex],
rXY,// double [][] rXY, // non-distorted X,Y offset per nominal pixel of disparity
rXY,// double [][] rXY, // non-distorted X,Y offset per nominal pixel of disparity
imgdtt_params.dbg_pair_mask,// int pair_mask, // which pairs to process
disp_str,// corr_stat, // double[][] xcenter_str, // preliminary center x in pixels for largest baseline
imgdtt_params.ortho_vasw_pwr,// double vasw_pwr, // value as weight to this power,
clust_lma_debug_level+0,// 2, // int debug_level,
// ddnd, // double [][] ddnd, // should provide [4][]
// stats, // double [][] stats, // should provide [1][]
clust_lma_debug_level+0,// 2, // int debug_level, // for a single cluster
clustX,// int tileX, // just for debug output
clustY);// int tileY
if(lma2!=null){
double[][]ddnd=lma2.getDdNd();
double[]stats=lma2.getStats();
double[][]lma2_ds=lma2.disparityStrength(
imgdtt_params.lma_max_rel_rms,// maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
imgdtt_params.lma_min_strength,// minimal composite strength (sqrt(average amp squared over absolute RMS)
imgdtt_params.lma_min_ac,// minimal of A and C coefficients maximum (measures sharpest point/line)
imgdtt_params.lma_str_scale,// convert lma-generated strength to match previous ones - scale
imgdtt_params.lma_str_offset);// convert lma-generated strength to match previous ones - add to result
for(intcTileY=0;cTileY<tileStep;cTileY++){
tileY=clustY*tileStep+cTileY;
if(tileY<tilesY){
for(intcTileX=0;cTileX<tileStep;cTileX++){
tileX=clustX*tileStep+cTileX;
if(tileX<tilesX){
cTile=cTileY*tileStep+cTileX;
tIndex=tileY*tilesX+tileX;
// int nTile = tileY * tilesX + tileX; // how is it different from tIndex?
publicdoublelmas_poly_str_min=0.05;// ignore tiles with poly strength (scaled) below
publicdoublelmas_lambda_initial=0.03;//
publicdoublelmas_rms_diff=0.001;//
publicintlmas_num_iter=20;//
// Filtering and strength calculation
publicdoublelmas_max_rel_rms=0.2;// maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
publicdoublelmas_min_strength=1.0;// minimal composite strength (sqrt(average amp squared over absolute RMS)
publicdoublelmas_min_ac=0.03;// minimal of a and C coefficients maximum (measures sharpest point/line)
publicbooleanlma_gaussian=false;// model correlation maximum as a Gaussian (false - as a parabola)
publicbooleanlma_second=true;// re-run LMA after removing weak/failed tiles
publicbooleanlma_second_gaussian=true;// re-run after removing weal/failed in Gaussian mode
publicbooleanlma_second=false;// re-run LMA after removing weak/failed tiles
publicbooleanlma_second_gaussian=false;// re-run after removing weal/failed in Gaussian mode
publicbooleanlma_adjust_wm=true;// used in new for width
publicbooleanlma_adjust_wy=true;// false; // used in new for ellipse
publicbooleanlma_adjust_wxy=true;// used in new for lazy eye adjust parallel-to-disparity correction
...
...
@@ -117,12 +134,13 @@ public class ImageDttParameters {
publicdoublelma_sigma=0.7;// Blur correlation before finding maximum and convex region
// maybe try using sqrt (corr_wnd) ? or variable power?
publicdoublelma_half_width=2.0;//
publicdoublelma_cost_wy=0.003;// cost of parallel-to-disparity correction
publicdoublelma_cost_wxy=0.003;// cost of ortho-to-disparity correction
publicdoublelma_cost_wy=0.0;// cost of parallel-to-disparity correction
publicdoublelma_cost_wxy=0.0;// cost of ortho-to-disparity correction
publicdoublelma_lambda_initial=0.03;//
publicdoublelma_lambda_scale_good=0.5;//
...
...
@@ -139,8 +157,10 @@ public class ImageDttParameters {
publicdoublelma_str_offset=0.05;// convert lma-generated strength to match previous ones - add to result
// Lazy eye results interpretation
publicbooleanlma_diff_xy=true;// convert dd/nd to x,y
publicdoublelma_diff_minw=0.5;// minimal weight to keep
publicdoublelma_diff_sigma=1.0;// blur differential data (relative to the cluster linear size)
publicintlma_debug_level=0;//
publicintlma_debug_level1=0;//
...
...
@@ -290,6 +310,38 @@ public class ImageDttParameters {
"Transition range, shifted sine is used");
gd.addTab("Corr LMA","Parameters for LMA fitting of the correlation maximum parameters");
gd.addMessage("Single-tile (no lazy eye) only parameters (some are common");
gd.addCheckbox("Correlation maximum as gaussian",this.lmas_gaussian,
"Model correlation maximum as a Gaussian exp(-r^2) (false - as a parabola - 1-r^2)");
gd.addCheckbox("Fit correlation defined half-width",this.lmas_adjust_wm,
"Allow fitting of the half-width common for all pairs, defined by the LPF filter of the phase correlation");
gd.addCheckbox("Adjust ellipse parameters (was Fit extra vertical half-width)",this.lmas_adjust_wy,
"Adjust ellipse (non-circular) of the correlation maximum (was Fit extra perpendicular to disparity half-width (not used? and only possible with multi-baseline cameras))");