Commit 413cd545 authored by Andrey Filippov's avatar Andrey Filippov

continue with eigen

parent c8d3d7d9
......@@ -2348,14 +2348,17 @@ public class ImageDtt extends ImageDttCPU {
final double td_weight, // mix correlations accumulated in TD with
final double td_neib_weight, // mix correlations accumulated in TD (neibs)
final double pd_weight, // correlations (post) accumulated in PD
final boolean td_nopd_only, // only use TD accumulated data if no safe PD is available for the tile.
final boolean eig_use_neibs, // use correlation from 9 tiles with neibs, if single-tile fails
final int eig_min_weaks, // = 4; minimal weak neighbors for a weak tile (too few - no averaging)
final int eig_min_strongs, // minimal strong neighbors for strong tiles
final double eig_disp_diff, // maximal disparity difference from the closest (by disparity) neighbor
final boolean eig_remove_neibs, //remove weak (by-neibs) tiles if they have strong (by-single) neighbor
final boolean eig_filt_other, // apply other before-eigen filters
// final double min_str_nofpn, // = 0.25;
final double eig_str_sum_nofpn,// = 0.8; // 5;
final double eig_str_neib_nofpn,// = 0.8; // 5;
// final double min_str_fpn, // = 0.25;
final double eig_str_sum_fpn, // = 0.8; // 5;
final double eig_str_neib_fpn, // = 0.8; // 5;
final int min_neibs, // 2; // minimal number of strong neighbors (> min_str)
......@@ -2365,7 +2368,7 @@ public class ImageDtt extends ImageDttCPU {
final boolean neibs_nofpn_only, // consolidate neighbors for non-fpn tiles only!
final boolean redo_both, // use average of neighbors for both pd,td if any of the center tile tests (td, pd) fails
final int min_num_neibs, // plus center, total number >= (min_num_neibs+1)
final double scale_neibs_pd, // scale threshold for the pixel-domain average maximums
final double scale_neibs_td, // scale threshold for the transform-domain average maximums
final double scale_avg_weight, // reduce influence of the averaged correlations compared to the single-tile ones
......@@ -2379,7 +2382,6 @@ public class ImageDtt extends ImageDttCPU {
final int threadsMax, // maximal number of threads to launch
final int globalDebugLevel)
{
// final boolean
// final boolean eigen_sub_min = false; // when calculating eigenvectors, subtract min from data, false - just skip
if (this.gpuQuad == null) {
System.out.println("clt_process_tl_interscene(): this.gpuQuad is null, bailing out");
......@@ -2497,6 +2499,7 @@ public class ImageDtt extends ImageDttCPU {
final Thread[] threads = newThreadArray(threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
final boolean [] used_td = new boolean [tilesX*tilesY]; // this tile had strong enough TD w/o neibs
final boolean [] weak_tile = new boolean [tilesX*tilesY]; // this is a weak tile (only through consolidating neighbors)
// all neibs with strong TD around them will be removed
// not using PD at all? always TD, then neibs?
for (int ithread = 0; ithread < threads.length; ithread++) {
......@@ -2537,10 +2540,7 @@ public class ImageDtt extends ImageDttCPU {
is_fpn = true;
}
// double [][] corrs = new double [corrs_len + extra_len + extra_len_eig][]; // 1/17/2/18 +(0/1)
double [][] corrs = new double [corrs_len + extra_len][]; // 1/17/2/18 +(0/1)
// int eigen_indx = (extra_len_eig > 0) ? (corrs_len + extra_len + extra_len_eig -1):-1;
// int eigen_indx = (extra_len_eig > 0) ? (corrs_len + extra_len):-1;
// copy correlation tiles from the GPU's floating point arrays
double scale = 1.0/getNumSensors();
if (extra_sum) {
......@@ -2654,6 +2654,13 @@ public class ImageDtt extends ImageDttCPU {
false, // boolean ignore_border, // only if fpn_mask != null - ignore tile if maximum touches fpn_mask
debug_data, // double [][] debug_data, // null or double [1]
false); // boolean debug)
weak_tile[nTile] = stats_mv != null;
if (stats_mv != null) {
stats_mv[2] -= eig_str_neib * scale_neibs_td;
if (stats_mv[2] <= 0) {
stats_mv = null;
}
}
}
if ((debug_data != null) && (debug_data[0] != null)) {
iCorrTile_index[nTile] = iCorrTile;
......@@ -2698,10 +2705,34 @@ public class ImageDtt extends ImageDttCPU {
public void run() {
TileNeibs tn = new TileNeibs(tilesX,tilesY);
for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) {
if ((mv[nTile] != null) && !used_td[nTile]) { // is weak (by neibs)
boolean remove_tile = false;
if (weak_tile[nTile]){
int num_weak = 0;
boolean has_strong = false;
for (int dir = 0; dir < TileNeibs.DIRS; dir++) {
int nTile1 = tn.getNeibIndex(nTile, dir);
if (nTile1 >= 0) {
if (used_td[nTile1]) {
has_strong = true;
break;
} else if (weak_tile[nTile1]) {
num_weak++;
}
}
}
remove_tile |= (has_strong || (num_weak < eig_min_weaks));
} else if (used_td[nTile]) {
int num_strong = 0;
for (int dir = 0; dir < TileNeibs.DIRS; dir++) {
int nTile1 = tn.getNeibIndex(nTile, dir);
if ((nTile1 >= 0) && used_td[nTile1]) {
if ((nTile1 >= 0) && (used_td[nTile1])) {
num_strong++;
}
}
remove_tile |= (num_strong < eig_min_strongs);
}
if (remove_tile) { // any of 3 reasons above
mv[nTile] = null;
if (pxd != null) {
pxd[nTile] = null;
......@@ -2711,16 +2742,58 @@ public class ImageDtt extends ImageDttCPU {
dcorr_tiles[iCorrTile][eigen_indx+1] = null;
dcorr_tiles[iCorrTile][eigen_indx+3] = null;
}
break;
}
}
}
};
}
startAndJoin(threads);
if (eig_disp_diff > 0) {
final boolean [] remove_tiles = new boolean[tilesX*tilesY];
ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
public void run() {
TileNeibs tn = new TileNeibs(tilesX,tilesY);
for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) if ((mv[nTile] != null) && (pXpYD[nTile] != null)) {
double min_diff = eig_disp_diff + 1.0;
double disp_c = pxd[nTile][2];
for (int dir = 0; dir < TileNeibs.DIRS; dir++) {
int nTile1 = tn.getNeibIndex(nTile, dir);
if ((nTile1 >= 0) && (pxd[nTile1]!= null) && !Double.isNaN(pxd[nTile1][2])) {
min_diff = Math.min(Math.abs(pxd[nTile1][2]-disp_c), min_diff);
}
}
remove_tiles[nTile] |= (min_diff > eig_disp_diff);
}
}
};
}
startAndJoin(threads);
ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
public void run() {
for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) if (remove_tiles[nTile]) {
mv[nTile] = null;
if (pxd != null) {
pxd[nTile] = null;
}
if (iCorrTile_index != null) {
int iCorrTile = iCorrTile_index[nTile];
dcorr_tiles[iCorrTile][eigen_indx+1] = null;
dcorr_tiles[iCorrTile][eigen_indx+3] = null;
}
}
}
};
}
startAndJoin(threads);
}
}
// Reduce weight if differs much from average of 8 neighbors, large disparity, remove too few neibs
final double scale_num_neib = ((weight_zero_neibs >= 0) && (weight_zero_neibs < 1.0)) ? (weight_zero_neibs * 8/(1.0 - weight_zero_neibs)): 0.0;
if (eig_filt_other) {
......@@ -2792,6 +2865,8 @@ public class ImageDtt extends ImageDttCPU {
startAndJoin(threads);
return coord_motion;
}
// using most of the ImageDttCPU.clt_process_tl_correlations
public void clt_process_tl_correlations( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
......
......@@ -534,7 +534,7 @@ public class Interscene {
boolean use_lma_dsi = clt_parameters.imp.use_lma_dsi;
double [] reduced_strength = new double[1];
double avg_z = quadCLTs[ref_index].getAverageZ(true); // use lma
double [] lma_rms = new double[clt_parameters.imp.eig_use? 4 : 2]; // [2];
double [] lma_rms = new double[clt_parameters.imp.eig_use? 6 : 4]; // [2];
// use combo if second pass?
if (min_ref_str > 0.0) {
reliable_ref = quadCLTs[ref_index].getReliableTiles( // will be null if does not exist.
......@@ -683,20 +683,20 @@ public class Interscene {
);
rmse_stats.add(lma_rms[0]);
if ((rmse_stats_metric != null) && (lma_rms.length >=4)) {
rmse_stats_metric.add(lma_rms[2]);
rmse_stats_metric.add(lma_rms[4]);
}
if (debugLevel > -3) {
System.out.print("invertInitialOrientation(): scene "+scene_index+" (of "+ quadCLTs.length+") "+
System.out.println("invertInitialOrientation(): scene "+scene_index+" (of "+ quadCLTs.length+") "+
quadCLTs[ref_index].getImageName() + "/" + quadCLTs[scene_index].getImageName()+
" Done. RMS="+lma_rms[0]+
" Done. Weight = "+lma_rms[2]+", number="+lma_rms[3]);
System.out.print("RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
if ((rmse_stats_metric != null) && (lma_rms.length >=4)) {
System.out.print(". RMS="+lma_rms[2]+
if ((rmse_stats_metric != null) && (lma_rms.length >=6)) {
System.out.print(". Pixel RMS="+lma_rms[4]+
"pix, maximal so far was "+rmse_stats_metric.getMax()+
"pix, average was "+rmse_stats_metric.getAverage()+"pix.");
}
System.out.println();
}
} // for (int scene_index = ref_index; scene_index <= last_index; scene_index++) {
......@@ -783,15 +783,16 @@ public class Interscene {
adjusted_xyzatr_dt[1]); // ZERO3 // ers_scene.getErsATR_dt()
rmse_stats.add(lma_rms[0]);
if ((rmse_stats_metric != null) && (lma_rms.length >=4)) {
rmse_stats_metric.add(lma_rms[2]);
rmse_stats_metric.add(lma_rms[4]);
}
if (debugLevel > -3) {
System.out.print("Pass multi scene "+fpn_pairs[ipair][0]+" (of "+ quadCLTs.length+") "+
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]+
" Done. Weight = "+lma_rms[2]+", number="+lma_rms[3]);
System.out.print("RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
if ((rmse_stats_metric != null) && (lma_rms.length >=4)) {
System.out.print(". RMS="+lma_rms[2]+
if ((rmse_stats_metric != null) && (lma_rms.length >=6)) {
System.out.print(". RMS="+lma_rms[4]+
"pix, maximal so far was "+rmse_stats_metric.getMax()+
"pix, average was "+rmse_stats_metric.getAverage()+"pix.");
}
......@@ -866,7 +867,7 @@ public class Interscene {
System.out.println("*** setInitialOrientationsIms(): clt_parameters.ilp.ilma_3d is TRUE. You may want to disable it when using IMS");
}
double [] lma_rms = new double[clt_parameters.imp.eig_use? 4 : 2]; // [2];
double [] lma_rms = new double[clt_parameters.imp.eig_use? 6 : 4]; // [2];
int tilesX = quadCLTs[ref_index].getTileProcessor().getTilesX();
int tilesY = quadCLTs[ref_index].getTileProcessor().getTilesY();
......@@ -1111,7 +1112,7 @@ public class Interscene {
ref_index, // int nscene0, // may be == ref_index
scene_index, // int nscene1, // compares to nscene0
null, // double [] ref_disparity, // null or alternative reference disparity
reliable_ref, //boolean [] reliable_ref, // null or bitmask of reliable reference tiles
reliable_ref, // boolean [] reliable_ref, // null or bitmask of reliable reference tiles
scenes_xyzatr[ref_index], // double [][] scene0_xyzatr,,
initial_pose, // double [][] scene1_xyzatr,
Double.NaN, // double average_z,
......@@ -1202,15 +1203,16 @@ public class Interscene {
);
rmse_stats.add(lma_rms[0]);
if ((rmse_stats_metric != null) && (lma_rms.length >=4)) {
rmse_stats_metric.add(lma_rms[2]);
rmse_stats_metric.add(lma_rms[4]);
}
if (debugLevel > -3) {
System.out.print("Pass multi scene "+scene_index+" (of "+ quadCLTs.length+") "+
System.out.println("Pass multi scene "+scene_index+" (of "+ quadCLTs.length+") "+
quadCLTs[ref_index].getImageName() + "/" + scene_QuadClt.getImageName()+
" Done. RMS="+lma_rms[0]+
" Done. Weight = "+lma_rms[2]+", number="+lma_rms[3]);
System.out.print("RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
if ((rmse_stats_metric != null) && (lma_rms.length >=4)) {
System.out.print(". RMS="+lma_rms[2]+
if ((rmse_stats_metric != null) && (lma_rms.length >=6)) {
System.out.print(". Pixel RMS="+lma_rms[4]+
"pix, maximal so far was "+rmse_stats_metric.getMax()+
"pix, average was "+rmse_stats_metric.getAverage()+"pix.");
}
......@@ -1310,15 +1312,16 @@ public class Interscene {
adjusted_xyzatr_dt[1]); // ZERO3 // ers_scene.getErsATR_dt()
rmse_stats.add(lma_rms[0]);
if ((rmse_stats_metric != null) && (lma_rms.length >=4)) {
rmse_stats_metric.add(lma_rms[2]);
rmse_stats_metric.add(lma_rms[4]);
}
if (debugLevel > -3) {
System.out.print("Pass multi scene "+fpn_pairs[ipair][0]+" (of "+ quadCLTs.length+") "+
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]+
" Done. Weight = "+lma_rms[2]+", number="+lma_rms[3]);
System.out.print("RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
if ((rmse_stats_metric != null) && (lma_rms.length >=4)) {
System.out.print(". RMS="+lma_rms[2]+
if ((rmse_stats_metric != null) && (lma_rms.length >=6)) {
System.out.print(". Pixel RMS="+lma_rms[4]+
"pix, maximal so far was "+rmse_stats_metric.getMax()+
"pix, average was "+rmse_stats_metric.getAverage()+"pix.");
}
......@@ -1827,15 +1830,16 @@ public class Interscene {
);
rmse_stats.add(lma_rms[0]);
if ((rmse_stats_metric != null) && (lma_rms.length >=4)) {
rmse_stats_metric.add(lma_rms[2]);
rmse_stats_metric.add(lma_rms[4]);
}
if (debugLevel > -3) {
System.out.print("Pass multi scene "+scene_index+" (of "+ quadCLTs.length+") "+
System.out.println("Pass multi scene "+scene_index+" (of "+ quadCLTs.length+") "+
quadCLTs[ref_index].getImageName() + "/" + scene_QuadClt.getImageName()+
" Done. RMS="+lma_rms[0]+
" Done. Weight = "+lma_rms[2]+", number="+lma_rms[3]);
System.out.print("RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
if ((rmse_stats_metric != null) && (lma_rms.length >=4)) {
System.out.print(". RMS="+lma_rms[2]+
if ((rmse_stats_metric != null) && (lma_rms.length >=6)) {
System.out.print(". Pixel RMS="+lma_rms[4]+
"pix, maximal so far was "+rmse_stats_metric.getMax()+
"pix, average was "+rmse_stats_metric.getAverage()+"pix.");
}
......@@ -2362,7 +2366,7 @@ public class Interscene {
boolean test_adjust = debugLevel > 1000;
while (test_adjust) {
int [] test_pair = {ref_index, 0};
double [] test_lma_rms = new double[clt_parameters.imp.eig_use? 4 : 2]; // [2];
double [] test_lma_rms = new double[clt_parameters.imp.eig_use? 6 : 4]; // [2];
TpTask[][] tp_tasks_test_rel_ref = new TpTask[2][];
double [][] test_xyzatr = adjustDiffPairsLMAInterscene( // compare two scenes, first may be reference, use motion blur
clt_parameters, //CLTParameters clt_parameters,
......@@ -2468,7 +2472,7 @@ public class Interscene {
dxyzatr_dt[nscene]
);
} else { // if (nscene == ref_index)
double [] lma_rms = new double[clt_parameters.imp.eig_use? 4 : 2]; // [2];
double [] lma_rms = new double[clt_parameters.imp.eig_use? 6 : 4]; // [2];
double [][] initial_pose = scenes_xyzatr[nscene].clone();
boolean adjust_OK = false;
if (est_shift < min_max[0]) {
......@@ -2605,15 +2609,16 @@ public class Interscene {
rmse_stats.add(lma_rms[0]);
if ((rmse_stats_metric != null) && (lma_rms.length >=4)) {
rmse_stats_metric.add(lma_rms[2]);
rmse_stats_metric.add(lma_rms[4]);
}
if (debugLevel > -3) {
System.out.print("reAdjustPairsLMAInterscene "+nscene+" (of "+ quadCLTs.length+") "+
System.out.println("reAdjustPairsLMAInterscene "+nscene+" (of "+ quadCLTs.length+") "+
quadCLTs[ref_index].getImageName() + "/" + ts+
" Done. RMS="+lma_rms[0]+
" Done. Weight = "+lma_rms[2]+", number="+lma_rms[3]);
System.out.print("RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
if ((rmse_stats_metric != null) && (lma_rms.length >=4)) {
System.out.print(". RMS="+lma_rms[2]+
if ((rmse_stats_metric != null) && (lma_rms.length >=6)) {
System.out.print(". Pixel RMS="+lma_rms[4]+
"pix, maximal so far was "+rmse_stats_metric.getMax()+
"pix, average was "+rmse_stats_metric.getAverage()+"pix.");
}
......@@ -2674,7 +2679,7 @@ public class Interscene {
" being too close to reference "+ref_index+
", using scene "+fpn_pairs[ipair][1]+" as a reference");
}
double [] lma_rms = new double[clt_parameters.imp.eig_use? 4 : 2]; // [2];
double [] lma_rms = new double[clt_parameters.imp.eig_use? 6 : 4]; // [2];
TpTask[][] tp_tasks_rel_ref = new TpTask[2][];
double [][] rel_xyzatr = adjustDiffPairsLMAInterscene( // compare two scenes, first may be reference, use motion blur
clt_parameters, //CLTParameters clt_parameters,
......@@ -2726,15 +2731,16 @@ public class Interscene {
adjusted_xyzatr_dt[1]);
rmse_stats.add(lma_rms[0]);
if ((rmse_stats_metric != null) && (lma_rms.length >=4)) {
rmse_stats_metric.add(lma_rms[2]);
rmse_stats_metric.add(lma_rms[4]);
}
if (debugLevel > -3) {
System.out.print("reAdjustPairsLMAInterscene "+fpn_pairs[ipair][0]+" (of "+ quadCLTs.length+") "+
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]+
" Done. Weight = "+lma_rms[2]+", number="+lma_rms[3]);
System.out.print("RMS="+lma_rms[0]+
", maximal so far was "+rmse_stats.getMax()+", average was "+rmse_stats.getAverage());
if ((rmse_stats_metric != null) && (lma_rms.length >=4)) {
System.out.print(". RMS="+lma_rms[2]+
if ((rmse_stats_metric != null) && (lma_rms.length >=6)) {
System.out.print(". Pixel RMS="+lma_rms[4]+
"pix, maximal so far was "+rmse_stats_metric.getMax()+
"pix, average was "+rmse_stats_metric.getAverage()+"pix.");
}
......@@ -2748,7 +2754,7 @@ public class Interscene {
if (test_adjust1) {
int [] test_pair = {0, ref_index};
while (test_adjust1) {
double [] test_lma_rms = new double[clt_parameters.imp.eig_use? 4 : 2]; // [2];
double [] test_lma_rms = new double[clt_parameters.imp.eig_use? 6 : 4]; // [2];
TpTask[][] tp_tasks_test_rel_ref = new TpTask[2][];
System.out.println("test_adjust scene = "+test_pair[0]+", reference="+test_pair[1]);
double [][] test_xyzatr = adjustDiffPairsLMAInterscene( // compare two scenes, first may be reference, use motion blur
......@@ -3540,18 +3546,22 @@ public class Interscene {
if ((rms_out != null) && (intersceneLma.getLastRms() != null)) {
rms_out[0] = intersceneLma.getLastRms()[0];
rms_out[1] = intersceneLma.getLastRms()[1];
if (rms_out.length >=2) {
rms_out[2] = intersceneLma.getSumWeights();
rms_out[3] = intersceneLma.getNumDefined();
if (rms_out.length >=4) {
if (intersceneLma.isEigenNormalized()) {
double [] rms_metric = intersceneLma.calcRMS(true);
rms_out[2] = rms_metric[0];
rms_out[3] = rms_metric[1];
rms_out[4] = rms_metric[0];
rms_out[5] = rms_metric[1];
} else {
rms_out[2] = Double.NaN;
rms_out[3] = Double.NaN;
rms_out[4] = Double.NaN;
rms_out[5] = Double.NaN;
}
}
}
//if (lmaResult < 0) { last_rms[0]
}
if (max_rms > 0.0) {
......@@ -4308,7 +4318,6 @@ public class Interscene {
fpn_offsets, // final double [][] fpn_offsets, // null, or per-tile X,Y offset to be blanked
fpn_radius, // final double fpn_radius, // radius to be blanked around FPN offset center
fpn_ignore_border, // final boolean fpn_ignore_border, // only if fpn_mask != null - ignore tile if maximum touches fpn_mask
// motion_vectors, // final double [][][] motion_vectors, // [tilesY*tilesX][][] -> [][][num_sel_sensors+1][2]
clt_parameters.imp.run_poly, // final boolean run_poly, // polynomial max, if false - centroid
use_partial, // final boolean use_partial, // find motion vectors for individual pairs, false - for sum only
clt_parameters.imp.centroid_radius,// final double centroid_radius, // 0 - use all tile, >0 - cosine window around local max
......@@ -4318,12 +4327,13 @@ public class Interscene {
clt_parameters.imp.pd_weight, // final double pd_weight, // correlations (post) accumulated in PD
clt_parameters.imp.td_nopd_only, // final boolean td_nopd_only , // only use TD accumulated data if no safe PD is available for the tile.
clt_parameters.imp.eig_use_neibs, // final boolean eig_use_neibs, // use correlation from 9 tiles with neibs, if single-tile fails
clt_parameters.imp.eig_min_weaks, // final int eig_min_weaks, // = 4; minimal weak neighbors for a weak tile (too few - no averaging)
clt_parameters.imp.eig_min_strongs,// final int eig_min_strongs, // minimal strong neighbors for strong tiles
clt_parameters.imp.eig_disp_diff, // final double eig_disp_diff, // maximal disparity difference from the closest (by disparity) neighbor
clt_parameters.imp.eig_remove_neibs,//final boolean eig_remove_neibs, //remove weak (by-neibs) tiles if they have strong (by-single) neighbor
clt_parameters.imp.eig_filt_other, // final boolean eig_filt_other, // apply other before-eigen filters
// min_str, // final double min_str_nofpn, // = 0.25;
eig_str_sum, // final double eig_str_sum_nofpn, // = 0.8; // 5;
eig_str_neib, // final double eig_str_neib_nofpn,
// clt_parameters.imp.min_str_fpn, // final double min_str, // = 0.25;
clt_parameters.imp.eig_str_sum_fpn,// final double eig_str_sum_fpn, // = 0.8; // 5;
clt_parameters.imp.eig_str_neib_fpn,//final double eig_str_neib_fpn,
clt_parameters.imp.min_neibs, // final int min_neibs, // 2; // minimal number of strong neighbors (> min_str)
......@@ -4332,7 +4342,6 @@ public class Interscene {
clt_parameters.imp.half_avg_diff, // final double half_avg_diff, // 0.2; // when L2 of x,y difference from average of neibs - reduce twice
neibs_nofpn_only, // final boolean neibs_nofpn_only, // consolidate neighbors fot non-fpn tiles only!
redo_both, // final boolean redo_both, // use average of neighbors for both pd,td if any of the center tile tests (td, pd) fails
min_num_neibs, // final int min_num_neibs, // plus center, total number >= (min_num_neibs+1)
scale_neibs_pd, // final double scale_neibs_pd, // scale threshold for the pixel-domain average maximums
scale_neibs_td, // final double scale_neibs_td, // scale threshold for the transform-domain average maximums
scale_avg_weight, // final double scale_avg_weight, // reduce influence of the averaged correlations compared to the single-tile ones
......
......@@ -51,6 +51,8 @@ public class IntersceneLma {
private double [] last_ymfx = null;
private double [][] last_jt = null;
private double [] weights; // normalized so sum is 1.0 for all - samples and extra regularization
private double sum_weights = 0;
private int num_defined = 0;
private double pure_weight; // weight of samples only
private boolean [] par_mask = null;
private int [] par_indices = null;
......@@ -92,6 +94,14 @@ public class IntersceneLma {
return last_jt;
}
public double getSumWeights() {
return sum_weights;
}
public int getNumDefined() {
return num_defined;
}
public double[] getLastRms() {
return last_rms;
......@@ -830,6 +840,7 @@ public class IntersceneLma {
final Thread[] threads = ImageDtt.newThreadArray(QuadCLT.THREADS_MAX);
final AtomicInteger ai = new AtomicInteger(0);
final AtomicInteger ati = new AtomicInteger(0);
final AtomicInteger anum_defined = new AtomicInteger(0);
final double [] sw_arr = new double [threads.length];
double sum_weights;
final int num_types = (num_components > 2) ? 2 : 1;
......@@ -842,6 +853,8 @@ public class IntersceneLma {
if (Double.isNaN(w)) {
w = 0;
}
if (w > 0) {
anum_defined.getAndIncrement();
weights[num_components * iMTile] = w;
sw_arr[thread_num] += 2*w;
//disparity_weight
......@@ -856,6 +869,7 @@ public class IntersceneLma {
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
......@@ -863,6 +877,9 @@ public class IntersceneLma {
for (double w:sw_arr) {
sum_weights += w;
}
num_defined = anum_defined.get();
this.sum_weights = sum_weights;
if (sum_weights <= 1E-8) {
System.out.println("!!!!!! setSamplesWeights(): sum_weights=="+sum_weights+" <= 1E-8");
}
......
......@@ -64,8 +64,8 @@ public class IntersceneMatchParameters {
public boolean sfm_use = true; // use SfM to improve depth map
public double sfm_min_base = 2.0; // use SfM if baseline exceeds this
public double sfm_min_gain = 5.0; // Minimal SfM gain to apply SfM to the depth map
public double sfm_min_base = 0.6; // 2.0; // use SfM if baseline exceeds this
public double sfm_min_gain = 3.0; // 5.0; // Minimal SfM gain to apply SfM to the depth map
public double sfm_min_frac = 0.5; // Minimal fraction of defined tiles to have SfM correction
public int sfm_num_pairs = 32; // desired number of SfM pairs to average
......@@ -450,6 +450,9 @@ public class IntersceneMatchParameters {
public double eig_max_sqrt = 6.0; // for sqrt(lambda) - consider infinity (infinite linear feature, a line)
public double eig_min_sqrt = 1.0; // for sqrt(lambda) - limit minimal sqrt(lambda) - can be sharp for very small max
public boolean eig_use_neibs = true; // use correlation from 9 tiles with neibs, if single-tile fails
public int eig_min_weaks = 4; // Minimal number of weak neighbors to keep center weak tile
public int eig_min_strongs = 2; // Minimal number of strong neighbors for stron tiles
public double eig_disp_diff = 1.0; // maximal disparity difference from the closest (by disparity) neighbor
public boolean eig_remove_neibs = true; // remove weak (by-neibs) tiles if they have strong (by-single) neighbor
public boolean eig_filt_other = false; // apply other before-eigen filters
public double eig_max_rms = 2.0; // eigen-normalized maximal RMS to consider adjustment to be a failure
......@@ -473,7 +476,7 @@ min_str_neib_fpn 0.35
public double min_ref_frac = 0.2; // 0.22; if fraction number of reliable tiles is less than this, use best possible
// SfM-related filtering (remove tiles without SfM)
public boolean sfm_filter = true; // use SfM filtering if available
public double sfm_minmax = 10.0; // minimal value of the SfM gain maximum to consider available
public double sfm_minmax = 3.0; // 10.0 // minimal value of the SfM gain maximum to consider available
public double sfm_fracmax = 0.75; // minimal fraction of the SfM maximal gain
public double sfm_fracall = 0.3; // minimal relative area of the SfM-enabled tiles (do not apply filter if less)
......@@ -1359,8 +1362,15 @@ min_str_neib_fpn 0.35
"For sqrt(egenvalue)==radius - do not trust too sharp (caused by small spot over threshold).");
gd.addCheckbox ("Use neighbors if single fails", this.eig_use_neibs,
"Use correlation from 9 tiles with neibs, if single-tile fails");
gd.addCheckbox ("Remove weak by strong neighbors", this.eig_remove_neibs,
"Remove weak (by-neibs) tiles if they have strong (by-single) neighbor");
gd.addNumericField("Min weak neighbors", this.eig_min_weaks, 0,3,"",
"Minimal number of weak neighbors to keep center weak tile. Too few will not reduce noise by averaging");
gd.addNumericField("Min strong neighbors of strong tiles", this.eig_min_strongs, 0,3,"",
"Minimal number of strong (w/o averaging with neighbors) tiles.");
gd.addNumericField("Maximal disparity difference to neighbors",this.eig_disp_diff, 5,7,"pix",
"Maximal disparity difference from the closest (by disparity) neighbor.");
gd.addCheckbox ("Remove weak by strong and too few weak neighbors", this.eig_remove_neibs,
"Remove weak (by-neibs) tiles if they have strong (by-single) neighbor. Or if they have too few weak ones");
gd.addCheckbox ("Apply other filters", this.eig_filt_other,
"Apply other (before-eigen) filters");
gd.addNumericField("Maximal eigen-normalized RMS", this.eig_max_rms, 5,7,"",
......@@ -2052,6 +2062,10 @@ min_str_neib_fpn 0.35
this.eig_max_sqrt = gd.getNextNumber();
this.eig_min_sqrt = gd.getNextNumber();
this.eig_use_neibs = gd.getNextBoolean();
this.eig_min_weaks = (int) gd.getNextNumber();
this.eig_min_strongs = (int) gd.getNextNumber();
this.eig_disp_diff = gd.getNextNumber();
this.eig_remove_neibs = gd.getNextBoolean();
this.eig_filt_other = gd.getNextBoolean();
this.eig_max_rms = gd.getNextNumber();
......@@ -2608,6 +2622,10 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"eig_max_sqrt", this.eig_max_sqrt+""); // double
properties.setProperty(prefix+"eig_min_sqrt", this.eig_min_sqrt+""); // double
properties.setProperty(prefix+"eig_use_neibs", this.eig_use_neibs+""); // boolean
properties.setProperty(prefix+"eig_min_weaks", this.eig_min_weaks+""); // int
properties.setProperty(prefix+"eig_min_strongs", this.eig_min_strongs+""); // int
properties.setProperty(prefix+"eig_disp_diff", this.eig_disp_diff+""); // double
properties.setProperty(prefix+"eig_remove_neibs", this.eig_remove_neibs+""); // boolean
properties.setProperty(prefix+"eig_filt_other", this.eig_filt_other+""); // boolean
properties.setProperty(prefix+"eig_max_rms", this.eig_max_rms+""); // double
......@@ -3127,6 +3145,9 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"eig_max_sqrt")!=null) this.eig_max_sqrt=Double.parseDouble(properties.getProperty(prefix+"eig_max_sqrt"));
if (properties.getProperty(prefix+"eig_min_sqrt")!=null) this.eig_min_sqrt=Double.parseDouble(properties.getProperty(prefix+"eig_min_sqrt"));
if (properties.getProperty(prefix+"eig_use_neibs")!=null) this.eig_use_neibs=Boolean.parseBoolean(properties.getProperty(prefix+"eig_use_neibs"));
if (properties.getProperty(prefix+"eig_min_weaks")!=null) this.eig_min_weaks=Integer.parseInt(properties.getProperty(prefix+"eig_min_weaks"));
if (properties.getProperty(prefix+"eig_min_strongs")!=null) this.eig_min_strongs=Integer.parseInt(properties.getProperty(prefix+"eig_min_strongs"));
if (properties.getProperty(prefix+"eig_disp_diff")!=null) this.eig_disp_diff=Double.parseDouble(properties.getProperty(prefix+"eig_disp_diff"));
if (properties.getProperty(prefix+"eig_remove_neibs")!=null) this.eig_remove_neibs=Boolean.parseBoolean(properties.getProperty(prefix+"eig_remove_neibs"));
if (properties.getProperty(prefix+"eig_filt_other")!=null) this.eig_filt_other=Boolean.parseBoolean(properties.getProperty(prefix+"eig_filt_other"));
if (properties.getProperty(prefix+"eig_max_rms")!=null) this.eig_max_rms=Double.parseDouble(properties.getProperty(prefix+"eig_max_rms"));
......@@ -3654,6 +3675,11 @@ min_str_neib_fpn 0.35
imp.eig_max_sqrt = this.eig_max_sqrt;
imp.eig_min_sqrt = this.eig_min_sqrt;
imp.eig_use_neibs = this.eig_use_neibs;
imp.eig_min_weaks = this.eig_min_weaks;
imp.eig_min_strongs = this.eig_min_strongs;
imp.eig_disp_diff = this.eig_disp_diff;
imp.eig_remove_neibs = this.eig_remove_neibs;
imp.eig_filt_other = this.eig_filt_other;
imp.eig_max_rms = this.eig_max_rms;
......
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