Commit 0de865d9 authored by Andrey Filippov's avatar Andrey Filippov

Added average RMSE fro orientation

parent 7c17ebab
......@@ -436,6 +436,8 @@ public class Interscene {
return earliest_scene2;
}
public static int invertInitialOrientation(
final CLTParameters clt_parameters,
final boolean batch_mode,
......@@ -492,7 +494,7 @@ public class Interscene {
false, // boolean use_ERS_tilt);
false );// boolean use_ERS_roll);
double maximal_series_rms = 0.0;
RMSEStats rmse_stats = new RMSEStats();
double [][][] scenes_xyzatr = new double [last_index+1][][];
double [][][] dxyzatr_dt = new double [last_index+1][][];
for (int nscene = earliest_index; nscene <= ref_index; nscene++) {
......@@ -677,14 +679,12 @@ public class Interscene {
adjusted_xyzatr_dt[0], // ZERO3, // ers_scene.getErsXYZ_dt(),
adjusted_xyzatr_dt[1] // ZERO3 // ers_scene.getErsATR_dt()
);
if (lma_rms[0] > maximal_series_rms) {
maximal_series_rms = lma_rms[0];
}
rmse_stats.add(lma_rms[0]);
if (debugLevel > -3) {
System.out.println("invertInitialOrientation(): scene "+scene_index+" (of "+ quadCLTs.length+") "+
quadCLTs[ref_index].getImageName() + "/" + quadCLTs[scene_index].getImageName()+
" Done. RMS="+lma_rms[0]+", maximal so far was "+maximal_series_rms);
" Done. RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
}
} // for (int scene_index = ref_index; scene_index <= last_index; scene_index++) {
......@@ -712,15 +712,6 @@ public class Interscene {
return getFPNUnResolved(fpn_pairs);
}
// mitigating problem, that in the process of adjusting offset can fall below
// the minimum and coordinates will be NaN:
/*
Mitigating FPN for scene 361 being too close to reference 344, using scene 367 as a reference
interCorrPair(): avg_offs = 10.755562139763402 <= 256.0, sw = 4217.0 iter=3, RMS=0.5364197453455559 (Pure RMS=0.5364197453455559)
interCorrPair(): avg_offs = 7.795390182218127 < 8.0, sw = 4219.0
adjustPairsLMAInterscene() returned null
*/
double [] min_max_fpn = {0,min_max[1]};
for (int ipair = 0; ipair < fpn_pairs.length; ipair++) if (fpn_pairs[ipair][1] >= 0) {
if (debugLevel > -4) {
......@@ -777,13 +768,12 @@ public class Interscene {
scenes_xyzatr[fpn_pairs[ipair][0]][1],
adjusted_xyzatr_dt[0], // ZERO3, // ers_scene.getErsXYZ_dt(),
adjusted_xyzatr_dt[1]); // ZERO3 // ers_scene.getErsATR_dt()
if (lma_rms[0] > maximal_series_rms) {
maximal_series_rms = lma_rms[0];
}
rmse_stats.add(lma_rms[0]);
if (debugLevel > -3) {
System.out.println("Pass multi scene "+fpn_pairs[ipair][0]+" (of "+ quadCLTs.length+") "+
quadCLTs[fpn_pairs[ipair][1]].getImageName() + "/" + quadCLTs[fpn_pairs[ipair][0]].getImageName()+
" Done. RMS="+lma_rms[0]+", maximal so far was "+maximal_series_rms);
" Done. RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
}
}
}
......@@ -798,7 +788,8 @@ public class Interscene {
sb.append("ref_index= "+ref_index+"\n");
sb.append("last_index= "+last_index+"\n");
sb.append("old_ref_index= "+ref_old+"\n");
sb.append("Maximal RMSE= "+maximal_series_rms+"\n");
sb.append("Maximal RMSE= "+rmse_stats.getMax()+"\n");
sb.append("Average RMSE= "+rmse_stats.getAverage()+"\n");
sb.append("------------------------\n\n");
quadCLTs[ref_index].saveStringInModelDirectory(sb.toString(), QuadCLT.ORIENTATION_LOGS_SUFFIX); // String suffix)
}
......@@ -820,7 +811,7 @@ public class Interscene {
final int threadsMax, // int threadsMax,
final boolean updateStatus,
final int debugLevel) {
double maximal_series_rms = 0.0;
RMSEStats rmse_stats = new RMSEStats();
double min_ref_str = clt_parameters.imp.min_ref_str;
boolean ref_need_lma = clt_parameters.imp.ref_need_lma;
double min_ref_frac= clt_parameters.imp.min_ref_frac;
......@@ -1180,14 +1171,12 @@ public class Interscene {
adjusted_xyzatr_dt[0], // ZERO3, // ers_scene.getErsXYZ_dt(),
adjusted_xyzatr_dt[1] // ZERO3 // ers_scene.getErsATR_dt()
);
if (lma_rms[0] > maximal_series_rms) {
maximal_series_rms = lma_rms[0];
}
rmse_stats.add(lma_rms[0]);
if (debugLevel > -3) {
System.out.println("Pass multi scene "+scene_index+" (of "+ quadCLTs.length+") "+
quadCLTs[ref_index].getImageName() + "/" + scene_QuadClt.getImageName()+
" Done. RMS="+lma_rms[0]+", maximal so far was "+maximal_series_rms);
" Done. RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
}
......@@ -1283,13 +1272,12 @@ public class Interscene {
scenes_xyzatr[fpn_pairs[ipair][0]][1],
adjusted_xyzatr_dt[0], // ZERO3, // ers_scene.getErsXYZ_dt(),
adjusted_xyzatr_dt[1]); // ZERO3 // ers_scene.getErsATR_dt()
if (lma_rms[0] > maximal_series_rms) {
maximal_series_rms = lma_rms[0];
}
rmse_stats.add(lma_rms[0]);
if (debugLevel > -3) {
System.out.println("Pass multi scene "+fpn_pairs[ipair][0]+" (of "+ quadCLTs.length+") "+
quadCLTs[fpn_pairs[ipair][1]].getImageName() + "/" + quadCLTs[fpn_pairs[ipair][0]].getImageName()+
" Done. RMS="+lma_rms[0]+", maximal so far was "+maximal_series_rms);
" Done. RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
}
}
}
......@@ -1298,9 +1286,9 @@ public class Interscene {
if (earliest_scene > 0) {
System.out.println("setInitialOrientationsIms(): Not all scenes matched, earliest useful scene = "+earliest_scene+
" (total number of scenes = "+(ref_index - earliest_scene + 1)+
").Maximal RMSE was "+maximal_series_rms);
"). Maximal RMSE was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
} else if (debugLevel > -4) {
System.out.println("All multi scene passes are Done. Maximal RMSE was "+maximal_series_rms);
System.out.println("All multi scene passes are Done. Maximal RMSE was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
}
quadCLTs[ref_index].set_orient(1); // first orientation
quadCLTs[ref_index].set_accum(0); // reset accumulations ("build_interscene") number
......@@ -1315,7 +1303,8 @@ public class Interscene {
sb.append("getNumAccum()= "+quadCLTs[ref_index].getNumAccum()+ " of "+clt_parameters.imp.min_num_interscene+"\n");
sb.append("earliest_scene= "+earliest_scene+"\n");
sb.append("ref_index= "+ref_index+"\n");
sb.append("Maximal RMSE= "+maximal_series_rms+"\n");
sb.append("Maximal RMSE= "+rmse_stats.getMax()+"\n");
sb.append("Average RMSE= "+rmse_stats.getAverage()+"\n");
sb.append("------------------------\n\n");
quadCLTs[ref_index].saveStringInModelDirectory(sb.toString(), QuadCLT.ORIENTATION_LOGS_SUFFIX); // String suffix)
return earliest_scene;
......@@ -1455,7 +1444,7 @@ public class Interscene {
double scale_extrap_atr = clt_parameters.imp.scale_extrap_atr;
double scale_extrap_xyz = clt_parameters.imp.scale_extrap_xyz;
int avg_len = clt_parameters.imp.avg_len;
double maximal_series_rms = 0.0;
RMSEStats rmse_stats = new RMSEStats();
double min_ref_str = clt_parameters.imp.min_ref_str;
boolean ref_need_lma = clt_parameters.imp.ref_need_lma;
double min_ref_frac= clt_parameters.imp.min_ref_frac;
......@@ -1773,14 +1762,12 @@ public class Interscene {
ZERO3, // ers_scene.getErsXYZ_dt(),
ZERO3 // ers_scene.getErsATR_dt()
);
if (lma_rms[0] > maximal_series_rms) {
maximal_series_rms = lma_rms[0];
}
rmse_stats.add(lma_rms[0]);
if (debugLevel > -3) {
System.out.println("Pass multi scene "+scene_index+" (of "+ quadCLTs.length+") "+
quadCLTs[ref_index].getImageName() + "/" + scene_QuadClt.getImageName()+
" Done. RMS="+lma_rms[0]+", maximal so far was "+maximal_series_rms);
" Done. RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
}
} // for (int scene_index = ref_index - 1; scene_index >= 0 ; scene_index--)
if ((ref_index - earliest_scene + 1) < min_num_scenes) {
......@@ -1794,9 +1781,9 @@ public class Interscene {
if (earliest_scene > 0) {
System.out.println("setInitialOrientations(): Not all scenes matched, earliest useful scene = "+earliest_scene+
" (total number of scenes = "+(ref_index - earliest_scene + 1)+
").Maximal RMSE was "+maximal_series_rms);
").Maximal RMSE was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
} else if (debugLevel > -4) {
System.out.println("All multi scene passes are Done. Maximal RMSE was "+maximal_series_rms);
System.out.println("All multi scene passes are Done. Maximal RMSE was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
}
quadCLTs[ref_index].set_orient(1); // first orientation
quadCLTs[ref_index].set_accum(0); // reset accumulations ("build_interscene") number
......@@ -2094,7 +2081,7 @@ public class Interscene {
scenes_xyzatr[ref_index] = new double[2][3]; // all zeros
// should have at least next or previous non-null
int debug_scene = 69; // -68; // -8;
double maximal_series_rms = 0.0;
RMSEStats rmse_stats = new RMSEStats();
if (debug_ers) {
System.out.println("ERS velocities scale mode = '"+dbg_ers_string+"'");
}
......@@ -2532,14 +2519,12 @@ public class Interscene {
adjusted_xyzatr_dt[1]
);
if (lma_rms[0] > maximal_series_rms) {
maximal_series_rms = lma_rms[0];
}
rmse_stats.add(lma_rms[0]);
if (debugLevel > -3) {
System.out.println("reAdjustPairsLMAInterscene "+nscene+" (of "+ quadCLTs.length+") "+
quadCLTs[ref_index].getImageName() + "/" + ts+
" Done. RMS="+lma_rms[0]+", maximal so far was "+maximal_series_rms);
" Done. RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
}
} // if (nscene == ref_index) else
} // for (int nscene = ref_index; nscene > earliest_scene; nscene--) {
......@@ -2646,13 +2631,12 @@ public class Interscene {
scenes_xyzatr[fpn_pairs[ipair][0]][1],
adjusted_xyzatr_dt[0],
adjusted_xyzatr_dt[1]);
if (lma_rms[0] > maximal_series_rms) {
maximal_series_rms = lma_rms[0];
}
rmse_stats.add(lma_rms[0]);
if (debugLevel > -3) {
System.out.println("reAdjustPairsLMAInterscene "+fpn_pairs[ipair][0]+" (of "+ quadCLTs.length+") "+
quadCLTs[fpn_pairs[ipair][1]].getImageName() + "/" + quadCLTs[fpn_pairs[ipair][0]].getImageName()+
" Done. RMS="+lma_rms[0]+", maximal so far was "+maximal_series_rms);
" Done. RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
}
}
}
......@@ -2718,7 +2702,7 @@ public class Interscene {
}
if (debugLevel > -4) {
System.out.println("All multi scene passes are Done. Maximal RMSE was "+maximal_series_rms);
System.out.println("All multi scene passes are Done. Maximal RMSE was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
}
quadCLTs[ref_index].saveInterProperties( // save properties for interscene processing (extrinsics, ers, ...)
......@@ -2734,7 +2718,8 @@ public class Interscene {
sb.append("earliest_scene= "+range[0]+"\n");
sb.append("ref_index= "+ref_index+"\n");
sb.append("last_index= "+range[1]+"\n");
sb.append("Maximal RMSE= "+maximal_series_rms+"\n");
sb.append("Maximal RMSE= "+rmse_stats.getMax()+"\n");
sb.append("Average RMSE= "+rmse_stats.getAverage()+"\n");
sb.append("lpf_xy= "+lpf_xy+"\n");
sb.append("readjust_xy_ims="+readjust_xy_ims+"\n");
sb.append("lma_xyzatr= "+lma_xyzatr+"\n");
......
......@@ -7591,8 +7591,9 @@ public class OpticalFlow {
Arrays.fill(dbg_rms_pre, Double.NaN);
// process scenes before reference
int dbg_ref_index = 10; // wait for ref_index <= dbg_ref_index and print (manually update dbg_ref_index
double maximal_series_rms = 0.0;
double maximal_series_rms1 = 0.0;
RMSEStats rmse_stats = new RMSEStats();
RMSEStats rmse_stats1 = new RMSEStats();
if (ref_index > 1) {
for (int i = ref_index - 2; i >= 0 ; i--) {
QuadCLT scene_QuadClt = scenes[i];
......@@ -7672,9 +7673,7 @@ public class OpticalFlow {
}
}
}
if (lma_rms[0] > maximal_series_rms) {
maximal_series_rms = lma_rms[0];
}
rmse_stats.add(lma_rms[0]);
dbg_rms_pre[i] = lma_rms[0];
ers_reference.addScene(scene_QuadClt.getImageName(),
scenes_xyzatr[i][0],
......@@ -7691,8 +7690,8 @@ public class OpticalFlow {
if (debug_level > -1) {
System.out.println("Pass multi scene "+i+" (of "+ scenes.length+") "+
reference_QuadClt.getImageName() + "/" + scene_QuadClt.getImageName()+
" Done. RMS="+lma_rms[0]+", maximal so far was "+maximal_series_rms);
}
" Done. RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage()); }
if (delete_scene_asap) {
scenes[i+1] = null;
}
......@@ -7775,9 +7774,7 @@ public class OpticalFlow {
0.0, // double max_rms,
debug_level); // int debug_level)
}
if (lma_rms[0] > maximal_series_rms) {
maximal_series_rms = lma_rms[0];
}
rmse_stats.add(lma_rms[0]);
dbg_rms_pre[i] = lma_rms[0];
ers_reference.addScene(scene_QuadClt.getImageName(),
scenes_xyzatr[i][0],
......@@ -7794,7 +7791,8 @@ public class OpticalFlow {
if (debug_level > -1) {
System.out.println("Pass multi scene "+i+" (of "+ scenes.length+") "+
reference_QuadClt.getImageName() + "/" + scene_QuadClt.getImageName()+
" Done. RMS="+lma_rms[0]+", maximal so far was "+maximal_series_rms);
" Done. RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
}
if (delete_scene_asap) {
scenes[i-1] = null;
......@@ -7802,7 +7800,7 @@ public class OpticalFlow {
}
}
if (debug_level > -3) {
System.out.println("All multi scene passes are Done. Maximal RMSE was "+maximal_series_rms);
System.out.println("All multi scene passes are Done. Maximal RMSE was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
}
// boolean show_results = true;
......@@ -7922,9 +7920,7 @@ public class OpticalFlow {
0.0, // double max_rms,
debug_level); // int debug_level)
}
if (lma_rms[0] > maximal_series_rms1) {
maximal_series_rms1 = lma_rms[0];
}
rmse_stats1.add(lma_rms[0]);
dbg_rms[i] = lma_rms[0];
ers_reference.addScene(
scene_ts,
......@@ -7944,7 +7940,8 @@ public class OpticalFlow {
if (debug_level > -1) {
System.out.println("Pass 2 multi scene "+i+" (of "+ scenes.length+") "+
reference_QuadClt.getImageName() + "/" + scene_ts+
" Done. RMS="+lma_rms[0]+", maximal so far was "+maximal_series_rms);
" Done. RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
}
if (delete_scene_asap) {
scenes[i-1] = null;
......@@ -7965,7 +7962,7 @@ public class OpticalFlow {
rms_mean /= rms_num;
if (debug_level > -3) {
System.out.println("adjustSeries() rms_pre_mean="+rms_pre_mean+", rms_mean="+
rms_mean+", maximal RMSE="+maximal_series_rms1);
rms_mean+", maximal RMSE="+rmse_stats1.getMax()+", average was "+rmse_stats1.getAverage());
}
if (show_results) {
......@@ -8125,8 +8122,8 @@ public class OpticalFlow {
8); // int iscale) // 8
}
if (debug_level > -3) {
System.out.println("adjustSeries() Done. Maximal RMSE in pass1 was "+maximal_series_rms+
", in pass2 - "+maximal_series_rms1);
System.out.println("adjustSeries() Done. Maximal RMSE in pass1 was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage()+
", in pass2 - "+rmse_stats1.getMax()+", average was "+rmse_stats1.getAverage());
}
}
......
package com.elphel.imagej.tileprocessor;
public class RMSEStats {
public double max = 0;
public double sum2 = 0;
public int num = 0;
public void add(double rmse) {
sum2 += rmse*rmse;
num++;
max = Math.max(max, rmse);
}
public double getMax() {
return max;
}
public int getNum() {
return num;
}
public double getAverage() {
return Math.sqrt(sum2/num);
}
}
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