Commit 330ac1f3 authored by Andrey Filippov's avatar Andrey Filippov

Improved and tested initial DSI, fixed DSI filtering

parent ff4593c5
......@@ -1259,10 +1259,10 @@ public class CLTPass3d{
final double strength = disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX][nTile];
final double disparity = disparity_map[ImageDtt.DISPARITY_INDEX_CM][nTile]; // is it combined with LMA?
// double fom = strength - w_adisp * Math.abs(disparity) - w_cdiff * second_max;
double cdiff = (second_max == null) ? 0.0:second_max[nTile];
double fom = strength
- w_adisp * Math.abs(disparity)
- w_cdiff * second_max[nTile] *(min_strength/strength);
- w_cdiff * cdiff *(min_strength/strength);
if ((strength <= 0) || (strength <= min_strength) || Double.isNaN(fom)) {
......
......@@ -219,7 +219,7 @@ public class ImageDtt extends ImageDttCPU {
if (globalDebugLevel > 1){
System.out.println("ortho_height="+ imgdtt_params.ortho_height+" ortho_eff_height="+ imgdtt_params.ortho_eff_height);
for (int i = 0; i < corr_size; i++){
System.out.println(" ortho_weights["+i+"]="+ ortho_weights[i]);
System.out.println("a. ortho_weights["+i+"]="+ ortho_weights[i]);
}
}
......@@ -1528,7 +1528,7 @@ public class ImageDtt extends ImageDttCPU {
if (globalDebugLevel > 1){
System.out.println("ortho_height="+ imgdtt_params.ortho_height+" ortho_eff_height="+ imgdtt_params.ortho_eff_height);
for (int i = 0; i < corr_size; i++){
System.out.println(" ortho_weights["+i+"]="+ ortho_weights[i]);
System.out.println("b. ortho_weights["+i+"]="+ ortho_weights[i]);
}
}
......@@ -2195,7 +2195,7 @@ public class ImageDtt extends ImageDttCPU {
if (globalDebugLevel > 1){
System.out.println("ortho_height="+ imgdtt_params.ortho_height+" ortho_eff_height="+ imgdtt_params.ortho_eff_height);
for (int i = 0; i < corr_size; i++){
System.out.println(" ortho_weights["+i+"]="+ ortho_weights[i]);
System.out.println("c. ortho_weights["+i+"]="+ ortho_weights[i]);
}
}
......@@ -2951,7 +2951,7 @@ public class ImageDtt extends ImageDttCPU {
if (globalDebugLevel > 1){
System.out.println("ortho_height="+ imgdtt_params.ortho_height+" ortho_eff_height="+ imgdtt_params.ortho_eff_height);
for (int i = 0; i < corr_size; i++){
System.out.println(" ortho_weights["+i+"]="+ ortho_weights[i]);
System.out.println("d. ortho_weights["+i+"]="+ ortho_weights[i]);
}
}
......@@ -3626,7 +3626,7 @@ public class ImageDtt extends ImageDttCPU {
if (globalDebugLevel > 1){
System.out.println("ortho_height="+ imgdtt_params.ortho_height+" ortho_eff_height="+ imgdtt_params.ortho_eff_height);
for (int i = 0; i < corr_size; i++){
System.out.println(" ortho_weights["+i+"]="+ ortho_weights[i]);
System.out.println("e. ortho_weights["+i+"]="+ ortho_weights[i]);
}
}
......
......@@ -1829,7 +1829,7 @@ public class ImageDttCPU {
if (globalDebugLevel > 1){
System.out.println("ortho_height="+ imgdtt_params.ortho_height+" ortho_eff_height="+ imgdtt_params.ortho_eff_height);
for (int i = 0; i < corr_size; i++){
System.out.println(" ortho_weights["+i+"]="+ ortho_weights[i]);
System.out.println("f. ortho_weights["+i+"]="+ ortho_weights[i]);
}
}
......@@ -3624,7 +3624,7 @@ public class ImageDttCPU {
if (globalDebugLevel > 1){
System.out.println("ortho_height="+ imgdtt_params.ortho_height+" ortho_eff_height="+ imgdtt_params.ortho_eff_height);
for (int i = 0; i < corr_size; i++){
System.out.println(" ortho_weights["+i+"]="+ ortho_weights[i]);
System.out.println("g. ortho_weights["+i+"]="+ ortho_weights[i]);
}
}
......@@ -4602,7 +4602,7 @@ public class ImageDttCPU {
if (globalDebugLevel > 1){
System.out.println("ortho_height="+ imgdtt_params.ortho_height+" ortho_eff_height="+ imgdtt_params.ortho_eff_height);
for (int i = 0; i < corr_size; i++){
System.out.println(" ortho_weights["+i+"]="+ ortho_weights[i]);
System.out.println("h. ortho_weights["+i+"]="+ ortho_weights[i]);
}
}
......@@ -7878,7 +7878,7 @@ public class ImageDttCPU {
if (globalDebugLevel > 1){
System.out.println("ortho_height="+ imgdtt_params.ortho_height+" ortho_eff_height="+ imgdtt_params.ortho_eff_height);
for (int i = 0; i < corr_size; i++){
System.out.println(" ortho_weights["+i+"]="+ ortho_weights[i]);
System.out.println("i. ortho_weights["+i+"]="+ ortho_weights[i]);
}
}
......@@ -12732,7 +12732,7 @@ public class ImageDttCPU {
if (globalDebugLevel > 1){
System.out.println("ortho_height="+ clt_parameters.img_dtt.ortho_height+" ortho_eff_height="+ clt_parameters.img_dtt.ortho_eff_height);
for (int i = 0; i < corr_size; i++){
System.out.println(" ortho_weights["+i+"]="+ ortho_weights[i]);
System.out.println("j. ortho_weights["+i+"]="+ ortho_weights[i]);
}
}
......@@ -13669,7 +13669,7 @@ public class ImageDttCPU {
if (globalDebugLevel > 1){
System.out.println("ortho_height="+ clt_parameters.img_dtt.ortho_height+" ortho_eff_height="+ clt_parameters.img_dtt.ortho_eff_height);
for (int i = 0; i < corr_size; i++){
System.out.println(" ortho_weights["+i+"]="+ ortho_weights[i]);
System.out.println("k. ortho_weights["+i+"]="+ ortho_weights[i]);
}
}
......@@ -14386,7 +14386,7 @@ public class ImageDttCPU {
if (globalDebugLevel > 1){
System.out.println("ortho_height="+ clt_parameters.img_dtt.ortho_height+" ortho_eff_height="+ clt_parameters.img_dtt.ortho_eff_height);
for (int i = 0; i < corr_size; i++){
System.out.println(" ortho_weights["+i+"]="+ ortho_weights[i]);
System.out.println("l. ortho_weights["+i+"]="+ ortho_weights[i]);
}
}
......@@ -14798,7 +14798,7 @@ public class ImageDttCPU {
if (globalDebugLevel > 1){
System.out.println("ortho_height="+ imgdtt_params.ortho_height+" ortho_eff_height="+ imgdtt_params.ortho_eff_height);
for (int i = 0; i < corr_size; i++){
System.out.println(" ortho_weights["+i+"]="+ ortho_weights[i]);
System.out.println("m. ortho_weights["+i+"]="+ ortho_weights[i]);
}
}
......
......@@ -136,7 +136,7 @@ public class IntersceneMatchParameters {
public double min_disparity = -0.15; // 0.2;
public double max_sym_disparity = 0.1; // 0.2;
// 2 next are wrong currently - minimal strength is ~0.25
public double min_strength_lma = 0.3; // no real filtering
public double min_strength_lma = 0.0; // 0.3; // no real filtering
public double min_strength_replace = 0.05; /// 0.14; /// Before /// - LWIR, after - RGB
public double min_strength_blur = 0.06; /// 0.2;
public double sigma = 2; /// 5;
......
......@@ -4322,12 +4322,24 @@ public class OpticalFlow {
debugLevel-2);
} // split cycles to remove output clutter
int debug_scene = -15;
boolean debug2 = true;
boolean [] reliable_ref = null;
if (min_ref_str > 0.0) {
reliable_ref = quadCLTs[ref_index].getReliableTiles( // will be null if does not exist.
min_ref_str, // double min_strength,
true); // boolean needs_lma);
if (debug2) {
double [] dbg_img = new double [reliable_ref.length];
for (int i = 0; i < dbg_img.length; i++) {
dbg_img[i] = reliable_ref[i]?1:0;
}
(new ShowDoubleFloatArrays()).showArrays(
dbg_img,
quadCLTs[ref_index].getTileProcessor().getTilesX(),
quadCLTs[ref_index].getTileProcessor().getTilesY(),
"reliable_ref");
}
}
for (int scene_index = ref_index - 1; scene_index >= earliest_scene ; scene_index--) {
......@@ -11431,7 +11443,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
double max_change = 1.0e-3;
double min_disparity = -0.2;
double max_sym_disparity = 0.2;
double min_strength_lma = 0.7; // weaker - treat as non-lma
double min_strength_lma = 0.0; // 7; // weaker - treat as non-lma
double min_strength_replace = 0.05; /// 0.14; /// Before /// - LWIR, after - RGB
double min_strength_blur = 0.06; /// 0.2;
double sigma = 2; /// 5;
......@@ -11684,7 +11696,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
tilesX, // int width,
sigma); // double sigma);
dbg_img[10] = disp.clone();
double [][] ds = {disp, clean_lma};
double [][] ds = {disp, dls[2]};
final double [][] ds_filled = QuadCLT.fillDisparityStrength(
ds, // final double [][] ds0,
min_disparity, // final double min_disparity,
......
......@@ -8688,7 +8688,7 @@ public class QuadCLTCPU {
{
final boolean show_init_refine = clt_parameters.show_init_refine; // change to true?
boolean lwir2022 = true;
boolean debug2 = true;
boolean debug_graphic = false; // true;
boolean no_macro = isLwir(); // make it a separate configurable parameter?
// change debugLevel to 0
......@@ -8730,7 +8730,7 @@ public class QuadCLTCPU {
// if (show_init_refine)
// if ((debugLevel > -2) && clt_parameters.show_first_bg) {
if ((debugLevel > -3) && clt_parameters.show_first_bg) {
if ((debugLevel > -2) && clt_parameters.show_first_bg) {
tp.showScan(
tp.clt_3d_passes.get(0), // CLTPass3d scan,
"bgnd_data_lma-"+tp.clt_3d_passes.size());
......@@ -9035,37 +9035,49 @@ public class QuadCLTCPU {
updateStatus,
debugLevel);
if (debugLevel > -3){
if (debugLevel > -2){
System.out.println("CLTMeasCorr("+refine_pass+")-*");
}
if ((debugLevel > 0) && show_init_refine) tp.showScan( // remove by debug
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"after_measure-"+tp.clt_3d_passes.size());
if (nnn < (clt_parameters.gr_num_refines-1)) { // all but last, because after last the next fresh one will be used
CLTPass3d combo_pass = tp.compositeScan(
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
bg_pass, // final int firstPass,
tp.clt_3d_passes.size(), // final int lastPassPlus1,
// tp.clt_3d_passes.get(bg_pass).getSelected(), // selected , // final boolean [] bg_tiles, // get from selected in clt_3d_passes.get(0);
// clt_parameters.ex_min_over,// final double ex_min_over, // when expanding over previously detected (by error) background, disregard far tiles
tp.getTrustedCorrelation(), // final double trustedCorrelation,
tp.getMaxOverexposure(), // final double max_overexposure,
0.0, // clt_parameters.bgnd_range, // final double disp_far, // limit results to the disparity range
clt_parameters.grow_disp_max, // final double disp_near,
clt_parameters.combine_min_strength, // final double minStrength,
clt_parameters.combine_min_hor, // final double minStrengthHor,
clt_parameters.combine_min_vert, // final double minStrengthVert,
false, // final boolean no_weak,
false, // final boolean use_last, //
// TODO: when useCombo - pay attention to borders (disregard)
false, // final boolean usePoly) // use polynomial method to find max), valid if useCombo == false
true, // final boolean copyDebug)
debugLevel);
CLTPass3d combo_pass;
if (lwir2022) {
combo_pass = tp.compositeScan(
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
bg_pass, // final int firstPass,
tp.clt_3d_passes.size(), // final int lastPassPlus1,
fom_min_strength, // final double fom_min_strength,
false, // final boolean fom_use_lma,
fom_adisp, // final double fom_adisp, // 0.5
fom_cdiff, // final double fom_cdiff, // 0.02
fom_inf_bonus, // final double fom_inf_bonus, // 0.2; // add this to infinity FOM (if it is closer than fom_inf_range)
fom_inf_range, // final double fom_inf_range, // 0.5;
true, // final boolean copyDebug)
debugLevel);
} else {
combo_pass = tp.compositeScan(
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
bg_pass, // final int firstPass,
tp.clt_3d_passes.size(), // final int lastPassPlus1,
tp.getTrustedCorrelation(), // final double trustedCorrelation,
tp.getMaxOverexposure(), // final double max_overexposure,
0.0, // clt_parameters.bgnd_range, // final double disp_far, // limit results to the disparity range
clt_parameters.grow_disp_max, // final double disp_near,
clt_parameters.combine_min_strength, // final double minStrength,
clt_parameters.combine_min_hor, // final double minStrengthHor,
clt_parameters.combine_min_vert, // final double minStrengthVert,
false, // final boolean no_weak,
false, // final boolean use_last, //
// TODO: when useCombo - pay attention to borders (disregard)
false, // final boolean usePoly) // use polynomial method to find max), valid if useCombo == false
true, // final boolean copyDebug)
debugLevel);
}
if (show_init_refine && (debugLevel>0)) tp.showScan(
combo_pass, // CLTPass3d scan,
"after_compositeScan-"+tp.clt_3d_passes.size());
tp.clt_3d_passes.add(combo_pass);
}
......@@ -9083,7 +9095,7 @@ public class QuadCLTCPU {
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
if (show_init_refine) tp.showScan(
if (show_init_refine && (debugLevel >-2)) tp.showScan(
tp.clt_3d_passes.get(tp.clt_3d_passes.size() -1), // CLTPass3d scan,
"after_measure_macro-"+tp.clt_3d_passes.size());
if (debugLevel > -1){
......@@ -9102,7 +9114,7 @@ public class QuadCLTCPU {
int dbg_tileX = 58; // 42;
int dbg_tileY = 48; // 28;
boolean break_now = true;
while (!break_now && debug2) {
while (!break_now && debug_graphic) {
tp.printScans(
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
0, // bg_pass, // final int firstPass,
......@@ -9188,7 +9200,7 @@ public class QuadCLTCPU {
combo_pass, // CLTPass3d combo_pass,
debugLevel); // final int debugLevel);
tp.clt_3d_passes.add(refined0);
if (show_init_refine) tp.showScan(
if (show_init_refine && (debugLevel > -2)) tp.showScan(
tp.clt_3d_passes.get(tp.clt_3d_passes.size() -1), // last scan (combo)
"first_refined-"+tp.clt_3d_passes.size());
......@@ -9225,7 +9237,7 @@ public class QuadCLTCPU {
true, // final boolean copyDebug)
debugLevel);
tp.clt_3d_passes.add(combo_pass);
if (show_init_refine) {
if (show_init_refine && (debugLevel >-2)) {
tp.showScan(
tp.clt_3d_passes.get(tp.clt_3d_passes.size() - 1), // CLTPass3d scan,
"combo_after_first_lma-"+tp.clt_3d_passes.size());
......@@ -9269,7 +9281,7 @@ public class QuadCLTCPU {
/// if (debugLevel > 1)
if (debug2 && (debugLevel > -3)) { // && (debugLevel > 0)
if (debug_graphic && (debugLevel > -2)) { // && (debugLevel > 0)
tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"before_makeUnique-"+refine_pass);
......@@ -9289,7 +9301,7 @@ public class QuadCLTCPU {
if (debugLevel > -1){
System.out.println("cycle makeUnique("+refine_pass+") -> left: "+numLeftRemoved[0]+", removed:" + numLeftRemoved[1]);
}
if (debug2 && (debugLevel > -3)) { // (show_init_refine && (debugLevel >0)) {
if (debug_graphic && (debugLevel > -3)) { // (show_init_refine && (debugLevel >0)) {
tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"after_refinePassSetup-"+tp.clt_3d_passes.size());
......@@ -9363,7 +9375,7 @@ public class QuadCLTCPU {
}
tp.clt_3d_passes.add(combo_pass);
}
if (show_init_refine) {
if (show_init_refine && (debugLevel >-2)) {
tp.showScan(
tp.clt_3d_passes.get(tp.clt_3d_passes.size() - 1), // CLTPass3d scan,
"before multi-tile-"+tp.clt_3d_passes.size());
......@@ -9373,7 +9385,7 @@ public class QuadCLTCPU {
// CLTPass3d
combo_pass = tp.clt_3d_passes.get(tp.clt_3d_passes.size() - 1); // last pass created by tp.compositeScan
break_now = true;
while (!break_now && debug2) {
while (!break_now && debug_graphic) {
tp.printScans(
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
0, // bg_pass, // final int firstPass,
......@@ -9470,7 +9482,7 @@ public class QuadCLTCPU {
threadsMax,
updateStatus,
debugLevel);
if (show_init_refine) tp.showScan(
if (show_init_refine && (debugLevel > -2)) tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"after_measure-"+tp.clt_3d_passes.size());
......@@ -9512,7 +9524,7 @@ public class QuadCLTCPU {
disparity[i] = disparity_LMA[i]; // update only measured, others will be removed by makeUnique
}
}
if (show_init_refine) tp.showScan(
if (show_init_refine && (debugLevel > -2)) tp.showScan(
combo_multi[clust_radius-1], // CLTPass3d scan,
"combo_multi-"+clust_radius+"-pass"+nnn);
......@@ -9522,27 +9534,7 @@ public class QuadCLTCPU {
// when done, grow to fill gaps from 3x3 first (by 1 step) and from 5x5 - second?(by 2 steps), ...
}
}
break_now = true;
while (!break_now && debug2) {
tp.printScans(
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
0, // bg_pass, // final int firstPass,
tp.clt_3d_passes.size(), // final int lastPassPlus1,
true, // final boolean use_lma,
fom_min_strength, // final double min_strength,
fom_adisp, // final double fom_adisp, // 0.5
fom_cdiff, // final double fom_cdiff, // 0.02
fom_inf_bonus, // final double fom_inf_bonus, // 0.2; // add this to infinity FOM (if it is closer than fom_inf_range)
fom_inf_range, // final double fom_inf_range, // 0.5;
dbg_tileX, // final int tileX,
dbg_tileY); // final int tileY
}
// Restore pairs selection
// Restore pairs selection
clt_parameters.img_dtt.setMcorr(getNumSensors(), save_pairs_selection); // restore
if (clt_parameters.gr_nan_bg) {
if (debugLevel > -2) {
......@@ -9557,7 +9549,21 @@ public class QuadCLTCPU {
"pre-last_pass-"+tp.clt_3d_passes.size());
}
}
break_now = true;
while (!break_now && debug_graphic) {
tp.printScans(
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
0, // bg_pass, // final int firstPass,
tp.clt_3d_passes.size(), // final int lastPassPlus1,
true, // final boolean use_lma,
fom_min_strength, // final double min_strength,
fom_adisp, // final double fom_adisp, // 0.5
fom_cdiff, // final double fom_cdiff, // 0.02
fom_inf_bonus, // final double fom_inf_bonus, // 0.2; // add this to infinity FOM (if it is closer than fom_inf_range)
fom_inf_range, // final double fom_inf_range, // 0.5;
dbg_tileX, // final int tileX,
dbg_tileY); // final int tileY
}
if (clt_parameters.gr_exp_certain) {
int num_added = tp.expandCertainMulti (
......
......@@ -1867,6 +1867,7 @@ ImageDtt.startAndJoin(threads);
for (DSD dsd:dsd_list) {
CLTPass3d pass = passes.get(dsd.indx);
double [] diffs = pass.getSecondMaxDiff(false);
double diff = (diffs == null)?Double.NaN:diffs[nt];
String prefix = " ";
if (dsd.indx == dsd_max_fom.indx) {
prefix = "+";
......@@ -1878,7 +1879,7 @@ ImageDtt.startAndJoin(threads);
}
System.out.println (String.format("%1s%4d: %8.3f %6.4f %6.4f %5b %1d %8.3f %8.3f",
prefix, //
dsd.indx, dsd.disparity, dsd.strength, dsd.adiff, dsd.has_lma, dsd.clust_radius, diffs[nt], dsd.fom));
dsd.indx, dsd.disparity, dsd.strength, dsd.adiff, dsd.has_lma, dsd.clust_radius, diff, dsd.fom));
}
System.out.println();
return;
......
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