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

before some refactoring

parent d1be5d00
......@@ -2192,13 +2192,15 @@ public class EyesisCorrectionParameters {
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 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 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
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 plMaxDisp = 0.6; // Maximal disparity of one of the planes to apply maximal ratio
......@@ -2616,8 +2618,9 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"plNeOwn", this.plNeOwn +"");
properties.setProperty(prefix+"plExNeibCost", this.plExNeibCost +"");
properties.setProperty(prefix+"plExNeibCostSngl", this.plExNeibCostSngl +"");
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+"plConflRelax", this.plConflRelax +"");
......@@ -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+"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+"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+"plConflRelax")!=null) this.plConflRelax=Double.parseDouble(properties.getProperty(prefix+"plConflRelax"));
......@@ -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, 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 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("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.addCheckbox ("Try to merge conflicting planes", this.plConflMerge);
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 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.addNumericField("Maximal ratio of Z to allow plane merging", this.plMaxZRatio, 6);
......@@ -3858,8 +3863,9 @@ public class EyesisCorrectionParameters {
this.plNeOwn= gd.getNextNumber();
this.plExNeibCost= gd.getNextNumber();
this.plExNeibCostSngl= gd.getNextNumber();
this.plExNeibSmooth= gd.getNextNumber();
this.plMergeCostStar= gd.getNextNumber();
this.plMergeCost= gd.getNextNumber();
this.plConflMerge= gd.getNextBoolean();
this.plConflRelax= gd.getNextNumber();
......
......@@ -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 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 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 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
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 {
plNeNeibCost = clt_parameters.plNeNeibCost;
plNeOwn = clt_parameters.plNeOwn;
plExNeibCost = clt_parameters.plExNeibCost;
plExNeibCostSngl = clt_parameters.plExNeibCostSngl;
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;
plCostKrq = clt_parameters.plCostKrq;
plCostKrqEq = clt_parameters.plCostKrqEq;
......@@ -135,13 +146,24 @@ public class LinkPlanes {
public double getExNeibCost(){
return plExNeibCost;
}
public double ExNeibCostSngl(){
return plExNeibCostSngl;
public double getMergeCostStar(){
return plMergeCostStar;
}
public double getMergeCostNoStar(){
return plMergeCost;
}
public double getExNeibSmooth(){
return plExNeibSmooth;
}
public double getConflRelax(){
return plConflRelax;
}
public boolean getConflMerge(){
return plConflMerge;
}
public boolean areWeakSimilar(
TilePlanes.PlaneData plane1, // should belong to the same supertile (or be converted for one)
TilePlanes.PlaneData plane2,
......@@ -634,9 +656,11 @@ public class LinkPlanes {
// 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 cost_near = average_disp * average_disp / (average_disp * average_disp + this.plCostDist * this.plCostDist);
double plCostKrq = this.plCostKrq * (1.0 - cost_near);
double plCostKrqEq = this.plCostKrqEq * (1.0 - cost_near);
double cost_near = (this.plCostDist > 0.0) ?
(2.0 * average_disp * average_disp / (average_disp * average_disp + this.plCostDist * this.plCostDist)) :
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 plCostWrqEq = this.plCostWrqEq * cost_near;
......@@ -968,7 +992,7 @@ public class LinkPlanes {
}
ImageDtt.startAndJoin(threads);
}
/*
public void setExclusiveLinks(
final TilePlanes.PlaneData [][] planes,
final int debugLevel,
......@@ -981,7 +1005,8 @@ public class LinkPlanes {
debugLevel,
dbg_X,
dbg_Y);
}
}
*/
public void setExclusiveLinks(
final TilePlanes.PlaneData [][] planes,
final double max_cost,
......@@ -2668,6 +2693,7 @@ public class LinkPlanes {
}
public int [][][] filterPairsByConflicts(
final TilePlanes.PlaneData [][] planes,
final int [][][] merge_candidates,
final int [][][] conflicts)
{
......@@ -2685,6 +2711,20 @@ public class LinkPlanes {
public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
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>();
for (int i = 0; i < merge_candidates[nsTile].length; i++ ){
if (merge_candidates[nsTile][i] != null){
......
......@@ -3309,7 +3309,8 @@ public class TileProcessor {
// Just overwrite results of the previous method
lp.setExclusiveLinks(
st.planes, // final TilePlanes.PlaneData [][] planes,
st.planes, // final TilePlanes.PlaneData [][] planes,
lp.getExNeibCost(), // final double max_cost,
2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
......@@ -3380,8 +3381,10 @@ public class TileProcessor {
// System.out.println("merge_cost_data.length = " + merge_cost_data.length);
lp.costSameTileConnectionsAlt(
5.0, // final double threshold,
10.0, // final double threshold_nostar,
//5.0, // final double threshold,
//10.0, // final double threshold_nostar,
lp.getMergeCostStar(), // relax_for_conflicts * 5.0, // final double threshold, //
lp.getMergeCostNoStar(), //relax_for_conflicts * 10.0, // final double threshold_nostar,
st.planes, // final TilePlanes.PlaneData [][] planes,
merge_candidates, // final int [][][] merge_candidates,
......@@ -3649,7 +3652,8 @@ public class TileProcessor {
//Just overwrite results of the previous method
lp.setExclusiveLinks(
st.planes, // final TilePlanes.PlaneData [][] planes,
st.planes, // final TilePlanes.PlaneData [][] planes,
lp.getExNeibCost(), // final double max_cost,
2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
......@@ -3805,7 +3809,8 @@ public class TileProcessor {
// Just overwrite results of the previous method
lp.setExclusiveLinks(
st.planes, // final TilePlanes.PlaneData [][] planes,
st.planes, // final TilePlanes.PlaneData [][] planes,
lp.getExNeibCost(), // final double max_cost,
2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
......@@ -3854,7 +3859,7 @@ public class TileProcessor {
TilePlanes.PlaneData [][] planes_mod = null;
// smooth planes (by averaging with neighbors and the "measured" one with variable "pull")
double relax_for_conflicts = 1.5;
// double relax_for_conflicts = lp.getConflRelax(); // 1.5;
if (clt_parameters.plIterations > 0) {
for (int num_merge_try = 0; num_merge_try < 10; num_merge_try ++ ) { // smooth and merge
......@@ -3880,7 +3885,8 @@ public class TileProcessor {
clt_parameters.tileY);
lp.setExclusiveLinks(
st.planes_mod, // final TilePlanes.PlaneData [][] planes,
2.5, //final double max_cost
// 2.5, //final double max_cost
lp.getExNeibCost()*lp.getExNeibSmooth(), // final double max_cost,
2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
......@@ -3906,7 +3912,8 @@ public class TileProcessor {
// recalculate links? more smooth?
lp.setExclusiveLinks(
st.planes_mod, // final TilePlanes.PlaneData [][] planes,
2.5, //final double max_cost
// 2.5, //final double max_cost
lp.getExNeibCost()*lp.getExNeibSmooth(), // final double max_cost,
2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
......@@ -3953,15 +3960,16 @@ public class TileProcessor {
1); // final int debugLevel)
int [][][] conflicting_candidates = lp.filterPairsByConflicts(
st.planes_mod, // final TilePlanes.PlaneData [][] planes,
merge_candidates, // final int [][][] merge_candidates,
conflicts0); // final int [][][] conflicts)
conflicts0); // final int [][][] conflicts)
// * Possible problem is that "normalizing" merge quality for low weights is not applicable for "star" plane that include neighhbors
// * Switch to a single "cost" function (costSameTileConnectionsAlt())
// Still - how to merge stray tiles that do not have neighbors/star? Still merge them "old way" (costSameTileConnections()) if at least 1 does not
// have a "star"
lp.costSameTileConnections(
// * Possible problem is that "normalizing" merge quality for low weights is not applicable for "star" plane that include neighhbors
// * Switch to a single "cost" function (costSameTileConnectionsAlt())
// Still - how to merge stray tiles that do not have neighbors/star? Still merge them "old way" (costSameTileConnections()) if at least 1 does not
// have a "star"
lp.costSameTileConnections(
st.planes_mod, // final TilePlanes.PlaneData [][] planes,
merge_candidates, // final int [][][] merge_candidates,
plane_nooverlaps, // final boolean [][][] valid_candidates, // will be updated
......@@ -3969,11 +3977,14 @@ public class TileProcessor {
2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// System.out.println("merge_cost_data.length = " + merge_cost_data.length);
lp.costSameTileConnectionsAlt(
5.0, // final double threshold,
10.0, // final double threshold_nostar,
// System.out.println("merge_cost_data.length = " + merge_cost_data.length);
lp.costSameTileConnectionsAlt(
//5.0, // final double threshold,
//10.0, // final double threshold_nostar,
lp.getMergeCostStar(), // relax_for_conflicts * 5.0, // final double threshold, //
lp.getMergeCostNoStar(), //relax_for_conflicts * 10.0, // final double threshold_nostar,
st.planes_mod, // final TilePlanes.PlaneData [][] planes,
merge_candidates, // final int [][][] merge_candidates,
......@@ -3981,7 +3992,7 @@ public class TileProcessor {
2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
int [][][] merge_groups = lp.extractMergeSameTileGroups(
st.planes_mod, // final TilePlanes.PlaneData [][] planes,
merge_candidates, // final int [][][] merge_candidates,
......@@ -3990,7 +4001,7 @@ public class TileProcessor {
2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
int num_removed_by_merging = st.applyMergePlanes(
st.planes, // final TilePlanes.PlaneData[][] planes,
merge_groups, // final int [][][] merge_groups,
......@@ -4045,23 +4056,23 @@ public class TileProcessor {
// 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
relax_for_conflicts, // final double relax,
2, // -1, // debugLevel, // final int debugLevel)
// 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,
2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// System.out.println("merge_cost_data.length = " + merge_cost_data.length);
lp.costSameTileConnectionsAlt(
// relax_for_conflicts, // final double relax,
relax_for_conflicts * 5.0, // final double threshold, //
relax_for_conflicts * 10.0, // final double threshold_nostar,
// relax_for_conflicts, // final double relax,
lp.getConflRelax() * lp.getMergeCostStar(), // relax_for_conflicts * 5.0, // final double threshold, //
lp.getConflRelax() * lp.getMergeCostNoStar(), //relax_for_conflicts * 10.0, // final double threshold_nostar,
// st.planes_mod, // final TilePlanes.PlaneData [][] planes,
// 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
......@@ -4070,12 +4081,12 @@ public class TileProcessor {
clt_parameters.tileY);
merge_groups = lp.extractMergeSameTileGroups(
// st.planes_mod, // final TilePlanes.PlaneData [][] planes,
st.planes, // final TilePlanes.PlaneData [][] planes,
merge_candidates, // final int [][][] merge_candidates,
plane_nooverlaps, // boolean [][][] plane_overlaps,
relax_for_conflicts, // final double relax,
2, // -1, // debugLevel, // final int debugLevel)
// st.planes_mod, // final TilePlanes.PlaneData [][] planes,
st.planes, // final TilePlanes.PlaneData [][] planes,
conflicting_candidates, // final int [][][] merge_candidates,
plane_nooverlaps, // boolean [][][] plane_overlaps,
lp.getConflRelax(), // relax_for_conflicts, // final double relax,
2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
......@@ -4100,7 +4111,7 @@ public class TileProcessor {
break;
}
}
// Do the same as in conditionSuperTiles before smoothing again
......@@ -4143,7 +4154,8 @@ public class TileProcessor {
// Just overwrite results of the previous method
lp.setExclusiveLinks(
st.planes, // final TilePlanes.PlaneData [][] planes,
2.5, //final double max_cost
// 2.5, //final double max_cost
lp.getExNeibCost()*lp.getExNeibSmooth(), // final double max_cost,
2, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
......
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