Commit 86e21078 authored by Andrey Filippov's avatar Andrey Filippov

merging planes in the same supertile

parent d24659c3
...@@ -33,6 +33,8 @@ public class ConnectionCosts { ...@@ -33,6 +33,8 @@ public class ConnectionCosts {
double diagonalWeight; double diagonalWeight;
double starPwr; // Divide cost by number of connections to this power double starPwr; // Divide cost by number of connections to this power
double starWeightPwr; // Use this power of tile weight when calculating connection cost double starWeightPwr; // Use this power of tile weight when calculating connection cost
double weightToDens; // Balance weighted density against density. 0.0 - density, 1.0 - weighted density
double starValPwr; // Raise value of each tile before averaging double starValPwr; // Raise value of each tile before averaging
int steps; int steps;
...@@ -51,6 +53,7 @@ public class ConnectionCosts { ...@@ -51,6 +53,7 @@ public class ConnectionCosts {
double diagonalWeight, double diagonalWeight,
double starPwr, // Divide cost by number of connections to this power double starPwr, // Divide cost by number of connections to this power
double starWeightPwr, // Use this power of tile weight when calculating connection cost double starWeightPwr, // Use this power of tile weight when calculating connection cost
double weightToDens, // Balance weighted density against density. 0.0 - density, 1.0 - weighted density
double starValPwr, // Raise value of each tile before averaging double starValPwr, // Raise value of each tile before averaging
int steps, int steps,
TilePlanes.PlaneData [][] planes, TilePlanes.PlaneData [][] planes,
...@@ -64,12 +67,14 @@ public class ConnectionCosts { ...@@ -64,12 +67,14 @@ public class ConnectionCosts {
this.diagonalWeight = diagonalWeight; this.diagonalWeight = diagonalWeight;
this.starPwr = starPwr; // Divide cost by number of connections to this power this.starPwr = starPwr; // Divide cost by number of connections to this power
this.starWeightPwr = starWeightPwr; this.starWeightPwr = starWeightPwr;
this.weightToDens = weightToDens; // Balance weighted density against density. 0.0 - density, 1.0 - weighted density
this.starValPwr = starValPwr; // Raise value of each tile before averaging this.starValPwr = starValPwr; // Raise value of each tile before averaging
this.steps = steps; this.steps = steps;
} }
public int [][][] initConnectionCosts( public int [][][] initConnectionCosts(
int [] nsTiles) int [] nsTiles,
int debugLevel)
{ {
int [] exp_tiles = nsTiles; int [] exp_tiles = nsTiles;
for (int i = 1; i < steps; i++) exp_tiles = getInvolvedSupertiles(exp_tiles); for (int i = 1; i < steps; i++) exp_tiles = getInvolvedSupertiles(exp_tiles);
...@@ -92,7 +97,7 @@ public class ConnectionCosts { ...@@ -92,7 +97,7 @@ public class ConnectionCosts {
if (planes[nsTile] != null){ if (planes[nsTile] != null){
val_weights[isTile] = new double [planes[nsTile].length][]; val_weights[isTile] = new double [planes[nsTile].length][];
for (int nl = 0; nl < planes[nsTile].length; nl++) if ( planes[nsTile][nl] != null){ for (int nl = 0; nl < planes[nsTile].length; nl++) if ( planes[nsTile][nl] != null){
val_weights[isTile][nl] = new double[2]; val_weights[isTile][nl] = new double[3];
} }
} }
} }
...@@ -111,17 +116,17 @@ public class ConnectionCosts { ...@@ -111,17 +116,17 @@ public class ConnectionCosts {
case 1: case 1:
val_weights = getConnectionsCostSingleStep ( val_weights = getConnectionsCostSingleStep (
null, null,
-1); // int debugLevel) debugLevel - 1); // int debugLevel)
break; break;
case 2: case 2:
val_weights = getConnectionsCostDualStep ( val_weights = getConnectionsCostDualStep (
null, null,
-1); // int debugLevel) debugLevel - 1); // int debugLevel)
break; break;
default: default:
val_weights = getConnectionsCostSingleStep ( val_weights = getConnectionsCostSingleStep (
null, null,
-1); // int debugLevel) debugLevel - 1); // int debugLevel)
} }
last_val_weights = val_weights; last_val_weights = val_weights;
...@@ -131,10 +136,16 @@ public class ConnectionCosts { ...@@ -131,10 +136,16 @@ public class ConnectionCosts {
for (int isTile = 0; isTile < all_tiles.length; isTile++){ for (int isTile = 0; isTile < all_tiles.length; isTile++){
if (val_weights[isTile] != null){ if (val_weights[isTile] != null){
for (int nl = 0; nl < val_weights[isTile].length; nl++) if ( val_weights[isTile][nl] != null){ for (int nl = 0; nl < val_weights[isTile].length; nl++) if ( val_weights[isTile][nl] != null){
double weighted = val_weights[isTile][nl][1];
double density = val_weights[isTile][nl][2];
double weight = (weightToDens >= 1.0) ? weighted :
((weightToDens <= 0.0) ? density :
(Math.pow(weighted, weightToDens) * Math.pow(density, 1.0 - weightToDens)));
double val = val_weights[isTile][nl][0]; double val = val_weights[isTile][nl][0];
if (starValPwr != 1.0) val = Math.pow(val, starValPwr); if (starValPwr != 1.0) val = Math.pow(val, starValPwr);
init_val += val * val_weights[isTile][nl][1]; init_val += val * weight;
init_weight += val_weights[isTile][nl][1]; init_weight += weight;
} }
} }
} }
...@@ -259,6 +270,7 @@ public class ConnectionCosts { ...@@ -259,6 +270,7 @@ public class ConnectionCosts {
int ineib1 = (tile_map.containsKey(nsTile1))? tile_map.get(nsTile1) : -1; int ineib1 = (tile_map.containsKey(nsTile1))? tile_map.get(nsTile1) : -1;
neibs2[dir] = (ineib1 >=0) ? neibs[tile_map.get(nsTile1)][nl1] : planes[nsTile1][nl1].getNeibBest(); neibs2[dir] = (ineib1 >=0) ? neibs[tile_map.get(nsTile1)][nl1] : planes[nsTile1][nl1].getNeibBest();
if (!neibs_changed && (ineib1 >= 0)) { if (!neibs_changed && (ineib1 >= 0)) {
/*
if ((neibs_init[ineib1] == null) || (neibs_init[ineib1][nl1] == null)) { if ((neibs_init[ineib1] == null) || (neibs_init[ineib1][nl1] == null)) {
neibs_changed = true; neibs_changed = true;
} else { } else {
...@@ -267,6 +279,16 @@ public class ConnectionCosts { ...@@ -267,6 +279,16 @@ public class ConnectionCosts {
break; break;
} }
} }
*/
if ((neibs_init[ineib1] == null) || (neibs[ineib1][nl1] == null)) {
neibs_changed = true;
} else {
for (int dir1 = 0; dir1 < 8; dir1++) if (neibs[ineib1][nl1][dir1] != neibs_init[ineib1][nl1][dir1]){
neibs_changed = true;
break;
}
}
} }
} }
} }
...@@ -296,6 +318,35 @@ public class ConnectionCosts { ...@@ -296,6 +318,35 @@ public class ConnectionCosts {
} }
} }
} }
if (debugLevel > 0) {
for (int isTile = 0; isTile < all_tiles.length; isTile++){
int nsTile = all_tiles[isTile];
System.out.print("getConnectionsCostDualStep(): "+isTile+" ("+nsTile+"): ");
if (vw[isTile] != null) {
for (int nl = 0; nl < vw[isTile].length; nl++){
// System.out.print(" "+nl+":[");
System.out.print(" "+nl+":[");
if (vw[isTile][nl] != null ) {
for (int i = 0; i < vw[isTile][nl].length;i++){
System.out.print(vw[isTile][nl][i]);
// if (i < (vw[isTile][nl].length -1)){
System.out.print(", ");
// }
}
double weighted = vw[isTile][nl][1];
double density = vw[isTile][nl][2];
double weight = (weightToDens >= 1.0) ? weighted :
((weightToDens <= 0.0) ? density :
(Math.pow(weighted, weightToDens) * Math.pow(density, 1.0 - weightToDens)));
System.out.print(weight);
}
// System.out.print("]");
System.out.println("]");
}
}
System.out.println();
}
}
return vw; // negative - improvement return vw; // negative - improvement
} }
...@@ -310,17 +361,17 @@ public class ConnectionCosts { ...@@ -310,17 +361,17 @@ public class ConnectionCosts {
case 1: case 1:
vw = getConnectionsCostSingleStep ( vw = getConnectionsCostSingleStep (
neibs, neibs,
-1); // int debugLevel) debugLevel-1); // int debugLevel)
break; break;
case 2: case 2:
vw = getConnectionsCostDualStep ( vw = getConnectionsCostDualStep (
neibs, neibs,
-1); // int debugLevel) debugLevel-1); // int debugLevel)
break; break;
default: default:
vw = getConnectionsCostSingleStep ( vw = getConnectionsCostSingleStep (
neibs, neibs,
-1); // int debugLevel) debugLevel-1); // int debugLevel)
} }
last_val_weights = vw; last_val_weights = vw;
// calculate new cost // calculate new cost
...@@ -329,11 +380,16 @@ public class ConnectionCosts { ...@@ -329,11 +380,16 @@ public class ConnectionCosts {
for (int isTile = 0; isTile < all_tiles.length; isTile++){ for (int isTile = 0; isTile < all_tiles.length; isTile++){
if (vw[isTile] != null){ if (vw[isTile] != null){
for (int nl = 0; nl < vw[isTile].length; nl++) if ( vw[isTile][nl] != null){ for (int nl = 0; nl < vw[isTile].length; nl++) if ( vw[isTile][nl] != null){
double weighted = vw[isTile][nl][1];
double density = vw[isTile][nl][2];
double weight = (weightToDens >= 1.0) ? weighted :
((weightToDens <= 0.0) ? density :
(Math.pow(weighted, weightToDens) * Math.pow(density, 1.0 - weightToDens)));
double val = vw[isTile][nl][0]; double val = vw[isTile][nl][0];
if (starValPwr != 1.0) val = Math.pow(val, starValPwr); if (starValPwr != 1.0) val = Math.pow(val, starValPwr);
new_value += val * vw[isTile][nl][1]; new_value += val * weight;
new_weight += vw[isTile][nl][1]; new_weight += weight;
} }
} }
} }
...@@ -372,6 +428,7 @@ public class ConnectionCosts { ...@@ -372,6 +428,7 @@ public class ConnectionCosts {
int debugLevel) int debugLevel)
{ {
TilePlanes.PlaneData merged_plane = planes[nsTile][nl]; // add weight TilePlanes.PlaneData merged_plane = planes[nsTile][nl]; // add weight
double conn_weight = 1.0; // center weight
for (int dir = 0; dir < 8; dir++){ for (int dir = 0; dir < 8; dir++){
if (neibs[dir] >= 0){ if (neibs[dir] >= 0){
double other_weight = ((dir & 1) != 0) ? diagonalWeight : orthoWeight; double other_weight = ((dir & 1) != 0) ? diagonalWeight : orthoWeight;
...@@ -386,9 +443,10 @@ public class ConnectionCosts { ...@@ -386,9 +443,10 @@ public class ConnectionCosts {
true, // boolean sum_weights, true, // boolean sum_weights,
preferDisparity, preferDisparity,
debugLevel - 1); // int debugLevel) debugLevel - 1); // int debugLevel)
conn_weight += 1.0;
} }
} }
double [] value_weight = {merged_plane.getValue(),merged_plane.getWeight()}; double [] value_weight = {merged_plane.getValue(),merged_plane.getWeight(),conn_weight};
if (starPwr != 0){ if (starPwr != 0){
value_weight[0] /= (Math.pow((planes[nsTile][nl].getNumNeibBest() + 1.0), starPwr)); value_weight[0] /= (Math.pow((planes[nsTile][nl].getNumNeibBest() + 1.0), starPwr));
} }
...@@ -451,6 +509,7 @@ public class ConnectionCosts { ...@@ -451,6 +509,7 @@ public class ConnectionCosts {
} }
} }
TilePlanes.PlaneData merged_plane = planes[nsTile][nl]; // center point TilePlanes.PlaneData merged_plane = planes[nsTile][nl]; // center point
double conn_weight = 1.0; // center weight
for (HashMap.Entry<Point, Double> entry : tile_weights.entrySet()){ for (HashMap.Entry<Point, Double> entry : tile_weights.entrySet()){
TilePlanes.PlaneData other_plane = merged_plane.getPlaneToThis( // layer here does not matter TilePlanes.PlaneData other_plane = merged_plane.getPlaneToThis( // layer here does not matter
planes[entry.getKey().x][entry.getKey().y], planes[entry.getKey().x][entry.getKey().y],
...@@ -458,13 +517,15 @@ public class ConnectionCosts { ...@@ -458,13 +517,15 @@ public class ConnectionCosts {
merged_plane = merged_plane.mergePlaneToThis( merged_plane = merged_plane.mergePlaneToThis(
other_plane, // PlaneData otherPd, other_plane, // PlaneData otherPd,
entry.getValue(), // double scale_other, entry.getValue(), // double scale_other,
starPwr, // Divide cost by number of connections to this power starPwr, // Divide cost by number of connections to this power
false, // boolean ignore_weights, false, // boolean ignore_weights,
true, // boolean sum_weights, true, // boolean sum_weights,
preferDisparity, preferDisparity,
debugLevel - 1); // int debugLevel) debugLevel - 1); // int debugLevel)
conn_weight += entry.getValue();
} }
double [] value_weight = {merged_plane.getValue(),merged_plane.getWeight()}; double [] value_weight = {merged_plane.getValue(),merged_plane.getWeight(),conn_weight};
if (starPwr != 0){ if (starPwr != 0){
value_weight[0] /= (Math.pow(tile_weights.size() + 1.0, starPwr)); value_weight[0] /= (Math.pow(tile_weights.size() + 1.0, starPwr));
} }
......
...@@ -2168,7 +2168,8 @@ public class EyesisCorrectionParameters { ...@@ -2168,7 +2168,8 @@ public class EyesisCorrectionParameters {
public double plFractOutliers = 0.3; // Maximal fraction of outliers to remove public double plFractOutliers = 0.3; // Maximal fraction of outliers to remove
public int plMaxOutliers = 20; // Maximal number of outliers to remove public int plMaxOutliers = 20; // Maximal number of outliers to remove
public double plMinStrength = 0.1; // Minimal total strength of a plane public double plMinStrength = 0.1; // Minimal total strength of a plane
public double plMaxEigen = 0.3; // Maximal eigenvalue of a plane public double plMaxEigen = 0.05; // Maximal eigenvalue of a plane
public double plEigenFloor = 0.01; // Add to eigenvalues of each participating plane and result to validate connections
public boolean plDbgMerge = true; // Combine 'other' plane with current public boolean plDbgMerge = true; // Combine 'other' plane with current
public double plWorstWorsening = 2.0; // Worst case worsening after merge public double plWorstWorsening = 2.0; // Worst case worsening after merge
public double plWorstWorsening2 = 5.0; // Worst case worsening for thin planes public double plWorstWorsening2 = 5.0; // Worst case worsening for thin planes
...@@ -2183,11 +2184,12 @@ public class EyesisCorrectionParameters { ...@@ -2183,11 +2184,12 @@ public class EyesisCorrectionParameters {
public boolean plConflDiag = false; // Resolve diagonal (ood) conflicts public boolean plConflDiag = false; // Resolve diagonal (ood) conflicts
public boolean plConflStar = true; // Resolve all conflicts around a supertile public boolean plConflStar = true; // Resolve all conflicts around a supertile
public int plStarSteps = 2; // How far to look around when calculationg connection cost public int plStarSteps = 2; // How far to look around when calculating connection cost
public double plStarOrtho = 0.5; // When calculating cost for the connections scale 4 ortho neighbors public double plStarOrtho = 0.5; // When calculating cost for the connections scale 4 ortho neighbors
public double plStarDiag = 0.25; // When calculating cost for the connections scale 4 diagonal neighbors public double plStarDiag = 0.25; // When calculating cost for the connections scale 4 diagonal neighbors
public double plStarPwr = 0.5; // Divide cost by number of connections to this power public double plStarPwr = 0.5; // Divide cost by number of connections to this power
public double plStarWeightPwr = 0.5; // use this power of tile weight when calculating connection cost public double plStarWeightPwr = 0.5; // use this power of tile weight when calculating connection cost
public double plWeightToDens = 0.3; // Balance weighted density against density. 0.0 - density, 1.0 - weighted density
public double plStarValPwr = 1.0; // Raise value of each tile before averaging public double plStarValPwr = 1.0; // Raise value of each tile before averaging
public double plDblTriLoss = 0.0001; // When resolving double triangles allow minor degradation (0.0 - strict) public double plDblTriLoss = 0.0001; // When resolving double triangles allow minor degradation (0.0 - strict)
public boolean plNewConfl = false; // Allow more conflicts if overall cost is reduced public boolean plNewConfl = false; // Allow more conflicts if overall cost is reduced
...@@ -2535,6 +2537,7 @@ public class EyesisCorrectionParameters { ...@@ -2535,6 +2537,7 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"plMaxOutliers", this.plMaxOutliers+""); properties.setProperty(prefix+"plMaxOutliers", this.plMaxOutliers+"");
properties.setProperty(prefix+"plMinStrength", this.plMinStrength +""); properties.setProperty(prefix+"plMinStrength", this.plMinStrength +"");
properties.setProperty(prefix+"plMaxEigen", this.plMaxEigen +""); properties.setProperty(prefix+"plMaxEigen", this.plMaxEigen +"");
properties.setProperty(prefix+"plEigenFloor", this.plEigenFloor +"");
properties.setProperty(prefix+"plDbgMerge", this.plDbgMerge+""); properties.setProperty(prefix+"plDbgMerge", this.plDbgMerge+"");
properties.setProperty(prefix+"plWorstWorsening", this.plWorstWorsening +""); properties.setProperty(prefix+"plWorstWorsening", this.plWorstWorsening +"");
properties.setProperty(prefix+"plWorstWorsening2",this.plWorstWorsening2 +""); properties.setProperty(prefix+"plWorstWorsening2",this.plWorstWorsening2 +"");
...@@ -2553,6 +2556,7 @@ public class EyesisCorrectionParameters { ...@@ -2553,6 +2556,7 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"plStarDiag", this.plStarDiag +""); properties.setProperty(prefix+"plStarDiag", this.plStarDiag +"");
properties.setProperty(prefix+"plStarPwr", this.plStarPwr +""); properties.setProperty(prefix+"plStarPwr", this.plStarPwr +"");
properties.setProperty(prefix+"plStarWeightPwr", this.plStarWeightPwr +""); properties.setProperty(prefix+"plStarWeightPwr", this.plStarWeightPwr +"");
properties.setProperty(prefix+"plWeightToDens", this.plWeightToDens +"");
properties.setProperty(prefix+"plStarValPwr", this.plStarValPwr +""); properties.setProperty(prefix+"plStarValPwr", this.plStarValPwr +"");
properties.setProperty(prefix+"plDblTriLoss", this.plDblTriLoss +""); properties.setProperty(prefix+"plDblTriLoss", this.plDblTriLoss +"");
properties.setProperty(prefix+"plNewConfl", this.plNewConfl+""); properties.setProperty(prefix+"plNewConfl", this.plNewConfl+"");
...@@ -2880,6 +2884,7 @@ public class EyesisCorrectionParameters { ...@@ -2880,6 +2884,7 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"plMaxOutliers")!=null) this.plMaxOutliers=Integer.parseInt(properties.getProperty(prefix+"plMaxOutliers")); if (properties.getProperty(prefix+"plMaxOutliers")!=null) this.plMaxOutliers=Integer.parseInt(properties.getProperty(prefix+"plMaxOutliers"));
if (properties.getProperty(prefix+"plMinStrength")!=null) this.plMinStrength=Double.parseDouble(properties.getProperty(prefix+"plMinStrength")); if (properties.getProperty(prefix+"plMinStrength")!=null) this.plMinStrength=Double.parseDouble(properties.getProperty(prefix+"plMinStrength"));
if (properties.getProperty(prefix+"plMaxEigen")!=null) this.plMaxEigen=Double.parseDouble(properties.getProperty(prefix+"plMaxEigen")); if (properties.getProperty(prefix+"plMaxEigen")!=null) this.plMaxEigen=Double.parseDouble(properties.getProperty(prefix+"plMaxEigen"));
if (properties.getProperty(prefix+"plEigenFloor")!=null) this.plEigenFloor=Double.parseDouble(properties.getProperty(prefix+"plEigenFloor"));
if (properties.getProperty(prefix+"plDbgMerge")!=null) this.plDbgMerge=Boolean.parseBoolean(properties.getProperty(prefix+"plDbgMerge")); if (properties.getProperty(prefix+"plDbgMerge")!=null) this.plDbgMerge=Boolean.parseBoolean(properties.getProperty(prefix+"plDbgMerge"));
if (properties.getProperty(prefix+"plWorstWorsening")!=null) this.plWorstWorsening=Double.parseDouble(properties.getProperty(prefix+"plWorstWorsening")); if (properties.getProperty(prefix+"plWorstWorsening")!=null) this.plWorstWorsening=Double.parseDouble(properties.getProperty(prefix+"plWorstWorsening"));
if (properties.getProperty(prefix+"plWorstWorsening2")!=null) this.plWorstWorsening2=Double.parseDouble(properties.getProperty(prefix+"plWorstWorsening2")); if (properties.getProperty(prefix+"plWorstWorsening2")!=null) this.plWorstWorsening2=Double.parseDouble(properties.getProperty(prefix+"plWorstWorsening2"));
...@@ -2898,6 +2903,7 @@ public class EyesisCorrectionParameters { ...@@ -2898,6 +2903,7 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"plStarDiag")!=null) this.plStarDiag=Double.parseDouble(properties.getProperty(prefix+"plStarDiag")); if (properties.getProperty(prefix+"plStarDiag")!=null) this.plStarDiag=Double.parseDouble(properties.getProperty(prefix+"plStarDiag"));
if (properties.getProperty(prefix+"plStarPwr")!=null) this.plStarPwr=Double.parseDouble(properties.getProperty(prefix+"plStarPwr")); if (properties.getProperty(prefix+"plStarPwr")!=null) this.plStarPwr=Double.parseDouble(properties.getProperty(prefix+"plStarPwr"));
if (properties.getProperty(prefix+"plStarWeightPwr")!=null) this.plStarWeightPwr=Double.parseDouble(properties.getProperty(prefix+"plStarWeightPwr")); if (properties.getProperty(prefix+"plStarWeightPwr")!=null) this.plStarWeightPwr=Double.parseDouble(properties.getProperty(prefix+"plStarWeightPwr"));
if (properties.getProperty(prefix+"plWeightToDens")!=null) this.plWeightToDens=Double.parseDouble(properties.getProperty(prefix+"plWeightToDens"));
if (properties.getProperty(prefix+"plStarValPwr")!=null) this.plStarValPwr=Double.parseDouble(properties.getProperty(prefix+"plStarValPwr")); if (properties.getProperty(prefix+"plStarValPwr")!=null) this.plStarValPwr=Double.parseDouble(properties.getProperty(prefix+"plStarValPwr"));
if (properties.getProperty(prefix+"plDblTriLoss")!=null) this.plDblTriLoss=Double.parseDouble(properties.getProperty(prefix+"plDblTriLoss")); if (properties.getProperty(prefix+"plDblTriLoss")!=null) this.plDblTriLoss=Double.parseDouble(properties.getProperty(prefix+"plDblTriLoss"));
if (properties.getProperty(prefix+"plNewConfl")!=null) this.plNewConfl=Boolean.parseBoolean(properties.getProperty(prefix+"plNewConfl")); if (properties.getProperty(prefix+"plNewConfl")!=null) this.plNewConfl=Boolean.parseBoolean(properties.getProperty(prefix+"plNewConfl"));
...@@ -3253,6 +3259,7 @@ public class EyesisCorrectionParameters { ...@@ -3253,6 +3259,7 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Maximal number of outliers to remove", this.plMaxOutliers, 0); gd.addNumericField("Maximal number of outliers to remove", this.plMaxOutliers, 0);
gd.addNumericField("Minimal total strength of a plane", this.plMinStrength, 6); gd.addNumericField("Minimal total strength of a plane", this.plMinStrength, 6);
gd.addNumericField("Maximal eigenvalue of a plane", this.plMaxEigen, 6); gd.addNumericField("Maximal eigenvalue of a plane", this.plMaxEigen, 6);
gd.addNumericField("Add to eigenvalues of each participating plane and result to validate connections",this.plEigenFloor, 6);
gd.addCheckbox ("Combine 'other' plane with the current (unused)", this.plDbgMerge); gd.addCheckbox ("Combine 'other' plane with the current (unused)", this.plDbgMerge);
gd.addNumericField("Worst case worsening after merge", this.plWorstWorsening, 6); gd.addNumericField("Worst case worsening after merge", this.plWorstWorsening, 6);
gd.addNumericField("Worst case worsening for thin planes", this.plWorstWorsening2, 6); gd.addNumericField("Worst case worsening for thin planes", this.plWorstWorsening2, 6);
...@@ -3271,6 +3278,7 @@ public class EyesisCorrectionParameters { ...@@ -3271,6 +3278,7 @@ public class EyesisCorrectionParameters {
gd.addNumericField("When calculating cost for the connections scale 4 diagonal neighbors", this.plStarDiag, 6); gd.addNumericField("When calculating cost for the connections scale 4 diagonal neighbors", this.plStarDiag, 6);
gd.addNumericField("Divide cost by number of connections to this power", this.plStarPwr, 6); gd.addNumericField("Divide cost by number of connections to this power", this.plStarPwr, 6);
gd.addNumericField("Use this power of tile weight when calculating connection cost", this.plStarWeightPwr, 6); gd.addNumericField("Use this power of tile weight when calculating connection cost", this.plStarWeightPwr, 6);
gd.addNumericField("Balance weighted density against density. 0.0 - density, 1.0 - weighted density", this.plWeightToDens, 6);
gd.addNumericField("Raise value of each tile before averaging", this.plStarValPwr, 6); gd.addNumericField("Raise value of each tile before averaging", this.plStarValPwr, 6);
gd.addNumericField("When resolving double triangles allow minor degradation (0.0 - strict)", this.plDblTriLoss, 6); gd.addNumericField("When resolving double triangles allow minor degradation (0.0 - strict)", this.plDblTriLoss, 6);
gd.addCheckbox ("Allow more conflicts if overall cost is reduced", this.plNewConfl); gd.addCheckbox ("Allow more conflicts if overall cost is reduced", this.plNewConfl);
...@@ -3611,6 +3619,7 @@ public class EyesisCorrectionParameters { ...@@ -3611,6 +3619,7 @@ public class EyesisCorrectionParameters {
this.plMaxOutliers= (int) gd.getNextNumber(); this.plMaxOutliers= (int) gd.getNextNumber();
this.plMinStrength= gd.getNextNumber(); this.plMinStrength= gd.getNextNumber();
this.plMaxEigen= gd.getNextNumber(); this.plMaxEigen= gd.getNextNumber();
this.plEigenFloor= gd.getNextNumber();
this.plDbgMerge= gd.getNextBoolean(); this.plDbgMerge= gd.getNextBoolean();
this.plWorstWorsening= gd.getNextNumber(); this.plWorstWorsening= gd.getNextNumber();
this.plWorstWorsening2= gd.getNextNumber(); this.plWorstWorsening2= gd.getNextNumber();
...@@ -3629,6 +3638,7 @@ public class EyesisCorrectionParameters { ...@@ -3629,6 +3638,7 @@ public class EyesisCorrectionParameters {
this.plStarDiag= gd.getNextNumber(); this.plStarDiag= gd.getNextNumber();
this.plStarPwr= gd.getNextNumber(); this.plStarPwr= gd.getNextNumber();
this.plStarWeightPwr= gd.getNextNumber(); this.plStarWeightPwr= gd.getNextNumber();
this.plWeightToDens= gd.getNextNumber();
this.plStarValPwr= gd.getNextNumber(); this.plStarValPwr= gd.getNextNumber();
this.plDblTriLoss= gd.getNextNumber(); this.plDblTriLoss= gd.getNextNumber();
this.plNewConfl= gd.getNextBoolean(); this.plNewConfl= gd.getNextBoolean();
......
...@@ -505,7 +505,7 @@ private Panel panel1, ...@@ -505,7 +505,7 @@ private Panel panel1,
addButton("CLT show fine corr", panelClt1, color_configure); addButton("CLT show fine corr", panelClt1, color_configure);
addButton("CLT apply fine corr", panelClt1, color_process); addButton("CLT apply fine corr", panelClt1, color_process);
addButton("CLT reset 3D", panelClt1, color_stop); addButton("CLT reset 3D", panelClt1, color_stop);
addButton("CLT 3D", panelClt1, color_conf_process); addButton("CLT 3D", panelClt1, color_process);
addButton("CLT planes", panelClt1, color_conf_process); addButton("CLT planes", panelClt1, color_conf_process);
addButton("CLT ASSIGN", panelClt1, color_process); addButton("CLT ASSIGN", panelClt1, color_process);
addButton("CLT OUT 3D", panelClt1, color_process); addButton("CLT OUT 3D", panelClt1, color_process);
......
This diff is collapsed.
...@@ -87,6 +87,7 @@ public class TilePlanes { ...@@ -87,6 +87,7 @@ public class TilePlanes {
double smplRms = 0.1; // Maximal RMS of the remaining tiles in a sample double smplRms = 0.1; // Maximal RMS of the remaining tiles in a sample
double [] starValueWeight = null; double [] starValueWeight = null;
double conn_density = Double.NaN; //
boolean preferDisparity = false; boolean preferDisparity = false;
...@@ -142,17 +143,32 @@ public class TilePlanes { ...@@ -142,17 +143,32 @@ public class TilePlanes {
if (starValueWeight != null){ if (starValueWeight != null){
pd.starValueWeight = starValueWeight.clone(); pd.starValueWeight = starValueWeight.clone();
} }
pd.conn_density = this.conn_density;
return pd; return pd;
} }
// public void setConnectionDensity(double density){
// conn_density = density;
// }
public void setStarValueWeight(double value, double weight){ public double getConnectionDensity(){
this.starValueWeight = new double[2]; return conn_density;
this.starValueWeight[0] = value;
this.starValueWeight[1] = weight;
} }
// public void setStarValueWeight(double value, double weight){
// this.starValueWeight = new double[2];
// this.starValueWeight[0] = value;
// this.starValueWeight[1] = weight;
// System.out.println("setStarValueWeight(): conn_density is not set");
// }
public void setStarValueWeight(double[] val_weight){ public void setStarValueWeight(double[] val_weight){
this.starValueWeight = val_weight; this.starValueWeight = new double[2];
this.starValueWeight[0] = val_weight[0];
this.starValueWeight[1] = val_weight[1];
this.conn_density = 0.0;
// if (val_weight.length > 2){
this.conn_density = val_weight[2];
// }
} }
public double [] getStarValueWeight() public double [] getStarValueWeight()
......
...@@ -3424,15 +3424,42 @@ public class TileProcessor { ...@@ -3424,15 +3424,42 @@ public class TileProcessor {
clt_parameters.plWeakWorsening, // final double worst_worsening, clt_parameters.plWeakWorsening, // final double worst_worsening,
clt_parameters.plOKMergeEigen, // final double okMergeEigen, f result of the merged planes is below, OK to use thin planes (higher) threshold clt_parameters.plOKMergeEigen, // final double okMergeEigen, f result of the merged planes is below, OK to use thin planes (higher) threshold
clt_parameters.plMaxWorldSin2, // final double maxWorldSin2, clt_parameters.plMaxWorldSin2, // final double maxWorldSin2,
clt_parameters.plDispNorm, clt_parameters.plDispNorm,
clt_parameters.plMaxEigen, clt_parameters.plMaxEigen,
clt_parameters.plEigenFloor, // final double eigenFloor, // Add to eigenvalues of each participating plane and result to validate connections
clt_parameters.plMinStrength, clt_parameters.plMinStrength,
0, // final int debugLevel) 0, // final int debugLevel)
clt_parameters.tileX, clt_parameters.tileX,
clt_parameters.tileY); clt_parameters.tileY);
/* */ /* */
int [][][] merge_candidates = st.getMergeSameTileCandidates(
2, // final int debugLevel,
clt_parameters.tileX,
clt_parameters.tileY);
boolean [][] pairs_to_merge = st.mergeSameTileEvaluate(
merge_candidates, // final int [][][] merge_candidates,
clt_parameters.plWorstWorsening, // final double worst_worsening,
clt_parameters.plWorstWorsening2,// final double worst_worsening2 Worst case worsening for thin planes,
clt_parameters.plWorstEq, // final double worstEq, // Worst case worsening after merge with equal weights
clt_parameters.plWorstEq2, // final double worstEq2, // Worst case worsening for thin planes with equal weights
clt_parameters.plWeakWorsening, // final double worst_worsening,
clt_parameters.plOKMergeEigen, // final double okMergeEigen, f result of the merged planes is below, OK to use thin planes (higher) threshold
clt_parameters.plMaxWorldSin2, // final double maxWorldSin2,
clt_parameters.plDispNorm,
clt_parameters.plMaxEigen,
clt_parameters.plEigenFloor, // final double eigenFloor, // Add to eigenvalues of each participating plane and result to validate connections
0.0, // clt_parameters.plMinStrength,
clt_parameters.plPreferDisparity,
2, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
st.selectNeighborPlanesMutual( st.selectNeighborPlanesMutual(
clt_parameters.plEigenFloor, // final double eigenFloor, // Add to eigenvalues of each participating plane and result to validate connections
0, // final int debugLevel) 0, // final int debugLevel)
clt_parameters.tileX, clt_parameters.tileX,
clt_parameters.tileY); clt_parameters.tileY);
...@@ -3445,6 +3472,7 @@ public class TileProcessor { ...@@ -3445,6 +3472,7 @@ public class TileProcessor {
clt_parameters.plDispNorm, clt_parameters.plDispNorm,
clt_parameters.plMaxEigen, clt_parameters.plMaxEigen,
clt_parameters.plEigenFloor, // final double eigenFloor, // Add to eigenvalues of each participating plane and result to validate connections
clt_parameters.plMinStrength, clt_parameters.plMinStrength,
0, // final int debugLevel) 0, // final int debugLevel)
clt_parameters.tileX, clt_parameters.tileX,
...@@ -3461,6 +3489,7 @@ public class TileProcessor { ...@@ -3461,6 +3489,7 @@ public class TileProcessor {
clt_parameters.plStarDiag, // double diagonalWeight, clt_parameters.plStarDiag, // double diagonalWeight,
clt_parameters.plStarPwr, // double starPwr, // Divide cost by number of connections to this power clt_parameters.plStarPwr, // double starPwr, // Divide cost by number of connections to this power
clt_parameters.plStarWeightPwr,// double starWeightPwr, // Use this power of tile weight when calculating connection cost clt_parameters.plStarWeightPwr,// double starWeightPwr, // Use this power of tile weight when calculating connection cost
clt_parameters.plWeightToDens, // double weightToDens, // // Balance weighted density against density. 0.0 - density, 1.0 - weighted density
clt_parameters.plStarValPwr, // double starValPwr, // Raise value of each tile before averaging clt_parameters.plStarValPwr, // double starValPwr, // Raise value of each tile before averaging
clt_parameters.plDblTriLoss, // double diagonalWeight, clt_parameters.plDblTriLoss, // double diagonalWeight,
clt_parameters.plNewConfl, // boolean preferDisparity, // Allow more conflicts if overall cost is reduced clt_parameters.plNewConfl, // boolean preferDisparity, // Allow more conflicts if overall cost is reduced
...@@ -3476,7 +3505,7 @@ public class TileProcessor { ...@@ -3476,7 +3505,7 @@ public class TileProcessor {
clt_parameters.plConflMulti, // boolean conflMulti, // Resolve multiple odo triangles conflicts clt_parameters.plConflMulti, // boolean conflMulti, // Resolve multiple odo triangles conflicts
clt_parameters.plConflDiag, // boolean conflDiag, // Resolve diagonal (ood) conflicts clt_parameters.plConflDiag, // boolean conflDiag, // Resolve diagonal (ood) conflicts
clt_parameters.plConflStar, // boolean conflStar, // Resolve all conflicts around a supertile clt_parameters.plConflStar, // boolean conflStar, // Resolve all conflicts around a supertile
clt_parameters.plStarSteps, // int starSteps, // How far to look around when calculationg connection cost clt_parameters.plStarSteps, // int starSteps, // How far to look around when calculating connection cost
clt_parameters.plStarOrtho, // double orthoWeight, clt_parameters.plStarOrtho, // double orthoWeight,
clt_parameters.plStarDiag, // double diagonalWeight, clt_parameters.plStarDiag, // double diagonalWeight,
clt_parameters.plStarPwr, // double starPwr, // Divide cost by number of connections to this power clt_parameters.plStarPwr, // double starPwr, // Divide cost by number of connections to this power
...@@ -3579,12 +3608,14 @@ public class TileProcessor { ...@@ -3579,12 +3608,14 @@ public class TileProcessor {
clt_parameters.plDispNorm, clt_parameters.plDispNorm,
clt_parameters.plMaxEigen, clt_parameters.plMaxEigen,
clt_parameters.plEigenFloor, // final double eigenFloor, // Add to eigenvalues of each participating plane and result to validate connections
clt_parameters.plMinStrength, clt_parameters.plMinStrength,
0, // final int debugLevel) 0, // final int debugLevel)
clt_parameters.tileX, clt_parameters.tileX,
clt_parameters.tileY); clt_parameters.tileY);
st.selectNeighborPlanesMutual( st.selectNeighborPlanesMutual(
clt_parameters.plEigenFloor, // final double eigenFloor, // Add to eigenvalues of each participating plane and result to validate connections
0, // final int debugLevel) 0, // final int debugLevel)
clt_parameters.tileX, clt_parameters.tileX,
clt_parameters.tileY); clt_parameters.tileY);
...@@ -3600,6 +3631,7 @@ public class TileProcessor { ...@@ -3600,6 +3631,7 @@ public class TileProcessor {
clt_parameters.plStarDiag, // double diagonalWeight, clt_parameters.plStarDiag, // double diagonalWeight,
clt_parameters.plStarPwr, // double starPwr, // Divide cost by number of connections to this power clt_parameters.plStarPwr, // double starPwr, // Divide cost by number of connections to this power
clt_parameters.plStarWeightPwr, // double starWeightPwr, // Use this power of tile weight when calculating connection cost clt_parameters.plStarWeightPwr, // double starWeightPwr, // Use this power of tile weight when calculating connection cost
clt_parameters.plWeightToDens, // double weightToDens, // // Balance weighted density against density. 0.0 - density, 1.0 - weighted density
clt_parameters.plStarValPwr, // double starValPwr, // Raise value of each tile before averaging clt_parameters.plStarValPwr, // double starValPwr, // Raise value of each tile before averaging
clt_parameters.plDblTriLoss, // double diagonalWeight, clt_parameters.plDblTriLoss, // double diagonalWeight,
clt_parameters.plNewConfl, // boolean preferDisparity, // Allow more conflicts if overall cost is reduced clt_parameters.plNewConfl, // boolean preferDisparity, // Allow more conflicts if overall cost is reduced
......
...@@ -180,15 +180,23 @@ public class TwoLayerNeighbors { ...@@ -180,15 +180,23 @@ public class TwoLayerNeighbors {
{ {
if (nl2 < 0) return true; // connection nowhere is always valid; if (nl2 < 0) return true; // connection nowhere is always valid;
int dir8 = (dir1 < 0) ? 8: dir1; int dir8 = (dir1 < 0) ? 8: dir1;
if ((dir8 >= merge_valid.length) || (nl1 >= merge_valid[dir8].length) || (dir12 >= merge_valid[dir8][nl1].length) || (nl2 >= merge_valid[dir8][nl1][dir12].length)) { /*// uncomment to debug
if ( (dir8 >= merge_valid.length) ||
(merge_valid[dir8] == null) ||
(nl1 >= merge_valid[dir8].length) ||
(merge_valid[dir8][nl1] == null) ||
(dir12 >= merge_valid[dir8][nl1].length) ||
(merge_valid[dir8][nl1][dir12] == null) ||
(nl2 >= merge_valid[dir8][nl1][dir12].length)) {
System.out.println("BUG in isValidConn("+dir1+","+dir12+","+nl1+","+nl2+")"); System.out.println("BUG in isValidConn("+dir1+","+dir12+","+nl1+","+nl2+")");
return true; return false;
} }
*/
if ( (merge_valid[dir8][nl1] != null ) && // should not happen
if (merge_valid[dir8][nl1][dir12][nl2]) return true; (merge_valid[dir8][nl1][dir12] != null ) && // can happen
(merge_valid[dir8][nl1][dir12][nl2])) return true;
if (debugLevel > 0){ if (debugLevel > 0){
System.out.println(" -- Fileterd out connection "+dir1+":"+nl1+" in direction "+dir12+" to layer "+nl2); System.out.println(" -- Filterd out connection "+dir1+":"+nl1+" in direction "+dir12+" to layer "+nl2);
} }
return false; return false;
} }
......
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