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

debugging planes merging

parent 1361f670
...@@ -2149,6 +2149,7 @@ public class EyesisCorrectionParameters { ...@@ -2149,6 +2149,7 @@ public class EyesisCorrectionParameters {
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.3; // Maximal eigenvalue of a plane
public boolean plDbgMerge = true; // Combine 'other' plane with current
// other debug images // other debug images
public boolean show_ortho_combine = false; // Show 'ortho_combine' public boolean show_ortho_combine = false; // Show 'ortho_combine'
...@@ -2389,6 +2390,7 @@ public class EyesisCorrectionParameters { ...@@ -2389,6 +2390,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+"plDbgMerge", this.plDbgMerge+"");
properties.setProperty(prefix+"show_ortho_combine", this.show_ortho_combine+""); properties.setProperty(prefix+"show_ortho_combine", this.show_ortho_combine+"");
properties.setProperty(prefix+"show_refine_supertiles", this.show_refine_supertiles+""); properties.setProperty(prefix+"show_refine_supertiles", this.show_refine_supertiles+"");
...@@ -2620,6 +2622,7 @@ public class EyesisCorrectionParameters { ...@@ -2620,6 +2622,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+"plDbgMerge")!=null) this.plDbgMerge=Boolean.parseBoolean(properties.getProperty(prefix+"plDbgMerge"));
if (properties.getProperty(prefix+"show_ortho_combine")!=null) this.show_ortho_combine=Boolean.parseBoolean(properties.getProperty(prefix+"show_ortho_combine")); if (properties.getProperty(prefix+"show_ortho_combine")!=null) this.show_ortho_combine=Boolean.parseBoolean(properties.getProperty(prefix+"show_ortho_combine"));
if (properties.getProperty(prefix+"show_refine_supertiles")!=null) this.show_refine_supertiles=Boolean.parseBoolean(properties.getProperty(prefix+"show_refine_supertiles")); if (properties.getProperty(prefix+"show_refine_supertiles")!=null) this.show_refine_supertiles=Boolean.parseBoolean(properties.getProperty(prefix+"show_refine_supertiles"));
...@@ -2873,6 +2876,7 @@ public class EyesisCorrectionParameters { ...@@ -2873,6 +2876,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.addCheckbox ("Combine 'other' plane with the current", this.plDbgMerge);
gd.addMessage ("--- Other debug images ---"); gd.addMessage ("--- Other debug images ---");
gd.addCheckbox ("Show 'ortho_combine'", this.show_ortho_combine); gd.addCheckbox ("Show 'ortho_combine'", this.show_ortho_combine);
...@@ -3113,6 +3117,7 @@ public class EyesisCorrectionParameters { ...@@ -3113,6 +3117,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.plDbgMerge= gd.getNextBoolean();
this.show_ortho_combine= gd.getNextBoolean(); this.show_ortho_combine= gd.getNextBoolean();
this.show_refine_supertiles= gd.getNextBoolean(); this.show_refine_supertiles= gd.getNextBoolean();
......
...@@ -1067,7 +1067,7 @@ public class SuperTiles{ ...@@ -1067,7 +1067,7 @@ public class SuperTiles{
// final int debug_stile = 18 * stilesX + 25; // final int debug_stile = 18 * stilesX + 25;
// final int debug_stile = 20 * stilesX + 24; // final int debug_stile = 20 * stilesX + 24;
final int debug_stile = 17 * stilesX + 10; final int debug_stile = 16 * stilesX + 27; // 10;
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
...@@ -1121,10 +1121,11 @@ public class SuperTiles{ ...@@ -1121,10 +1121,11 @@ public class SuperTiles{
// int dl = ((nsTile >= debug_stile-1) && (nsTile <= debug_stile+1) ) ? 1 : 0; // int dl = ((nsTile >= debug_stile-1) && (nsTile <= debug_stile+1) ) ? 1 : 0;
// int dl = ((stileY == 17) && (stileX > 4)) ? 1 : 0; // int dl = ((stileY == 17) && (stileX > 4)) ? 1 : 0;
// int dl = (stileY >= 0) ? 1 : 0; // int dl = (stileY >= 0) ? 1 : 0;
int dl1 = (nsTile == debug_stile-1) ? 3 : 0; int dl1 = (nsTile == debug_stile) ? 3 : 0;
// int dl = (nsTile == debug_stile) ? 3 : 0; // int dl = (nsTile == debug_stile) ? 3 : 0;
int dl = ((stileY >= 15) && (stileY <= 18) && (stileX >= 5) && (stileX <= 31)) ? 1 : 0; // int dl = ((stileY >= 15) && (stileY <= 18) && (stileX >= 5) && (stileX <= 31)) ? 1 : 0;
// int dl = ((stileY == 17) && (stileX == 27) ) ? 3 : 0; int dl = ((stileY == 16) && (stileX == 27) ) ? 3 : 0;
// int debugLevel1 = ((sTileXY[0] == 27) && (sTileXY[1] == 16))? 1: 0; // check why v[0][0] <0
boolean [] sel_all = stSel.clone(); boolean [] sel_all = stSel.clone();
...@@ -1301,6 +1302,9 @@ public class SuperTiles{ ...@@ -1301,6 +1302,9 @@ public class SuperTiles{
} }
if (st_planes.size() > 0){ if (st_planes.size() > 0){
planes[nsTile] = st_planes.toArray(new TilePlanes.PlaneData[0] ); planes[nsTile] = st_planes.toArray(new TilePlanes.PlaneData[0] );
if (dl >0){
System.out.println("processPlanes2(): nsTile="+nsTile);
}
} }
} // if sw >0 } // if sw >0
...@@ -1325,13 +1329,9 @@ public class SuperTiles{ ...@@ -1325,13 +1329,9 @@ public class SuperTiles{
return wh; return wh;
} }
// public double [][]
TilePlanes.PlaneData [][] getNeibPlanes( TilePlanes.PlaneData [][] getNeibPlanes(
final int dir // 0: get from up (N), 1:from NE, ... 7 - from NW final int dir, // 0: get from up (N), 1:from NE, ... 7 - from NW
// final double minWeight, final boolean dbgMerge // Combine 'other' plane with current
// final double maxEigen,
// final double dispNorm,
// final boolean use_NaN
) )
{ {
final int tilesX = tileProcessor.getTilesX(); final int tilesX = tileProcessor.getTilesX();
...@@ -1340,16 +1340,13 @@ public class SuperTiles{ ...@@ -1340,16 +1340,13 @@ public class SuperTiles{
final int tileSize = tileProcessor.getTileSize(); final int tileSize = tileProcessor.getTileSize();
final int stilesX = (tilesX + superTileSize -1)/superTileSize; final int stilesX = (tilesX + superTileSize -1)/superTileSize;
final int stilesY = (tilesY + superTileSize -1)/superTileSize; final int stilesY = (tilesY + superTileSize -1)/superTileSize;
// final int width = stilesX * superTileSize; // * tileSize;
// final int height = stilesY * superTileSize; // * tileSize;
final double [] nan_plane = new double [superTileSize*superTileSize]; final double [] nan_plane = new double [superTileSize*superTileSize];
for (int i = 0; i < nan_plane.length; i++) nan_plane[i] = Double.NaN; for (int i = 0; i < nan_plane.length; i++) nan_plane[i] = Double.NaN;
// final int centerIndex = (superTileSize+1) * superTileSize / 2;
final int [][] dirsYX = {{-1, 0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1}}; final int [][] dirsYX = {{-1, 0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1}};
TilePlanes.PlaneData [][] neib_planes = new TilePlanes.PlaneData[stilesY * stilesX][]; TilePlanes.PlaneData [][] neib_planes = new TilePlanes.PlaneData[stilesY * stilesX][];
TilePlanes tpl = null; // new TilePlanes(tileSize,superTileSize, geometryCorrection); TilePlanes tpl = null; // new TilePlanes(tileSize,superTileSize, geometryCorrection);
// final int debug_stile = 17 * stilesX + 27; // final int debug_stile = 20 * stilesX + 27;
final int debug_stile = 20 * stilesX + 27; final int debug_stile = 17 * stilesX + 27;
for (int sty0 = 0; sty0 < stilesY; sty0++){ for (int sty0 = 0; sty0 < stilesY; sty0++){
int sty = sty0 + dirsYX[dir][0]; int sty = sty0 + dirsYX[dir][0];
...@@ -1377,9 +1374,55 @@ public class SuperTiles{ ...@@ -1377,9 +1374,55 @@ public class SuperTiles{
if (nsTile0 == debug_stile) { if (nsTile0 == debug_stile) {
System.out.println("getNeibPlanes(): nsTile0="+nsTile0+", nsTile="+nsTile+", np = "+np+" dir = "+ dir ); System.out.println("getNeibPlanes(): nsTile0="+nsTile0+", nsTile="+nsTile+", np = "+np+" dir = "+ dir );
} }
neib_planes[nsTile0][np] = pd.getPlaneToThis( TilePlanes.PlaneData other_pd = pd.getPlaneToThis(
planes[nsTile][np], // PlaneData otherPd, planes[nsTile][np], // PlaneData otherPd,
(nsTile0 == debug_stile)? 1:0); // int debugLevel) (nsTile0 == debug_stile)? 1:0); // int debugLevel)
int num_this = (planes[nsTile0] == null)? 0:(planes[nsTile0].length);
int best_index = 0;
if (dbgMerge && (num_this > 0)) {
double best_value = Double.NaN;
if (num_this > 1){
// find the best candidate for merge
for (int indx = 1; indx < planes[nsTile0].length; indx++){
if (nsTile0 == debug_stile) {
System.out.println("this with this, same weight:");
TilePlanes.PlaneData this_this_pd = planes[nsTile0][indx].mergePlaneToThis(
planes[nsTile0][indx], // PlaneData otherPd,
1.0, // double scale_other,
true, // boolean ignore_weights,
(nsTile0 == debug_stile)? 1:0); // int debugLevel)
System.out.println("other with other, same weight:");
TilePlanes.PlaneData other_other_pd = other_pd.mergePlaneToThis(
other_pd, // PlaneData otherPd,
1.0, // double scale_other,
true, // boolean ignore_weights,
(nsTile0 == debug_stile)? 1:0); // int debugLevel)
System.out.println("other with this, same weight:");
}
TilePlanes.PlaneData merged_pd = planes[nsTile0][indx].mergePlaneToThis(
other_pd, // PlaneData otherPd,
1.0, // double scale_other,
true, // boolean ignore_weights,
(nsTile0 == debug_stile)? 1:0); // int debugLevel)
if (!(merged_pd.getValue() > best_value)) { // Double.isNaN(best_value) will work too
best_value = merged_pd.getValue();
best_index = indx;
}
}
}
// now merge with weights with the best plane of this supertile
if (nsTile0 == debug_stile) {
System.out.println("this with this, proportional weight, np(other):"+np+" best fit(this):"+best_index);
}
TilePlanes.PlaneData merged_pd = planes[nsTile0][best_index].mergePlaneToThis(
other_pd, // PlaneData otherPd,
1.0, // double scale_other,
false, // boolean ignore_weights,
(nsTile0 == debug_stile)? 1:0); // int debugLevel)
neib_planes[nsTile0][np] = merged_pd;
} else {
neib_planes[nsTile0][np] = other_pd;
}
} }
} else { } else {
neib_planes[nsTile0] = null; neib_planes[nsTile0] = null;
......
This diff is collapsed.
...@@ -3000,7 +3000,9 @@ public class TileProcessor { ...@@ -3000,7 +3000,9 @@ public class TileProcessor {
sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "plane_data"); sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "plane_data");
// show plane data // show plane data
for (int dr = 0; dr < 8; dr++){ for (int dr = 0; dr < 8; dr++){
TilePlanes.PlaneData [][] planes = st.getNeibPlanes(dr); TilePlanes.PlaneData [][] planes = st.getNeibPlanes(
dr,
clt_parameters.plDbgMerge);
plane_data_nonan = st.getShowPlanes( plane_data_nonan = st.getShowPlanes(
planes, planes,
clt_parameters.plMinStrength, // minWeight, clt_parameters.plMinStrength, // minWeight,
......
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