@@ -920,19 +963,235 @@ public class Correlation2d {
...
@@ -920,19 +963,235 @@ public class Correlation2d {
returnpadded_strip;
returnpadded_strip;
}
}
publicvoidcorrLMA(
// returns array 3*num_pairs long
// TODO: now works for small offsets. Maybe add re-calculate int argmax for each pair? xcenter is still needed to subtract Add switch? (small/large correction)
publicdouble[]mismatchPairs(// returns x-xcenter, y, strength (sign same as disparity)
ImageDttParametersimgdtt_params,
ImageDttParametersimgdtt_params,
double[][]corrs,
double[][]corrs,
doublexcenter,// preliminary center x in pixels for largest baseline
intpair_mask,// which pairs to process
double[]window_y,// (half) window function in y-direction(perpendicular to disparity: for row0 ==1
doublexcenter,// -disparity to compare
double[]window_x,// half of a window function in x (disparity) direction
// double w = wxy; // full weight before value as weight
doublev=groups_LMA[ig][center_index+width*cy+cx];
doublew=filtWeight[center_index+width*cy+cx]*groups_pairs[ig][0];// number of pair averaged
if(vasw_pwr!=0){
if(w>0.0){
w*=Math.pow(Math.abs(v),vasw_pwr);
doublev=groups_LMA[ig][center_index+width*cy+cx];
if(vasw_pwr!=0){
w*=Math.pow(Math.abs(v),vasw_pwr);
}
lma.addSample(
quad_signs[quad][0]*acol*scale05+xcs,// x * scale, // double x, // x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
quad_signs[quad][1]*arow*scale05,// y * scale, // double y, // y coordinate (0 - disparity axis)
v,// double v, // correlation value at that point
w,// double w,
group_scale_ind[ig],// int si, // baseline scale index
ig);// int gi);
}
}
lma.addSample(
quad_signs[quad][0]*acol*scale05+xcs,// x * scale, // double x, // x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
quad_signs[quad][1]*arow*scale05,// y * scale, // double y, // y coordinate (0 - disparity axis)
v,// double v, // correlation value at that point
w,// double w,
group_scale_ind[ig],// int si, // baseline scale index
ig);// int gi);
}
}
}
}
}
}
}
}
}else{// ortho
}else{// ortho
for(intarow=0;arow<hwindow_y;arow+=2){
for(intarow=0;arow<hwindow_y2;arow+=2){
doublewy=window_y[arow]*groups_pairs[0][0];// number of pair averaged
// double wy = window_y[arow] * groups_pairs[0][0]; // number of pair averaged
for(intacol=0;acol<hwindow_x;acol+=2){
for(intacol=0;acol<hwindow_x2;acol+=2){
doublewxy=window_x[acol]*wy;// full weight before value as weight
// double wxy = window_x[acol] * wy; // full weight before value as weight
// double w = wxy; // full weight before value as weight
doublev=groups_LMA[ig][center_index+width*cy+cx];
doublew=filtWeight[center_index+width*cy+cx]*groups_pairs[ig][0];// number of pair averaged;
if(vasw_pwr!=0){
if(w>0.0){
w*=Math.pow(Math.abs(v),vasw_pwr);
doublev=groups_LMA[ig][center_index+width*cy+cx];
if(vasw_pwr!=0){
w*=Math.pow(Math.abs(v),vasw_pwr);
}
lma.addSample(
quad_signs[quad][0]*acol*scale05+xcs,// x * scale, // double x, // x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
quad_signs[quad][1]*arow*scale05,// y * scale, // double y, // y coordinate (0 - disparity axis)
v,// double v, // correlation value at that point
w,// double w,
group_scale_ind[ig],// int si, // baseline scale index
ig);// int gi);
}
}
lma.addSample(
quad_signs[quad][0]*acol*scale05+xcs,// x * scale, // double x, // x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
quad_signs[quad][1]*arow*scale05,// y * scale, // double y, // y coordinate (0 - disparity axis)
v,// double v, // correlation value at that point
w,// double w,
group_scale_ind[ig],// int si, // baseline scale index
ig);// int gi);
}
}
}
}
}
}
...
@@ -1066,38 +1696,298 @@ public class Correlation2d {
...
@@ -1066,38 +1696,298 @@ public class Correlation2d {
}
}
}
}
lma.initVector(
}
imgdtt_params.lma_adjust_wm,// boolean adjust_wm,
imgdtt_params.lma_adjust_wy,// boolean adjust_wy,
// Mimics addSamples, but reads f(x) values instead of setting them
"false - return (old) per-coor correlations, true - replace them with more pairs correlation (new)");
gd.addCheckbox("Replace CM layer with mixed/new poly one",this.mix_corr_poly);
gd.addCheckbox("Replace CM layer with mixed/new poly one",this.mix_corr_poly);
gd.addNumericField("Use poly mode if strength is greater than",this.min_poly_strength,3,6,"","AND condition");
gd.addNumericField("Use poly mode if strength is greater than",this.min_poly_strength,3,6,"","AND condition");
gd.addNumericField("Maximal polynomial approximation half-width",this.max_poly_hwidth,3,6,"pix","Maximal polynomial approximation half-width (in both directions), Most now are ~2.0");
gd.addNumericField("Maximal polynomial approximation half-width",this.max_poly_hwidth,3,6,"pix","Maximal polynomial approximation half-width (in both directions), Most now are ~2.0");
...
@@ -107,20 +125,37 @@ public class ImageDttParameters {
...
@@ -107,20 +125,37 @@ public class ImageDttParameters {
gd.addNumericField("Multiply center correlation pixels (inside enhortho_width) (1.0 - disables enh_orttho)",this.enhortho_scale,3);
gd.addNumericField("Multiply center correlation pixels (inside enhortho_width) (1.0 - disables enh_orttho)",this.enhortho_scale,3);
gd.addMessage("Far objects correction");
gd.addMessage("Far objects correction");
gd.addCheckbox("Try to correct far objects (make them closer) by hor/vert comparison",this.far_object_correct);
gd.addCheckbox("Try to correct far objects (make them closer) by hor/vert comparison",this.fo_correct);
"Limit full correction with respect to largest - fullcorr difference. 1.0 does not allow overcorrection, < 1.0 - the result will be closer to full correction");
"Limit full correction with respect to largest - fullcorr difference. 1.0 does not allow overcorrection, < 1.0 - the result will be closer to full correction");
gd.addNumericField("Maximal disparity difference to calculate mismatch",this.mismatch_max_diff,3,6,"",
"Too low value will disqualify large mismatches, too high - treat multi-z disparity as mismatch");
gd.addNumericField("Add to pair correlation before multiplying by other pairs",this.corr_offset,6,8,"",
gd.addNumericField("Add to pair correlation before multiplying by other pairs",this.corr_offset,6,8,"",
"0.0 - pure product (false-positive tolerant), higher the value - closer to the sum (linear, better S/N");
"0.0 - pure product (false-positive tolerant), higher the value - closer to the sum (linear, better S/N");
gd.addCheckbox("Double weight of diagonal pairs when combining",this.twice_diagonal,
"Diagonal pairs provide twice denser samples, when true it doubles the weight of diagonal pairs");
gd.addNumericField("Extract disparity max/argmax if maximal value is above",this.min_corr,6,8,"",
gd.addNumericField("Extract disparity max/argmax if maximal value is above",this.min_corr,6,8,"",
"skip unreliable correlations");
"skip unreliable correlations");
...
@@ -129,6 +164,16 @@ public class ImageDttParameters {
...
@@ -129,6 +164,16 @@ public class ImageDttParameters {