Commit 9b8a5082 authored by Andrey Filippov's avatar Andrey Filippov

before some refactoring

parent d1be5d00
...@@ -2192,13 +2192,15 @@ public class EyesisCorrectionParameters { ...@@ -2192,13 +2192,15 @@ public class EyesisCorrectionParameters {
public double plNeOwn = 5.0; // When calculating non-exclusive planes, use center plane relative weight public double plNeOwn = 5.0; // When calculating non-exclusive planes, use center plane relative weight
public double plExNeibCost = 5.0; // When calculating exclusive planes links, do not use neighbors with high cost public double plExNeibCost = 5.0; // When calculating exclusive planes links, do not use neighbors with high cost
public double plExNeibCostSngl = 10.0; // When calculating exclusive planes links, do not use no-link neighbors with high cost // public double plExNeibCostSngl = 10.0; // When calculating exclusive planes links, do not use no-link neighbors with high cost
public double plExNeibSmooth = 0.5; // Scale down maximal costs for smoothed planes (tighter requirements) public double plExNeibSmooth = 0.5; // Scale down maximal costs for smoothed planes (tighter requirements)
public double plMergeCostStar = 5.0; // Cost threshold for merging same tile planes if the plane has connected neighbors
public double plMergeCost = 10.0; // Cost threshold for merging same tile planes if not connected
public boolean plConflMerge = true; // Try to merge conflicting planes public boolean plConflMerge = true; // Try to merge conflicting planes
public double plConflRelax = 1.5; // Scale parameters to relax planes fit for merging conflicting planes public double plConflRelax = 1.5; // Scale parameters to relax planes fit for merging conflicting planes
public boolean plConflSngl = true; // Only merge conflicting planes if this is the only conflicting pair in the supertile public boolean plConflSngl = true; // Only merge conflicting planes if this is the only conflicting pair in the supertile
public boolean plConflSnglPair = true; // Only merge conflicting planes only if there are only two planes in the supertile public boolean plConflSnglPair = true; // Only merge conflicting planes only if there are just two planes in the supertile
public double plMaxZRatio = 2.0; // Maximal ratio of Z to allow plane merging public double plMaxZRatio = 2.0; // Maximal ratio of Z to allow plane merging
public double plMaxDisp = 0.6; // Maximal disparity of one of the planes to apply maximal ratio public double plMaxDisp = 0.6; // Maximal disparity of one of the planes to apply maximal ratio
...@@ -2616,8 +2618,9 @@ public class EyesisCorrectionParameters { ...@@ -2616,8 +2618,9 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"plNeOwn", this.plNeOwn +""); properties.setProperty(prefix+"plNeOwn", this.plNeOwn +"");
properties.setProperty(prefix+"plExNeibCost", this.plExNeibCost +""); properties.setProperty(prefix+"plExNeibCost", this.plExNeibCost +"");
properties.setProperty(prefix+"plExNeibCostSngl", this.plExNeibCostSngl +"");
properties.setProperty(prefix+"plExNeibSmooth", this.plExNeibSmooth +""); properties.setProperty(prefix+"plExNeibSmooth", this.plExNeibSmooth +"");
properties.setProperty(prefix+"plMergeCostStar", this.plMergeCostStar +"");
properties.setProperty(prefix+"plMergeCost", this.plMergeCost +"");
properties.setProperty(prefix+"plConflMerge", this.plConflMerge+""); properties.setProperty(prefix+"plConflMerge", this.plConflMerge+"");
properties.setProperty(prefix+"plConflRelax", this.plConflRelax +""); properties.setProperty(prefix+"plConflRelax", this.plConflRelax +"");
...@@ -3015,8 +3018,9 @@ public class EyesisCorrectionParameters { ...@@ -3015,8 +3018,9 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"plNeOwn")!=null) this.plNeOwn=Double.parseDouble(properties.getProperty(prefix+"plNeOwn")); if (properties.getProperty(prefix+"plNeOwn")!=null) this.plNeOwn=Double.parseDouble(properties.getProperty(prefix+"plNeOwn"));
if (properties.getProperty(prefix+"plExNeibCost")!=null) this.plExNeibCost=Double.parseDouble(properties.getProperty(prefix+"plExNeibCost")); if (properties.getProperty(prefix+"plExNeibCost")!=null) this.plExNeibCost=Double.parseDouble(properties.getProperty(prefix+"plExNeibCost"));
if (properties.getProperty(prefix+"plExNeibCostSngl")!=null) this.plExNeibCostSngl=Double.parseDouble(properties.getProperty(prefix+"plExNeibCostSngl"));
if (properties.getProperty(prefix+"plExNeibSmooth")!=null) this.plExNeibSmooth=Double.parseDouble(properties.getProperty(prefix+"plExNeibSmooth")); if (properties.getProperty(prefix+"plExNeibSmooth")!=null) this.plExNeibSmooth=Double.parseDouble(properties.getProperty(prefix+"plExNeibSmooth"));
if (properties.getProperty(prefix+"plMergeCostStar")!=null) this.plMergeCostStar=Double.parseDouble(properties.getProperty(prefix+"plMergeCostStar"));
if (properties.getProperty(prefix+"plMergeCost")!=null) this.plMergeCost=Double.parseDouble(properties.getProperty(prefix+"plMergeCost"));
if (properties.getProperty(prefix+"plConflMerge")!=null) this.plConflMerge=Boolean.parseBoolean(properties.getProperty(prefix+"plConflMerge")); if (properties.getProperty(prefix+"plConflMerge")!=null) this.plConflMerge=Boolean.parseBoolean(properties.getProperty(prefix+"plConflMerge"));
if (properties.getProperty(prefix+"plConflRelax")!=null) this.plConflRelax=Double.parseDouble(properties.getProperty(prefix+"plConflRelax")); if (properties.getProperty(prefix+"plConflRelax")!=null) this.plConflRelax=Double.parseDouble(properties.getProperty(prefix+"plConflRelax"));
...@@ -3442,14 +3446,15 @@ public class EyesisCorrectionParameters { ...@@ -3442,14 +3446,15 @@ public class EyesisCorrectionParameters {
gd.addNumericField("When calculating non-exclusive planes, do not use neighbors with high cost", this.plNeNeibCost, 6); gd.addNumericField("When calculating non-exclusive planes, do not use neighbors with high cost", this.plNeNeibCost, 6);
gd.addNumericField("When calculating non-exclusive planes, use cenrter plane relative weight", this.plNeOwn, 6); gd.addNumericField("When calculating non-exclusive planes, use cenrter plane relative weight", this.plNeOwn, 6);
gd.addNumericField("When calculating exclusive planes links, do not use neighbors with high cost", this.plExNeibCost, 6); gd.addNumericField("When calculating exclusive planes links, do not use neighbors with high cost", this.plExNeibCost, 6);
gd.addNumericField("When calculating exclusive planes links, do not use no-link neighbors with high cost", this.plExNeibCostSngl, 6);
gd.addNumericField("Scale down maximal costs for smoothed planes links (tighter requirements)", this.plExNeibSmooth, 6); gd.addNumericField("Scale down maximal costs for smoothed planes links (tighter requirements)", this.plExNeibSmooth, 6);
gd.addNumericField("Cost threshold for merging same tile planes if the plane has connected neighbors", this.plMergeCostStar, 6);
gd.addNumericField("Cost threshold for merging same tile planes if not connected", this.plMergeCost, 6);
gd.addMessage ("--- Merging planes with topological conflicts ---"); gd.addMessage ("--- Merging planes with topological conflicts ---");
gd.addCheckbox ("Try to merge conflicting planes", this.plConflMerge); gd.addCheckbox ("Try to merge conflicting planes", this.plConflMerge);
gd.addNumericField("Scale parameters to relax planes fit for merging conflicting planes", this.plConflRelax, 6); gd.addNumericField("Scale parameters to relax planes fit for merging conflicting planes", this.plConflRelax, 6);
gd.addCheckbox ("Only merge conflicting planes if this is the only conflicting pair in the supertile",this.plConflSngl); gd.addCheckbox ("Only merge conflicting planes if this is the only conflicting pair in the supertile",this.plConflSngl);
gd.addCheckbox ("Only merge conflicting planes only if there are only two planes in the supertile", this.plConflSnglPair); gd.addCheckbox ("Only merge conflicting planes only if there are just two planes in the supertile", this.plConflSnglPair);
gd.addMessage ("--- ---"); gd.addMessage ("--- ---");
gd.addNumericField("Maximal ratio of Z to allow plane merging", this.plMaxZRatio, 6); gd.addNumericField("Maximal ratio of Z to allow plane merging", this.plMaxZRatio, 6);
...@@ -3858,8 +3863,9 @@ public class EyesisCorrectionParameters { ...@@ -3858,8 +3863,9 @@ public class EyesisCorrectionParameters {
this.plNeOwn= gd.getNextNumber(); this.plNeOwn= gd.getNextNumber();
this.plExNeibCost= gd.getNextNumber(); this.plExNeibCost= gd.getNextNumber();
this.plExNeibCostSngl= gd.getNextNumber();
this.plExNeibSmooth= gd.getNextNumber(); this.plExNeibSmooth= gd.getNextNumber();
this.plMergeCostStar= gd.getNextNumber();
this.plMergeCost= gd.getNextNumber();
this.plConflMerge= gd.getNextBoolean(); this.plConflMerge= gd.getNextBoolean();
this.plConflRelax= gd.getNextNumber(); this.plConflRelax= gd.getNextNumber();
......
...@@ -58,9 +58,14 @@ public class LinkPlanes { ...@@ -58,9 +58,14 @@ public class LinkPlanes {
public double plNeNeibCost; // = 5.0; // When calculating non-exclusive planes, do not use neighbors with high cost public double plNeNeibCost; // = 5.0; // When calculating non-exclusive planes, do not use neighbors with high cost
public double plNeOwn; // = 5.0; // When calculating non-exclusive planes, use center plane relative weight public double plNeOwn; // = 5.0; // When calculating non-exclusive planes, use center plane relative weight
public double plExNeibCost; // = 5.0; // When calculating non-exclusive planes, do not use neighbors with high cost public double plExNeibCost; // = 5.0; // When calculating non-exclusive planes, do not use neighbors with high cost
public double plExNeibCostSngl; // = 10.0; // When calculating exclusive planes links, do not use no-link neighbors with high cost
public double plExNeibSmooth; // = 0.5; // Scale down maximal costs for smoothed planes (tighter requirements) public double plExNeibSmooth; // = 0.5; // Scale down maximal costs for smoothed planes (tighter requirements)
public double plMergeCostStar; // = 5.0; // Cost threshold for merging same tile planes if the plane has connected neighbors
public double plMergeCost; // = 10.0; // Cost threshold for merging same tile planes if not connected
public boolean plConflMerge; // = true; // Try to merge conflicting planes
public double plConflRelax; // = 1.5; // Scale parameters to relax planes fit for merging conflicting planes
public boolean plConflSngl; // = true; // Only merge conflicting planes if this is the only conflicting pair in the supertile
public boolean plConflSnglPair; // = true; // Only merge conflicting planes only if there are only two planes in the supertile
// comparing merge quality for plane pairs // comparing merge quality for plane pairs
public double plCostDist; // = 4.0; // Disparity (pix) - closer cost will use more of the real world, farther - disparity public double plCostDist; // = 4.0; // Disparity (pix) - closer cost will use more of the real world, farther - disparity
...@@ -111,9 +116,15 @@ public class LinkPlanes { ...@@ -111,9 +116,15 @@ public class LinkPlanes {
plNeNeibCost = clt_parameters.plNeNeibCost; plNeNeibCost = clt_parameters.plNeNeibCost;
plNeOwn = clt_parameters.plNeOwn; plNeOwn = clt_parameters.plNeOwn;
plExNeibCost = clt_parameters.plExNeibCost; plExNeibCost = clt_parameters.plExNeibCost;
plExNeibCostSngl = clt_parameters.plExNeibCostSngl;
plExNeibSmooth = clt_parameters.plExNeibSmooth; plExNeibSmooth = clt_parameters.plExNeibSmooth;
plMergeCostStar = clt_parameters.plMergeCostStar;
plMergeCost = clt_parameters.plMergeCost;
plConflMerge = clt_parameters.plConflMerge;
plConflRelax = clt_parameters.plConflRelax;
plConflSngl = clt_parameters.plConflSngl;
plConflSnglPair = clt_parameters.plConflSnglPair;
plCostDist = clt_parameters.plCostDist; plCostDist = clt_parameters.plCostDist;
plCostKrq = clt_parameters.plCostKrq; plCostKrq = clt_parameters.plCostKrq;
plCostKrqEq = clt_parameters.plCostKrqEq; plCostKrqEq = clt_parameters.plCostKrqEq;
...@@ -135,13 +146,24 @@ public class LinkPlanes { ...@@ -135,13 +146,24 @@ public class LinkPlanes {
public double getExNeibCost(){ public double getExNeibCost(){
return plExNeibCost; return plExNeibCost;
} }
public double ExNeibCostSngl(){ public double getMergeCostStar(){
return plExNeibCostSngl; return plMergeCostStar;
}
public double getMergeCostNoStar(){
return plMergeCost;
} }
public double getExNeibSmooth(){ public double getExNeibSmooth(){
return plExNeibSmooth; return plExNeibSmooth;
} }
public double getConflRelax(){
return plConflRelax;
}
public boolean getConflMerge(){
return plConflMerge;
}
public boolean areWeakSimilar( public boolean areWeakSimilar(
TilePlanes.PlaneData plane1, // should belong to the same supertile (or be converted for one) TilePlanes.PlaneData plane1, // should belong to the same supertile (or be converted for one)
TilePlanes.PlaneData plane2, TilePlanes.PlaneData plane2,
...@@ -634,9 +656,11 @@ public class LinkPlanes { ...@@ -634,9 +656,11 @@ public class LinkPlanes {
// reduce cost contribution for disparity space parameters for near objects, increase - for far // reduce cost contribution for disparity space parameters for near objects, increase - for far
double average_disp = 0.5 * (plane1.getZxy()[0] + plane2.getZxy()[0]); double average_disp = 0.5 * (plane1.getZxy()[0] + plane2.getZxy()[0]);
double cost_near = average_disp * average_disp / (average_disp * average_disp + this.plCostDist * this.plCostDist); double cost_near = (this.plCostDist > 0.0) ?
double plCostKrq = this.plCostKrq * (1.0 - cost_near); (2.0 * average_disp * average_disp / (average_disp * average_disp + this.plCostDist * this.plCostDist)) :
double plCostKrqEq = this.plCostKrqEq * (1.0 - cost_near); 1.0;
double plCostKrq = this.plCostKrq * (2.0 - cost_near);
double plCostKrqEq = this.plCostKrqEq * (2.0 - cost_near);
double plCostWrq = this.plCostWrq * cost_near; double plCostWrq = this.plCostWrq * cost_near;
double plCostWrqEq = this.plCostWrqEq * cost_near; double plCostWrqEq = this.plCostWrqEq * cost_near;
...@@ -968,7 +992,7 @@ public class LinkPlanes { ...@@ -968,7 +992,7 @@ public class LinkPlanes {
} }
ImageDtt.startAndJoin(threads); ImageDtt.startAndJoin(threads);
} }
/*
public void setExclusiveLinks( public void setExclusiveLinks(
final TilePlanes.PlaneData [][] planes, final TilePlanes.PlaneData [][] planes,
final int debugLevel, final int debugLevel,
...@@ -981,7 +1005,8 @@ public class LinkPlanes { ...@@ -981,7 +1005,8 @@ public class LinkPlanes {
debugLevel, debugLevel,
dbg_X, dbg_X,
dbg_Y); dbg_Y);
} }
*/
public void setExclusiveLinks( public void setExclusiveLinks(
final TilePlanes.PlaneData [][] planes, final TilePlanes.PlaneData [][] planes,
final double max_cost, final double max_cost,
...@@ -2668,6 +2693,7 @@ public class LinkPlanes { ...@@ -2668,6 +2693,7 @@ public class LinkPlanes {
} }
public int [][][] filterPairsByConflicts( public int [][][] filterPairsByConflicts(
final TilePlanes.PlaneData [][] planes,
final int [][][] merge_candidates, final int [][][] merge_candidates,
final int [][][] conflicts) final int [][][] conflicts)
{ {
...@@ -2685,6 +2711,20 @@ public class LinkPlanes { ...@@ -2685,6 +2711,20 @@ public class LinkPlanes {
public void run() { public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) { for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
if ((merge_candidates[nsTile] != null) && (conflicts[nsTile] != null)) { if ((merge_candidates[nsTile] != null) && (conflicts[nsTile] != null)) {
if (plConflSnglPair){
int num_planes = 0;
for (int i = 0; i < planes[nsTile].length; i++){
if (planes[nsTile][i] != null) num_planes++;
}
if (num_planes > 2) {
continue;
}
}
if (plConflSngl && (conflicts[nsTile].length > 1)){
continue;
}
// TODO: maybe additionally check link costs correlation
HashSet<Point> pairs_set = new HashSet<Point>(); HashSet<Point> pairs_set = new HashSet<Point>();
for (int i = 0; i < merge_candidates[nsTile].length; i++ ){ for (int i = 0; i < merge_candidates[nsTile].length; i++ ){
if (merge_candidates[nsTile][i] != null){ if (merge_candidates[nsTile][i] != null){
......
This diff is collapsed.
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