disparity_index,// index of disparity value in disparity_map == 2 (0,2 or 4)
clt_parameters.show_bgnd_nonbgnd,
(clt_parameters.debug_filters?(debugLevel):-1));
boolean[]bgnd_tiles_new=tp.getBackgroundMask_new(// which tiles do belong to the background
clt_parameters.bgnd_range,// disparity range to be considered background
clt_parameters.bgnd_sure,// minimal strength to be considered definitely background
clt_parameters.bgnd_maybe,// maximal strength to ignore as non-background
clt_parameters.sure_smth,// if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
clt_parameters.min_clstr_seed,// number of tiles in a cluster to seed (just background?)
clt_parameters.min_clstr_block,// number of tiles in a cluster to block (just non-background?)
disparity_index,// index of disparity value in disparity_map == 2 (0,2 or 4)
clt_parameters.show_bgnd_nonbgnd,
(clt_parameters.debug_filters?(debugLevel):-1));
boolean[]bgnd_dbg=bgnd_tiles.clone();// only these have non 0 alpha
// TODO: fix mess - after modifying getBackgroundMask() to getBackgroundMask_new (before road with tractor was identified as a background because of a double
// tile glitch, the background was wrong. So temporarily both old/new are used and combined (new is grown twice)
// still does not work - using old variant for now
// background selections (slightly) influences the plane mertging / connections
for(inti=0;i<bgnd_tiles.length;i++){
// bgnd_tiles[i] &= bgnd_tiles_new[i];
}
boolean[]bgnd_strict=bgnd_tiles.clone();// only these have non 0 alpha
tp.growTiles(
clt_parameters.bgnd_grow,// grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
...
...
@@ -5537,36 +5562,62 @@ public class QuadCLT {
2,// grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
bgnd_tiles,
null);// prohibit
// hacking - grow bgnd texture even more, without changing selection
boolean[]bgnd_tiles_grown2=bgnd_tiles_grown.clone();// only these have non 0 alpha
bgnd_data.selected=bgnd_tiles_grown;// selected for background w/o extra transparent layer
tp.growTiles(
2,// grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
st.planes,// final TilePlanes.PlaneData[][] planes,
merge_groups,// final int [][][] merge_groups,
// parameters to generate ellipsoids
0.0,// 3, // final double disp_far, // minimal disparity to select (or NaN)
Double.NaN,// final double disp_near, // maximal disparity to select (or NaN)
clt_parameters.plDispNorm,// final double dispNorm, // Normalize disparities to the average if above
0.0,// final double min_weight,
clt_parameters.plMinPoints,// final int min_tiles,
// parameters to reduce outliers
clt_parameters.plTargetEigen,// final double targetEigen, // = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below
clt_parameters.plFractOutliers,// final double fractOutliers, // = 0.3; // Maximal fraction of outliers to remove
clt_parameters.plMaxOutliers,// final int maxOutliers, // = 20; // Maximal number of outliers to remove
debugLevel,// final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
System.out.println("Try "+num_merge_try+": removed "+num_removed_by_merging+" planes by merging, recalculating connections");
if(num_removed_by_merging==0){// re-calculate all links
debugLevel+1,// 2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
intnum_removed_by_merging=st.applyMergePlanes(
st.planes,// final TilePlanes.PlaneData[][] planes,
merge_groups,// final int [][][] merge_groups,
// parameters to generate ellipsoids
0.0,// 3, // final double disp_far, // minimal disparity to select (or NaN)
Double.NaN,// final double disp_near, // maximal disparity to select (or NaN)
clt_parameters.plDispNorm,// final double dispNorm, // Normalize disparities to the average if above
0.0,// final double min_weight,
clt_parameters.plMinPoints,// final int min_tiles,
// parameters to reduce outliers
clt_parameters.plTargetEigen,// final double targetEigen, // = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below
clt_parameters.plFractOutliers,// final double fractOutliers, // = 0.3; // Maximal fraction of outliers to remove
clt_parameters.plMaxOutliers,// final int maxOutliers, // = 20; // Maximal number of outliers to remove
debugLevel,// 2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
System.out.println("Try "+num_merge_try+": removed "+num_removed_by_merging+" planes by merging, recalculating connections");
if(num_removed_by_merging==0){// re-calculate all links
// Consider supertiles with conflicts, merge conflicting layers with relaxed requirements
//TODO: Fix the mess to get rid of the plane_nooverlaps
Conflictsconflicts0_stats=newConflicts(
conflicts0,
st,
-1);// debugLevel);
System.out.println("Trying relaxed merging for conflicting plane pairs");
plane_nooverlaps=lp.overlapSameTileCandidates(
st.planes_mod,// final TilePlanes.PlaneData [][] planes,
conflicting_candidates,// final int [][][] merge_candidates,\
0.4,// final double min_distance,
debugLevel,// 2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// remove merge candidates that break connections to neighbors
if(debugLevel>100)lp.keepSameTileConnections(
st.planes_mod,// final TilePlanes.PlaneData [][] planes,
conflicting_candidates,// final int [][][] merge_candidates,
plane_nooverlaps,// final boolean [][][] valid_candidates, // will be updated
true,// final boolean merge_low_eigen, here it should be true
true,// final boolean useNonExcl, // consider only directions available for non-exclusive merges
debugLevel,// 2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// Consider supertiles with conflicts, merge conflicting layers with relaxed requirements
//end of TODO: Fix the mess to get rid of the plane_nooverlaps
// try to merge original (measured) planes, not smoothed ones
lp.costSameTileConnections(
// st.planes_mod, // final TilePlanes.PlaneData [][] planes,
st.planes,// final TilePlanes.PlaneData [][] planes,
conflicting_candidates,// final int [][][] merge_candidates,
plane_nooverlaps,// final boolean [][][] valid_candidates, // will be updated
lp.getConflRelax(),//relax_for_conflicts, // final double relax,
debugLevel,// 2, // -1, // debugLevel, // final int debugLevel)
lp.getConflRelax(),// relax_for_conflicts, // final double relax,
debugLevel+1,// 2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
num_removed_by_merging=st.applyMergePlanes(
st.planes,// final TilePlanes.PlaneData[][] planes,
merge_groups,// final int [][][] merge_groups,
// parameters to generate ellipsoids
0.0,// 3, // final double disp_far, // minimal disparity to select (or NaN)
Double.NaN,// final double disp_near, // maximal disparity to select (or NaN)
clt_parameters.plDispNorm,// final double dispNorm, // Normalize disparities to the average if above
0.0,// final double min_weight,
clt_parameters.plMinPoints,// final int min_tiles,
// parameters to reduce outliers
clt_parameters.plTargetEigen,// final double targetEigen, // = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below
clt_parameters.plFractOutliers,// final double fractOutliers, // = 0.3; // Maximal fraction of outliers to remove
clt_parameters.plMaxOutliers,// final int maxOutliers, // = 20; // Maximal number of outliers to remove
debugLevel,// 2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
System.out.println("Try "+num_merge_try+": removed "+num_removed_by_merging+" conflicting planes by merging, recalculating connections");
if(num_merge_try>=max_num_tries){
System.out.println("Exceeded maximal number of iterations, beaking anyway...");
break;
}
if(num_removed_by_merging==0){// re-calculate all links
break;
}
}
// Do the same as in conditionSuperTiles before smoothing again
lp.matchPlanes(
st.planes,// final TilePlanes.PlaneData [][] planes,
debugLevel,// final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
lp.interPlaneCosts(//
true,// final boolean en_sticks, // treat planes with second eigenvalue below plEigenStick as "sticks"
st.planes,// final TilePlanes.PlaneData [][] planes,
debugLevel,// final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
lp.filterNeighborPlanes(
st.planes,// final TilePlanes.PlaneData [][] planes,
true,// final boolean merge_low_eigen,
debugLevel,// final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// calculate it here - use results to keep some planes from merging