Commit b4b58042 authored by Andrey Filippov's avatar Andrey Filippov

Fixed dsi_main to inter-intra-lma difference with disparity offset - now

both use the same offset
parent 96562ce2
......@@ -1593,6 +1593,7 @@ public class Interscene {
double [][] mb_vectors, // now [2][ntiles];
int debug_level)
{
boolean show_initial = true; // debug feature
boolean use3D = clt_parameters.ilp.ilma_3d;
boolean filter_by_ers = clt_parameters.ilp.ilma_ers_quads;
double gap_frac = clt_parameters.ilp.ilma_gap_frac ; // 0.25;
......@@ -1825,9 +1826,6 @@ public class Interscene {
scene_QuadClt.getImageName()+"-"+reference_QuadClt.getImageName()+"-CORR-FPN",
fpn_dbg_titles);
}
if (clt_parameters.imp.debug_level > -2) {
String [] lines1 = intersceneLma.printOldNew((clt_parameters.imp.debug_level > -1)); // false); // boolean allvectors)
System.out.println("Adjusted interscene, iteration="+nlma+
......@@ -1837,6 +1835,12 @@ public class Interscene {
for (String line : lines1) {
System.out.println(line);
}
if (show_initial) {
lines1 = intersceneLma.printOldNew(true, 1); // force "was"
for (String line : lines1) {
System.out.println(line);
}
}
}
if ((rms_out != null) && (intersceneLma.getLastRms() != null)) {
rms_out[0] = intersceneLma.getLastRms()[0];
......
......@@ -100,10 +100,16 @@ public class IntersceneLma {
}
public String [] printOldNew(boolean allvectors) {
return printOldNew(allvectors, 9, 6);
return printOldNew(allvectors, 0);
}
public String [] printOldNew(boolean allvectors, int mode) {
return printOldNew(allvectors, mode, 9, 6);
}
public String [] printOldNew(boolean allvectors, int w, int d) {
return printOldNew(allvectors, 0, w, d);
/*
String fmt1 = String.format("%%%d.%df", w+2,d+2); // more for the differences
ArrayList<String> lines = new ArrayList<String>();
for (int n = ErsCorrection.DP_DVAZ; n < ErsCorrection.DP_NUM_PARS; n+=3) {
......@@ -118,6 +124,26 @@ public class IntersceneLma {
}
}
return lines.toArray(new String[lines.size()]);
*/
}
public String [] printOldNew(boolean allvectors, int mode, int w, int d) {
// mode: 0 - auto, 1 - force "was", 2 force "pull"
String fmt1 = String.format("%%%d.%df", w+2,d+2); // more for the differences
ArrayList<String> lines = new ArrayList<String>();
for (int n = ErsCorrection.DP_DVAZ; n < ErsCorrection.DP_NUM_PARS; n+=3) {
boolean adj = false;
for (int i = 0; i <3; i++) adj |= par_mask[n+i];
if (allvectors || adj) {
String line = printNameV3(n, false, mode, w,d)+" (" + getCompareType(mode)+
" "+printNameV3(n, true, mode, w,d)+")";
line += ", diff_last="+String.format(fmt1, getV3Diff(n)[0]);
line += ", diff_first="+String.format(fmt1, getV3Diff(n)[1]);
lines.add(line);
}
}
return lines.toArray(new String[lines.size()]);
}
/**
......@@ -142,11 +168,19 @@ public class IntersceneLma {
}
public String getCompareType() {
return (parameters_pull != null)? "pull": "was";
return getCompareType(0);
// return (parameters_pull != null)? "pull": "was";
}
public String getCompareType(int mode) {
boolean is_pull = (mode == 0) ? (parameters_pull != null) : (mode > 1);
// return (parameters_pull != null)? "pull": "was";
return is_pull? "pull": "was";
}
public String printNameV3(int indx, boolean initial, int w, int d) {
boolean use_pull = parameters_pull != null;
return printNameV3(indx, initial, 0, w, d);
/*
double [] full_vector = initial?
(use_pull? getFullVector(parameters_pull) : backup_parameters_full):
getFullVector(parameters_vector);
......@@ -156,7 +190,24 @@ public class IntersceneLma {
}
String name = ErsCorrection.DP_VECTORS_NAMES[indx];
return printNameV3(name, vector, w, d);
*/
}
public String printNameV3(int indx, boolean initial, int mode, int w, int d) {
// mode: 0 - auto, 1 - was, 2 - pull
boolean use_pull = (mode == 0) ? (parameters_pull != null) : (mode > 1);
// boolean use_pull = parameters_pull != null;
double [] full_vector = initial?
(use_pull? getFullVector(parameters_pull) : backup_parameters_full):
getFullVector(parameters_vector);
double [] vector = new double[3];
for (int i = 0; i <3; i++) {
vector[i] = full_vector[indx + i];
}
String name = ErsCorrection.DP_VECTORS_NAMES[indx];
return printNameV3(name, vector, w, d);
}
public static String printNameV3(String name, double[] vector) {
return printNameV3(name, vector, 10, 6);
......
......@@ -48,6 +48,7 @@ public class IntersceneMatchParameters {
public double sfp_tolerance = 0.05; // average SfM pairs if their baselines differ less
public int sfm_readjust = 5; // number of SfM readjustment cycles
public double sfm_prev_frac = 0.6; // update if new sfm gain > this fraction of the old one
public double sfm_same_weight = 0.8; // correction weight when new SfM gain is the same as the old one
public int sfm_shrink = 2; // shrink sfm gain area before applying sfm_fade_sigma
public double sfm_fade_sigma = 3.0; // fade SfM gains at the edges
public double sfm_min_str = 0.4; // update if correction strength exceeds
......@@ -462,6 +463,8 @@ public class IntersceneMatchParameters {
"Number of SfM readjustment cycles.");
gd.addNumericField("Minimal SfM gain from previous", this.sfm_prev_frac, 5,8,"",
"Update if new sfm gain > this fraction of the old one.");
gd.addNumericField("Correction scale for equal gains", this.sfm_same_weight, 5,8,"",
"Correction scale when new SfM gain is the same as the old one.");
gd.addNumericField("Shrink SfM area", this.sfm_shrink, 0,3,"",
"Shrink sfm gain area before applying sfm_fade_sigmas.");
gd.addNumericField("Fade SfM area sigma", this.sfm_fade_sigma, 5,8,"",
......@@ -1150,6 +1153,7 @@ public class IntersceneMatchParameters {
this.sfp_tolerance = gd.getNextNumber();
this.sfm_readjust = (int) gd.getNextNumber();
this.sfm_prev_frac = gd.getNextNumber();
this.sfm_same_weight = gd.getNextNumber();
this.sfm_shrink = (int) gd.getNextNumber();
this.sfm_fade_sigma = gd.getNextNumber();
this.sfm_min_str = gd.getNextNumber();
......@@ -1515,7 +1519,8 @@ public class IntersceneMatchParameters {
properties.setProperty(prefix+"sfp_tolerance", this.sfp_tolerance+""); // double
properties.setProperty(prefix+"sfm_readjust", this.sfm_readjust+""); // int
properties.setProperty(prefix+"sfm_prev_frac", this.sfm_prev_frac+""); // double
properties.setProperty(prefix+"sfm_shrink", this.sfm_shrink+""); // int
properties.setProperty(prefix+"sfm_same_weight", this.sfm_same_weight+""); // double
properties.setProperty(prefix+"sfm_shrink", this.sfm_shrink+""); // int
properties.setProperty(prefix+"sfm_fade_sigma", this.sfm_fade_sigma+""); // double
properties.setProperty(prefix+"sfm_min_str", this.sfm_min_str+""); // double
properties.setProperty(prefix+"sfm_use_neibs", this.sfm_use_neibs+""); // boolean
......@@ -1840,6 +1845,7 @@ public class IntersceneMatchParameters {
if (properties.getProperty(prefix+"sfp_tolerance")!=null) this.sfp_tolerance=Double.parseDouble(properties.getProperty(prefix+"sfp_tolerance"));
if (properties.getProperty(prefix+"sfm_readjust")!=null) this.sfm_readjust=Integer.parseInt(properties.getProperty(prefix+"sfm_readjust"));
if (properties.getProperty(prefix+"sfm_prev_frac")!=null) this.sfm_prev_frac=Double.parseDouble(properties.getProperty(prefix+"sfm_prev_frac"));
if (properties.getProperty(prefix+"sfm_same_weight")!=null) this.sfm_same_weight=Double.parseDouble(properties.getProperty(prefix+"sfm_same_weight"));
if (properties.getProperty(prefix+"sfm_shrink")!=null) this.sfm_shrink=Integer.parseInt(properties.getProperty(prefix+"sfm_shrink"));
if (properties.getProperty(prefix+"sfm_fade_sigma")!=null) this.sfm_fade_sigma=Double.parseDouble(properties.getProperty(prefix+"sfm_fade_sigma"));
if (properties.getProperty(prefix+"sfm_min_str")!=null) this.sfm_min_str=Double.parseDouble(properties.getProperty(prefix+"sfm_min_str"));
......@@ -2192,6 +2198,7 @@ public class IntersceneMatchParameters {
imp.sfp_tolerance = this.sfp_tolerance;
imp.sfm_readjust = this.sfm_readjust;
imp.sfm_prev_frac = this.sfm_prev_frac;
imp.sfm_same_weight = this.sfm_same_weight;
imp.sfm_shrink = this.sfm_shrink;
imp.sfm_fade_sigma = this.sfm_fade_sigma;
imp.sfm_min_str = this.sfm_min_str;
......
......@@ -14868,7 +14868,12 @@ public class QuadCLTCPU {
if (clt_parameters.z_corr_map.containsKey(image_name)){ // not used in lwir
z_correction +=clt_parameters.z_corr_map.get(image_name);
}
final double disparity_corr = (z_correction == 0) ? 0.00 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
// currently it was 0.
if (z_correction != 0) {
System.out.println("CLTMeas(): z_correction="+z_correction+" != 0! ***********");
}
final double disparity_corr = (z_correction == 0) ? clt_parameters.imp.disparity_corr : geometryCorrection.getDisparityFromZ(1.0/z_correction);
int mcorr_sel = save_corr ? Correlation2d.corrSelEncode(clt_parameters.img_dtt, getNumSensors()) : 0;
TpTask[] tp_tasks = GpuQuad.setTasks( // null on geometryCorrection
num_sensors, // final int num_cams,
......
......@@ -515,6 +515,7 @@ public class StructureFromMotion {
final boolean use_neibs = clt_parameters.imp.sfm_use_neibs; // true;
final double min_neib_strength= clt_parameters.imp.sfm_neib_str; // 0.5; // update if no-individual and neibs correction strength exceeds
final double prev_sfm_frac = clt_parameters.imp.sfm_prev_frac; // 0.6; // update if new sfm gain > this fraction of the old one
final double same_weight = clt_parameters.imp.sfm_same_weight; // 0.8;
final double range_disparity_offset = clt_parameters.imp.range_disparity_offset;
final double centroid_radius = clt_parameters.imp.centroid_radius; // final double centroid_radius, // 0 - use all tile, >0 - cosine window around local max
final int n_recenter = clt_parameters.imp.n_recenter; // when cosine window, re-center window this many times
......@@ -673,11 +674,32 @@ public class StructureFromMotion {
// combine corrections
final Thread[] threads = ImageDtt.newThreadArray(QuadCLT.THREADS_MAX);
final AtomicInteger ai = new AtomicInteger(0);
final double wscale = -0.5/Math.log(prev_sfm_frac);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nTile = ai.getAndIncrement(); nTile < sfmCorr.length; nTile = ai.getAndIncrement())
if (sfmCorr[nTile] != null){
if (sfmCorr[nTile].sfm_gain >= prev_sfm_frac*ref_sfm_gain[nTile]){
double w = 1.0;
if (ref_sfm_gain[nTile] > 0) {
w = same_weight + wscale*Math.log(sfmCorr[nTile].sfm_gain/ref_sfm_gain[nTile]);
}
if (w < 0.0) w = 0;
else if (w > 1.0) w = 1.0;
// Update some strength too?
if ((sfmCorr[nTile].corr_ind != null) && (sfmCorr[nTile].corr_ind[1] > min_strength)) {
ref_disparity[nTile] += w *sfmCorr[nTile].corr_ind[0];
// TODO: add same (as above) for strengths?
ref_sfm_gain[nTile] = (1-w) *ref_sfm_gain[nTile] + w * sfmCorr[nTile].sfm_gain;
} else if ((sfmCorr[nTile].corr_neib != null) && (sfmCorr[nTile].corr_neib[1] > min_neib_strength)) {
ref_disparity[nTile] += w *sfmCorr[nTile].corr_neib[0];
// TODO: add same (as above) for strengths?
ref_sfm_gain[nTile] = (1-w) *ref_sfm_gain[nTile] + w * sfmCorr[nTile].sfm_gain;
}
}
/*
if (sfmCorr[nTile].sfm_gain >= prev_sfm_frac*ref_sfm_gain[nTile]){
if (prev_sfm_frac*sfmCorr[nTile].sfm_gain >= ref_sfm_gain[nTile]){ // copy 100%
// Update some strength too?
......@@ -691,6 +713,7 @@ public class StructureFromMotion {
}
}
*/
}
}
};
......@@ -749,6 +772,7 @@ public class StructureFromMotion {
final boolean use_neibs = clt_parameters.imp.sfm_use_neibs; // true;
final double min_neib_strength= clt_parameters.imp.sfm_neib_str; // 0.5; // update if no-individual and neibs correction strength exceeds
final double prev_sfm_frac = clt_parameters.imp.sfm_prev_frac; // 0.6; // update if new sfm gain > this fraction of the old one
final double same_weight = clt_parameters.imp.sfm_same_weight; // 0.8;
final double range_disparity_offset = clt_parameters.imp.range_disparity_offset;
final double centroid_radius = clt_parameters.imp.centroid_radius; // final double centroid_radius, // 0 - use all tile, >0 - cosine window around local max
final int n_recenter = clt_parameters.imp.n_recenter; // when cosine window, re-center window this many times
......@@ -978,7 +1002,7 @@ public class StructureFromMotion {
if (sfmCorrCombo[nTile].sfm_gain >= prev_sfm_frac*ref_sfm_gain[nTile]){
double w = 1.0;
if (ref_sfm_gain[nTile] > 0) {
w = 0.5 + wscale*Math.log(sfmCorrCombo[nTile].sfm_gain/ref_sfm_gain[nTile]);
w = same_weight + wscale*Math.log(sfmCorrCombo[nTile].sfm_gain/ref_sfm_gain[nTile]);
}
if (w < 0.0) w = 0;
else if (w > 1.0) w = 1.0;
......
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