Loading src/main/java/EyesisCorrectionParameters.java +12 −2 Original line number Original line Diff line number Diff line Loading @@ -2142,6 +2142,7 @@ public class EyesisCorrectionParameters { public double grow_disp_step = 6.0; // Increase disparity (from maximal tried) if nothing found in that tile // TODO: handle enclosed dips? public double grow_disp_step = 6.0; // Increase disparity (from maximal tried) if nothing found in that tile // TODO: handle enclosed dips? public double grow_min_diff = 0.5; // Grow more only if at least one channel has higher variance from others for the tile public double grow_min_diff = 0.5; // Grow more only if at least one channel has higher variance from others for the tile public boolean plPreferDisparity = false;// Always start with disparity-most axis (false - lowest eigenvalue) public double plDispNorm = 3.0; // Normalize disparities to the average if above (now only for eigenvalue comparison) public double plDispNorm = 3.0; // Normalize disparities to the average if above (now only for eigenvalue comparison) public int plMinPoints = 5; // Minimal number of points for plane detection public int plMinPoints = 5; // Minimal number of points for plane detection public double plTargetEigen = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below public double plTargetEigen = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below Loading @@ -2150,7 +2151,8 @@ public class EyesisCorrectionParameters { 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 public boolean plDbgMerge = true; // Combine 'other' plane with current public double plWorstWorsening = 1.0; // Worst case worsening after merge public double plWorstWorsening = 3.0; // Worst case worsening after merge public double plWeakWorsening = 1.0; // Relax merge requirements for weaker planes public boolean plMutualOnly = true; // keep only mutual links, remove weakest if conflict public boolean plMutualOnly = true; // keep only mutual links, remove weakest if conflict public boolean plFillSquares = true; // Add diagonals to full squares public boolean plFillSquares = true; // Add diagonals to full squares public boolean plCutCorners = true; // Add ortho to 45-degree corners public boolean plCutCorners = true; // Add ortho to 45-degree corners Loading Loading @@ -2406,6 +2408,7 @@ public class EyesisCorrectionParameters { properties.setProperty(prefix+"grow_disp_step", this.grow_disp_step +""); properties.setProperty(prefix+"grow_disp_step", this.grow_disp_step +""); properties.setProperty(prefix+"grow_min_diff", this.grow_min_diff +""); properties.setProperty(prefix+"grow_min_diff", this.grow_min_diff +""); properties.setProperty(prefix+"plPreferDisparity",this.plPreferDisparity+""); properties.setProperty(prefix+"plDispNorm", this.plDispNorm +""); properties.setProperty(prefix+"plDispNorm", this.plDispNorm +""); properties.setProperty(prefix+"plMinPoints", this.plMinPoints+""); properties.setProperty(prefix+"plMinPoints", this.plMinPoints+""); properties.setProperty(prefix+"plTargetEigen", this.plTargetEigen +""); properties.setProperty(prefix+"plTargetEigen", this.plTargetEigen +""); Loading @@ -2415,6 +2418,7 @@ public class EyesisCorrectionParameters { properties.setProperty(prefix+"plMaxEigen", this.plMaxEigen +""); properties.setProperty(prefix+"plMaxEigen", this.plMaxEigen +""); 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+"plWeakWorsening", this.plWeakWorsening +""); properties.setProperty(prefix+"plMutualOnly", this.plMutualOnly+""); properties.setProperty(prefix+"plMutualOnly", this.plMutualOnly+""); properties.setProperty(prefix+"plFillSquares", this.plFillSquares+""); properties.setProperty(prefix+"plFillSquares", this.plFillSquares+""); Loading Loading @@ -2657,6 +2661,7 @@ public class EyesisCorrectionParameters { if (properties.getProperty(prefix+"grow_disp_step")!=null) this.grow_disp_step=Double.parseDouble(properties.getProperty(prefix+"grow_disp_step")); if (properties.getProperty(prefix+"grow_disp_step")!=null) this.grow_disp_step=Double.parseDouble(properties.getProperty(prefix+"grow_disp_step")); if (properties.getProperty(prefix+"grow_min_diff")!=null) this.grow_min_diff=Double.parseDouble(properties.getProperty(prefix+"grow_min_diff")); if (properties.getProperty(prefix+"grow_min_diff")!=null) this.grow_min_diff=Double.parseDouble(properties.getProperty(prefix+"grow_min_diff")); if (properties.getProperty(prefix+"plPreferDisparity")!=null) this.plPreferDisparity=Boolean.parseBoolean(properties.getProperty(prefix+"plPreferDisparity")); if (properties.getProperty(prefix+"plDispNorm")!=null) this.plDispNorm=Double.parseDouble(properties.getProperty(prefix+"plDispNorm")); if (properties.getProperty(prefix+"plDispNorm")!=null) this.plDispNorm=Double.parseDouble(properties.getProperty(prefix+"plDispNorm")); if (properties.getProperty(prefix+"plMinPoints")!=null) this.plMinPoints=Integer.parseInt(properties.getProperty(prefix+"plMinPoints")); if (properties.getProperty(prefix+"plMinPoints")!=null) this.plMinPoints=Integer.parseInt(properties.getProperty(prefix+"plMinPoints")); if (properties.getProperty(prefix+"plTargetEigen")!=null) this.plTargetEigen=Double.parseDouble(properties.getProperty(prefix+"plTargetEigen")); if (properties.getProperty(prefix+"plTargetEigen")!=null) this.plTargetEigen=Double.parseDouble(properties.getProperty(prefix+"plTargetEigen")); Loading @@ -2666,6 +2671,7 @@ public class EyesisCorrectionParameters { 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+"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+"plWeakWorsening")!=null) this.plWeakWorsening=Double.parseDouble(properties.getProperty(prefix+"plWeakWorsening")); if (properties.getProperty(prefix+"plMutualOnly")!=null) this.plMutualOnly=Boolean.parseBoolean(properties.getProperty(prefix+"plMutualOnly")); if (properties.getProperty(prefix+"plMutualOnly")!=null) this.plMutualOnly=Boolean.parseBoolean(properties.getProperty(prefix+"plMutualOnly")); if (properties.getProperty(prefix+"plFillSquares")!=null) this.plFillSquares=Boolean.parseBoolean(properties.getProperty(prefix+"plFillSquares")); if (properties.getProperty(prefix+"plFillSquares")!=null) this.plFillSquares=Boolean.parseBoolean(properties.getProperty(prefix+"plFillSquares")); Loading Loading @@ -2930,6 +2936,7 @@ public class EyesisCorrectionParameters { gd.addNumericField("Increase disparity (from maximal tried) if nothing found in that tile", this.grow_disp_step, 6); gd.addNumericField("Increase disparity (from maximal tried) if nothing found in that tile", this.grow_disp_step, 6); gd.addNumericField("Grow more only if at least one channel has higher variance from others for the tile", this.grow_min_diff, 6); gd.addNumericField("Grow more only if at least one channel has higher variance from others for the tile", this.grow_min_diff, 6); gd.addMessage ("--- Planes detection ---"); gd.addMessage ("--- Planes detection ---"); gd.addCheckbox ("Always start with disparity-most axis (false - lowest eigenvalue)", this.plPreferDisparity); gd.addNumericField("Normalize disparities to the average if above", this.plDispNorm, 6); gd.addNumericField("Normalize disparities to the average if above", this.plDispNorm, 6); gd.addNumericField("Minimal number of points for plane detection", this.plMinPoints, 0); gd.addNumericField("Minimal number of points for plane detection", this.plMinPoints, 0); gd.addNumericField("Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below", this.plTargetEigen, 6); gd.addNumericField("Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below", this.plTargetEigen, 6); Loading @@ -2937,8 +2944,9 @@ 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.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("Relax merge requirements for weaker planes", this.plWeakWorsening, 6); gd.addCheckbox ("Keep only mutual links, remove weakest if conflict", this.plMutualOnly); gd.addCheckbox ("Keep only mutual links, remove weakest if conflict", this.plMutualOnly); gd.addCheckbox ("Add diagonals to full squares", this.plFillSquares); gd.addCheckbox ("Add diagonals to full squares", this.plFillSquares); Loading Loading @@ -3191,6 +3199,7 @@ public class EyesisCorrectionParameters { this.grow_disp_step= gd.getNextNumber(); this.grow_disp_step= gd.getNextNumber(); this.grow_min_diff= gd.getNextNumber(); this.grow_min_diff= gd.getNextNumber(); this.plPreferDisparity= gd.getNextBoolean(); this.plDispNorm= gd.getNextNumber(); this.plDispNorm= gd.getNextNumber(); this.plMinPoints= (int) gd.getNextNumber(); this.plMinPoints= (int) gd.getNextNumber(); this.plTargetEigen= gd.getNextNumber(); this.plTargetEigen= gd.getNextNumber(); Loading @@ -3200,6 +3209,7 @@ public class EyesisCorrectionParameters { this.plMaxEigen= gd.getNextNumber(); this.plMaxEigen= gd.getNextNumber(); this.plDbgMerge= gd.getNextBoolean(); this.plDbgMerge= gd.getNextBoolean(); this.plWorstWorsening= gd.getNextNumber(); this.plWorstWorsening= gd.getNextNumber(); this.plWeakWorsening= gd.getNextNumber(); this.plMutualOnly= gd.getNextBoolean(); this.plMutualOnly= gd.getNextBoolean(); this.plFillSquares= gd.getNextBoolean(); this.plFillSquares= gd.getNextBoolean(); Loading src/main/java/SuperTiles.java +50 −39 Original line number Original line Diff line number Diff line Loading @@ -1168,7 +1168,6 @@ public class SuperTiles{ public void processPlanes2( public void processPlanes2( final boolean [] selected, // or null final boolean [] selected, // or null final double min_disp, final double min_disp, final boolean invert_disp, // use 1/disparity final boolean invert_disp, // use 1/disparity Loading @@ -1177,6 +1176,7 @@ public class SuperTiles{ final double plTargetEigen, // = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below final double plTargetEigen, // = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below final double plFractOutliers, // = 0.3; // Maximal fraction of outliers to remove final double plFractOutliers, // = 0.3; // Maximal fraction of outliers to remove final int plMaxOutliers, // = 20; // Maximal number of outliers to remove final int plMaxOutliers, // = 20; // Maximal number of outliers to remove final boolean plPreferDisparity, // Always start with disparity-most axis (false - lowest eigenvalue) final GeometryCorrection geometryCorrection, final GeometryCorrection geometryCorrection, final boolean correct_distortions, final boolean correct_distortions, final int debugLevel, final int debugLevel, Loading Loading @@ -1262,27 +1262,19 @@ public class SuperTiles{ } } } } planes[nsTile] = null; planes[nsTile] = null; if (sw >0){ if (sw >0){ // there are some non-zero tiles, process them (all points, not clustered by disparity value) ArrayList<TilePlanes.PlaneData> st_planes = new ArrayList<TilePlanes.PlaneData>(); ArrayList<TilePlanes.PlaneData> st_planes = new ArrayList<TilePlanes.PlaneData>(); // int dl = ((nsTile >= debug_stile-1) && (nsTile <= debug_stile+1) ) ? 1 : 0; // int dl = ((stileY == 17) && (stileX > 4)) ? 1 : 0; // int dl = (stileY >= 0) ? 1 : 0; int dl1 = (nsTile == debug_stile) ? 3 : 0; int dl1 = (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 == 16) && (stileX == 27) ) ? 3 : 0; int dl = (nsTile == debug_stile) ? 3 : 0; int dl = (nsTile == debug_stile) ? 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(); TilePlanes.PlaneData pd = tpl.getPlane( TilePlanes.PlaneData pd = tpl.getPlane( sTiles, sTiles, stDisparity, stDisparity, stStrength, stStrength, sel_all, sel_all, plPreferDisparity, 0); // debugLevel); 0); // debugLevel); if (pd != null) { if (pd != null) { // not too few points, probably //correct_distortions //correct_distortions double swc_common = pd.getWeight(); double swc_common = pd.getWeight(); if (dl > 0) { if (dl > 0) { Loading @@ -1301,19 +1293,11 @@ public class SuperTiles{ // now try to remove outliers // now try to remove outliers int max_outliers = (int) Math.round(pd.getNumPoints() * plFractOutliers); int max_outliers = (int) Math.round(pd.getNumPoints() * plFractOutliers); if (max_outliers > plMaxOutliers) max_outliers = plMaxOutliers; if (max_outliers > plMaxOutliers) max_outliers = plMaxOutliers; /* double targetV = plTargetEigen; double z0 = pd.getZxy()[0]; if ((plTargetEigen > 0.0) && (z0 > plDispNorm)) { double dd = (plDispNorm + z0)/ plDispNorm; // > 1 targetV *= dd * dd; // > original } */ double targetV = corrMaxEigen( double targetV = corrMaxEigen( plTargetEigen, plTargetEigen, plDispNorm, plDispNorm, pd); pd); if (pd.getValues()[0] > targetV) { if (pd.getValue() > targetV) { pd = tpl.removePlaneOutliers( pd = tpl.removePlaneOutliers( pd, pd, sTiles, sTiles, Loading @@ -1323,7 +1307,9 @@ public class SuperTiles{ targetV, // double targetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant) targetV, // double targetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant) max_outliers, // int maxRemoved, // maximal number of tiles to remove (not a constant) max_outliers, // int maxRemoved, // maximal number of tiles to remove (not a constant) plMinPoints, // int minLeft, // minimal number of tiles to keep plMinPoints, // int minLeft, // minimal number of tiles to keep plPreferDisparity, dl1); // 0); // debugLevel); dl1); // 0); // debugLevel); if (pd == null) continue; if (dl > 0) { if (dl > 0) { if (swc_common > 0.3) { // 1.0) { if (swc_common > 0.3) { // 1.0) { System.out.println("Removed outliers["+nsTile+"]"+ System.out.println("Removed outliers["+nsTile+"]"+ Loading @@ -1350,9 +1336,9 @@ public class SuperTiles{ norm_xyz[0]+", "+norm_xyz[1]+", "+norm_xyz[2]+"}"); norm_xyz[0]+", "+norm_xyz[1]+", "+norm_xyz[2]+"}"); } } st_planes.add(pd); st_planes.add(pd); // adding [0] - all supertile tiles, not clustered by disparity value // now try for each of the disparity-separated clusters // now try for each of the disparity-separated clusters (only for multi-peak histograms) double [][] mm = maxMinMax[nsTile]; double [][] mm = maxMinMax[nsTile]; Loading Loading @@ -1392,6 +1378,7 @@ public class SuperTiles{ stDisparity, stDisparity, stStrength, stStrength, stSels[m], stSels[m], plPreferDisparity, 0); // debugLevel); 0); // debugLevel); if (pd != null) { if (pd != null) { if (dl > 0) { if (dl > 0) { Loading Loading @@ -1426,7 +1413,11 @@ public class SuperTiles{ targetV, // double targetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant) targetV, // double targetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant) max_outliers, // int maxRemoved, // maximal number of tiles to remove (not a constant) max_outliers, // int maxRemoved, // maximal number of tiles to remove (not a constant) plMinPoints, // int minLeft, // minimal number of tiles to keep plMinPoints, // int minLeft, // minimal number of tiles to keep plPreferDisparity, dl1); // 0); // debugLevel); dl1); // 0); // debugLevel); if (pd == null) { continue; } if (dl > 0) { if (dl > 0) { if (swc_common > 1.0) { if (swc_common > 1.0) { System.out.println("Removed outliers["+nsTile+"]["+m+"]"+ System.out.println("Removed outliers["+nsTile+"]["+m+"]"+ Loading Loading @@ -1485,6 +1476,7 @@ public class SuperTiles{ 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 boolean preferDisparity, final boolean dbgMerge, // Combine 'other' plane with current final boolean dbgMerge, // Combine 'other' plane with current final int dbg_X, final int dbg_X, final int dbg_Y final int dbg_Y Loading Loading @@ -1548,12 +1540,14 @@ public class SuperTiles{ planes[nsTile0][indx], // PlaneData otherPd, planes[nsTile0][indx], // PlaneData otherPd, 1.0, // double scale_other, 1.0, // double scale_other, true, // boolean ignore_weights, true, // boolean ignore_weights, preferDisparity, (nsTile0 == debug_stile)? 1:0); // int debugLevel) (nsTile0 == debug_stile)? 1:0); // int debugLevel) System.out.println("other with other, same weight:"); System.out.println("other with other, same weight:"); TilePlanes.PlaneData other_other_pd = other_pd.mergePlaneToThis( TilePlanes.PlaneData other_other_pd = other_pd.mergePlaneToThis( other_pd, // PlaneData otherPd, other_pd, // PlaneData otherPd, 1.0, // double scale_other, 1.0, // double scale_other, true, // boolean ignore_weights, true, // boolean ignore_weights, preferDisparity, (nsTile0 == debug_stile)? 1:0); // int debugLevel) (nsTile0 == debug_stile)? 1:0); // int debugLevel) System.out.println("other with this, same weight:"); System.out.println("other with this, same weight:"); } } Loading @@ -1561,6 +1555,7 @@ public class SuperTiles{ other_pd, // PlaneData otherPd, other_pd, // PlaneData otherPd, 1.0, // double scale_other, 1.0, // double scale_other, true, // boolean ignore_weights, true, // boolean ignore_weights, preferDisparity, (nsTile0 == debug_stile)? 1:0); // int debugLevel) (nsTile0 == debug_stile)? 1:0); // int debugLevel) if (!(merged_pd.getValue() > best_value)) { // Double.isNaN(best_value) will work too if (!(merged_pd.getValue() > best_value)) { // Double.isNaN(best_value) will work too best_value = merged_pd.getValue(); best_value = merged_pd.getValue(); Loading @@ -1576,6 +1571,7 @@ public class SuperTiles{ other_pd, // PlaneData otherPd, other_pd, // PlaneData otherPd, 1.0, // double scale_other, 1.0, // double scale_other, false, // boolean ignore_weights, false, // boolean ignore_weights, preferDisparity, (nsTile0 == debug_stile)? 1:0); // int debugLevel) (nsTile0 == debug_stile)? 1:0); // int debugLevel) neib_planes[nsTile0][np] = merged_pd; neib_planes[nsTile0][np] = merged_pd; } else { } else { Loading Loading @@ -1618,6 +1614,7 @@ public class SuperTiles{ } } public void matchPlanes( public void matchPlanes( final boolean preferDisparity, // Always start with disparity-most axis (false - lowest eigenvalue) final int dbg_X, final int dbg_X, final int dbg_Y) final int dbg_Y) { { Loading @@ -1636,6 +1633,7 @@ public class SuperTiles{ final Thread[] threads = ImageDtt.newThreadArray(tileProcessor.threadsMax); final Thread[] threads = ImageDtt.newThreadArray(tileProcessor.threadsMax); final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0); // Select best symmetrical match, consider only N, NE, E, SE - later opposite ones will be copied for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) { threads[ithread] = new Thread() { threads[ithread] = new Thread() { public void run() { public void run() { Loading Loading @@ -1673,6 +1671,7 @@ public class SuperTiles{ other_plane, // PlaneData otherPd, other_plane, // PlaneData otherPd, 1.0, // double scale_other, 1.0, // double scale_other, false, // boolean ignore_weights, false, // boolean ignore_weights, preferDisparity, dl); // int debugLevel) dl); // int debugLevel) if (merged_pd !=null) { // now always, but may add later if (merged_pd !=null) { // now always, but may add later this_plane.setNeibMatch(dir, np, merged_pd.getValue()); // smallest eigenValue this_plane.setNeibMatch(dir, np, merged_pd.getValue()); // smallest eigenValue Loading Loading @@ -1706,28 +1705,18 @@ public class SuperTiles{ if ( planes[nsTile0] != null) { if ( planes[nsTile0] != null) { for (int np0 = 0; np0 < planes[nsTile0].length; np0++){ // nu for (int np0 = 0; np0 < planes[nsTile0].length; np0++){ // nu TilePlanes.PlaneData this_plane = planes[nsTile0][np0]; TilePlanes.PlaneData this_plane = planes[nsTile0][np0]; // this_plane.initMergedValue(); for (int dir = 4; dir < 8; dir++){ // other half - copy from opposite for (int dir = 4; dir < 8; dir++){ // other half - copy from opposite int stx = stx0 + dirsYX[dir][1]; int stx = stx0 + dirsYX[dir][1]; int sty = sty0 + dirsYX[dir][0]; int sty = sty0 + dirsYX[dir][0]; // if ((stx < stilesX) && (sty < stilesY) && (sty > 0)) { if ((sty < stilesY) && (sty > 0) && (stx > 0)) { if ((sty < stilesY) && (sty > 0) && (stx > 0)) { int nsTile = sty * stilesX + stx; // from where to get int nsTile = sty * stilesX + stx; // from where to get TilePlanes.PlaneData [] other_planes = planes[nsTile]; TilePlanes.PlaneData [] other_planes = planes[nsTile]; if (other_planes !=null) { if (other_planes !=null) { this_plane.initMergedValue(dir,other_planes.length); // filled with NaN this_plane.initMergedValue(dir,other_planes.length); // filled with NaN for (int np = 0; np < other_planes.length; np ++){ for (int np = 0; np < other_planes.length; np ++){ /* if ((other_planes[np] != null) && (other_planes[np].getMergedValue(dir-4) != null)) { double [] dbg_nm = other_planes[np].getMergedValue(dir-4); this_plane.setNeibMatch(dir,np, other_planes[np].getMergedValue(dir-4, np0)); // } */ if (other_planes[np] != null) { // && (other_planes[np].getMergedValue(dir-4) != null)) { if (other_planes[np] != null) { // && (other_planes[np].getMergedValue(dir-4) != null)) { double [] nm = other_planes[np].getMergedValue(dir-4); double [] nm = other_planes[np].getMergedValue(dir-4); if (nm != null) { if (nm != null) { // this_plane.setNeibMatch(dir,np, other_planes[np].getMergedValue(dir-4, np0)); // this_plane.setNeibMatch(dir,np, nm[np0]); // this_plane.setNeibMatch(dir,np, nm[np0]); // } } } } Loading Loading @@ -1859,7 +1848,7 @@ public class SuperTiles{ ImageDtt.startAndJoin(threads); ImageDtt.startAndJoin(threads); } } } } public void fillSquares() public int fillSquares() { { final int tilesX = tileProcessor.getTilesX(); final int tilesX = tileProcessor.getTilesX(); final int tilesY = tileProcessor.getTilesY(); final int tilesY = tileProcessor.getTilesY(); Loading @@ -1868,6 +1857,7 @@ public class SuperTiles{ 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 nStiles = stilesX * stilesY; final int nStiles = stilesX * stilesY; int num_added = 0; for (int stY = 0; stY < (stilesY - 1); stY++ ) { for (int stY = 0; stY < (stilesY - 1); stY++ ) { for (int stX = 0; stX < (stilesX - 1); stX++ ) { for (int stX = 0; stX < (stilesX - 1); stX++ ) { int nsTile = stY * stilesX + stX; int nsTile = stY * stilesX + stX; Loading @@ -1891,18 +1881,21 @@ public class SuperTiles{ if (neibs0[3] < 0) { if (neibs0[3] < 0) { neibs0[3] = neibs1[4]; neibs0[3] = neibs1[4]; neibs3[7] = np; neibs3[7] = np; num_added++; } } if (neibs1[5] < 0){ if (neibs1[5] < 0){ neibs1[5] = neibs0[4]; neibs1[5] = neibs0[4]; neibs2[1] = neibs0[2]; neibs2[1] = neibs0[2]; num_added++; } } } } } } } } } } return num_added; } } public void cutCorners() public int cutCorners() { { final int tilesX = tileProcessor.getTilesX(); final int tilesX = tileProcessor.getTilesX(); final int tilesY = tileProcessor.getTilesY(); final int tilesY = tileProcessor.getTilesY(); Loading @@ -1910,7 +1903,8 @@ 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 nStiles = stilesX * stilesY; // final int nStiles = stilesX * stilesY; int num_added = 0; for (int stY = 0; stY < (stilesY - 1); stY++ ) { for (int stY = 0; stY < (stilesY - 1); stY++ ) { for (int stX = 0; stX < (stilesX - 1); stX++ ) { for (int stX = 0; stX < (stilesX - 1); stX++ ) { int nsTile = stY * stilesX + stX; int nsTile = stY * stilesX + stX; Loading @@ -1931,6 +1925,7 @@ public class SuperTiles{ neibs0[4] = neibs1[5]; neibs0[4] = neibs1[5]; int [] neibs2 = planes4[2][neibs1[5]].getNeibBest(); int [] neibs2 = planes4[2][neibs1[5]].getNeibBest(); neibs2[0] = np; //? neibs2[0] = np; //? num_added++; } } } } } } Loading @@ -1942,6 +1937,7 @@ public class SuperTiles{ neibs0[2] = neibs2[1]; neibs0[2] = neibs2[1]; int [] neibs1 = planes4[1][neibs2[1]].getNeibBest(); int [] neibs1 = planes4[1][neibs2[1]].getNeibBest(); neibs1[6] = np; neibs1[6] = np; num_added++; } } } } } } Loading @@ -1951,6 +1947,7 @@ public class SuperTiles{ if (neibs1[4] < 0) { if (neibs1[4] < 0) { neibs1[4] = neibs0[3]; neibs1[4] = neibs0[3]; neibs3[0] = neibs0[2]; //? neibs3[0] = neibs0[2]; //? num_added++; } } } } if ((neibs0[3] >= 0) && (neibs0[4] >= 0)){ if ((neibs0[3] >= 0) && (neibs0[4] >= 0)){ Loading @@ -1959,6 +1956,7 @@ public class SuperTiles{ if (neibs2[2] < 0) { if (neibs2[2] < 0) { neibs2[2] = neibs0[3]; neibs2[2] = neibs0[3]; neibs3[6] = neibs0[4]; neibs3[6] = neibs0[4]; num_added++; } } } } } } Loading @@ -1975,6 +1973,7 @@ public class SuperTiles{ if (neibs0[2] < 0) { if (neibs0[2] < 0) { neibs0[2] = neibs3[0]; neibs0[2] = neibs3[0]; neibs1[6] = neibs3[7]; neibs1[6] = neibs3[7]; num_added++; } } } } Loading @@ -1985,6 +1984,7 @@ public class SuperTiles{ if (neibs0[4] < 0) { if (neibs0[4] < 0) { neibs0[4] = neibs3[6]; neibs0[4] = neibs3[6]; neibs2[0] = neibs3[7]; //? neibs2[0] = neibs3[7]; //? num_added++; } } } } Loading @@ -1996,6 +1996,7 @@ public class SuperTiles{ int [] neibs2 = planes4[2][neibs0[4]].getNeibBest(); int [] neibs2 = planes4[2][neibs0[4]].getNeibBest(); neibs3[6] = neibs0[4]; neibs3[6] = neibs0[4]; neibs2[2] = np; //? neibs2[2] = np; //? num_added++; } } } } Loading @@ -2006,6 +2007,7 @@ public class SuperTiles{ int [] neibs1 = planes4[1][neibs2[1]].getNeibBest(); int [] neibs1 = planes4[1][neibs2[1]].getNeibBest(); neibs3[0] = neibs2[1]; //? neibs3[0] = neibs2[1]; //? neibs1[4] = np; neibs1[4] = np; num_added++; } } } } } } Loading @@ -2013,6 +2015,8 @@ public class SuperTiles{ } } } } } } return num_added; } } /** /** Loading @@ -2027,6 +2031,7 @@ public class SuperTiles{ */ */ public void selectNeighborPlanesMutual( public void selectNeighborPlanesMutual( final double rquality, final double rquality, final double weakWorsening, final double dispNorm, final double dispNorm, final double maxEigen, // maximal eigenvalue of planes to consider final double maxEigen, // maximal eigenvalue of planes to consider final double minWeight, // minimal pain weight to consider final double minWeight, // minimal pain weight to consider Loading Loading @@ -2130,8 +2135,9 @@ public class SuperTiles{ merge_ev[np], // double L, merge_ev[np], // double L, w1, // double w1, w1, // double w1, w2); // double w2) w2); // double w2) // if (this_rq <= rquality) { // compare with the threshold before applying strengths double this_rq_norm = this_rq; if ((w1 + w2) * this_rq <= rquality) { // forgive more for weak planes if ((w1 + w2) < weakWorsening) this_rq_norm *= (w1 + w2) / weakWorsening; // forgive more for weak planes if (this_rq_norm <= rquality) { this_rq /= (w1 + w2); // for comparision reduce this value for stronger planes this_rq /= (w1 + w2); // for comparision reduce this value for stronger planes if (Double.isNaN(best_rqual) || (this_rq < best_rqual)){ // OK if Double.isNaN(this_rq[np]) if (Double.isNaN(best_rqual) || (this_rq < best_rqual)){ // OK if Double.isNaN(this_rq[np]) best_rqual = this_rq; best_rqual = this_rq; Loading Loading @@ -2504,6 +2510,7 @@ public class SuperTiles{ final double meas_pull,// relative pull of the original (measured) plane with respect to the average of the neighbors final double meas_pull,// relative pull of the original (measured) plane with respect to the average of the neighbors final int num_passes, final int num_passes, final double maxDiff, // maximal change in any of the disparity values final double maxDiff, // maximal change in any of the disparity values final boolean preferDisparity, // Always start with disparity-most axis (false - lowest eigenvalue) final int debugLevel, final int debugLevel, final int dbg_X, final int dbg_X, final int dbg_Y) final int dbg_Y) Loading @@ -2517,6 +2524,7 @@ public class SuperTiles{ this.planes, // final TilePlanes.PlaneData[][] measured_planes, this.planes, // final TilePlanes.PlaneData[][] measured_planes, this.planes_mod, // final TilePlanes.PlaneData[][] mod_planes, this.planes_mod, // final TilePlanes.PlaneData[][] mod_planes, true, // final boolean calc_diff, true, // final boolean calc_diff, preferDisparity, (pass < 10)? debugLevel: 0, (pass < 10)? debugLevel: 0, dbg_X, dbg_X, dbg_Y); dbg_Y); Loading @@ -2539,6 +2547,7 @@ public class SuperTiles{ final TilePlanes.PlaneData[][] measured_planes, final TilePlanes.PlaneData[][] measured_planes, final TilePlanes.PlaneData[][] mod_planes, final TilePlanes.PlaneData[][] mod_planes, final boolean calc_diff, final boolean calc_diff, final boolean preferDisparity, // Always start with disparity-most axis (false - lowest eigenvalue) final int debugLevel, final int debugLevel, final int dbg_X, final int dbg_X, final int dbg_Y) final int dbg_Y) Loading Loading @@ -2600,6 +2609,7 @@ public class SuperTiles{ other_plane, // PlaneData otherPd, other_plane, // PlaneData otherPd, 1.0, // double scale_other, 1.0, // double scale_other, false, // boolean ignore_weights, false, // boolean ignore_weights, preferDisparity, dl); // int debugLevel) dl); // int debugLevel) } else { } else { this_new_plane = other_plane; this_new_plane = other_plane; Loading @@ -2619,6 +2629,7 @@ public class SuperTiles{ measured_planes[nsTile0][np0], // PlaneData otherPd, measured_planes[nsTile0][np0], // PlaneData otherPd, meas_pull, // double scale_other, meas_pull, // double scale_other, false, // boolean ignore_weights, false, // boolean ignore_weights, preferDisparity, dl); // int debugLevel) dl); // int debugLevel) } else { } else { this_new_plane = measured_planes[nsTile0][np0].clone(); this_new_plane = measured_planes[nsTile0][np0].clone(); Loading Loading
src/main/java/EyesisCorrectionParameters.java +12 −2 Original line number Original line Diff line number Diff line Loading @@ -2142,6 +2142,7 @@ public class EyesisCorrectionParameters { public double grow_disp_step = 6.0; // Increase disparity (from maximal tried) if nothing found in that tile // TODO: handle enclosed dips? public double grow_disp_step = 6.0; // Increase disparity (from maximal tried) if nothing found in that tile // TODO: handle enclosed dips? public double grow_min_diff = 0.5; // Grow more only if at least one channel has higher variance from others for the tile public double grow_min_diff = 0.5; // Grow more only if at least one channel has higher variance from others for the tile public boolean plPreferDisparity = false;// Always start with disparity-most axis (false - lowest eigenvalue) public double plDispNorm = 3.0; // Normalize disparities to the average if above (now only for eigenvalue comparison) public double plDispNorm = 3.0; // Normalize disparities to the average if above (now only for eigenvalue comparison) public int plMinPoints = 5; // Minimal number of points for plane detection public int plMinPoints = 5; // Minimal number of points for plane detection public double plTargetEigen = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below public double plTargetEigen = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below Loading @@ -2150,7 +2151,8 @@ public class EyesisCorrectionParameters { 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 public boolean plDbgMerge = true; // Combine 'other' plane with current public double plWorstWorsening = 1.0; // Worst case worsening after merge public double plWorstWorsening = 3.0; // Worst case worsening after merge public double plWeakWorsening = 1.0; // Relax merge requirements for weaker planes public boolean plMutualOnly = true; // keep only mutual links, remove weakest if conflict public boolean plMutualOnly = true; // keep only mutual links, remove weakest if conflict public boolean plFillSquares = true; // Add diagonals to full squares public boolean plFillSquares = true; // Add diagonals to full squares public boolean plCutCorners = true; // Add ortho to 45-degree corners public boolean plCutCorners = true; // Add ortho to 45-degree corners Loading Loading @@ -2406,6 +2408,7 @@ public class EyesisCorrectionParameters { properties.setProperty(prefix+"grow_disp_step", this.grow_disp_step +""); properties.setProperty(prefix+"grow_disp_step", this.grow_disp_step +""); properties.setProperty(prefix+"grow_min_diff", this.grow_min_diff +""); properties.setProperty(prefix+"grow_min_diff", this.grow_min_diff +""); properties.setProperty(prefix+"plPreferDisparity",this.plPreferDisparity+""); properties.setProperty(prefix+"plDispNorm", this.plDispNorm +""); properties.setProperty(prefix+"plDispNorm", this.plDispNorm +""); properties.setProperty(prefix+"plMinPoints", this.plMinPoints+""); properties.setProperty(prefix+"plMinPoints", this.plMinPoints+""); properties.setProperty(prefix+"plTargetEigen", this.plTargetEigen +""); properties.setProperty(prefix+"plTargetEigen", this.plTargetEigen +""); Loading @@ -2415,6 +2418,7 @@ public class EyesisCorrectionParameters { properties.setProperty(prefix+"plMaxEigen", this.plMaxEigen +""); properties.setProperty(prefix+"plMaxEigen", this.plMaxEigen +""); 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+"plWeakWorsening", this.plWeakWorsening +""); properties.setProperty(prefix+"plMutualOnly", this.plMutualOnly+""); properties.setProperty(prefix+"plMutualOnly", this.plMutualOnly+""); properties.setProperty(prefix+"plFillSquares", this.plFillSquares+""); properties.setProperty(prefix+"plFillSquares", this.plFillSquares+""); Loading Loading @@ -2657,6 +2661,7 @@ public class EyesisCorrectionParameters { if (properties.getProperty(prefix+"grow_disp_step")!=null) this.grow_disp_step=Double.parseDouble(properties.getProperty(prefix+"grow_disp_step")); if (properties.getProperty(prefix+"grow_disp_step")!=null) this.grow_disp_step=Double.parseDouble(properties.getProperty(prefix+"grow_disp_step")); if (properties.getProperty(prefix+"grow_min_diff")!=null) this.grow_min_diff=Double.parseDouble(properties.getProperty(prefix+"grow_min_diff")); if (properties.getProperty(prefix+"grow_min_diff")!=null) this.grow_min_diff=Double.parseDouble(properties.getProperty(prefix+"grow_min_diff")); if (properties.getProperty(prefix+"plPreferDisparity")!=null) this.plPreferDisparity=Boolean.parseBoolean(properties.getProperty(prefix+"plPreferDisparity")); if (properties.getProperty(prefix+"plDispNorm")!=null) this.plDispNorm=Double.parseDouble(properties.getProperty(prefix+"plDispNorm")); if (properties.getProperty(prefix+"plDispNorm")!=null) this.plDispNorm=Double.parseDouble(properties.getProperty(prefix+"plDispNorm")); if (properties.getProperty(prefix+"plMinPoints")!=null) this.plMinPoints=Integer.parseInt(properties.getProperty(prefix+"plMinPoints")); if (properties.getProperty(prefix+"plMinPoints")!=null) this.plMinPoints=Integer.parseInt(properties.getProperty(prefix+"plMinPoints")); if (properties.getProperty(prefix+"plTargetEigen")!=null) this.plTargetEigen=Double.parseDouble(properties.getProperty(prefix+"plTargetEigen")); if (properties.getProperty(prefix+"plTargetEigen")!=null) this.plTargetEigen=Double.parseDouble(properties.getProperty(prefix+"plTargetEigen")); Loading @@ -2666,6 +2671,7 @@ public class EyesisCorrectionParameters { 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+"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+"plWeakWorsening")!=null) this.plWeakWorsening=Double.parseDouble(properties.getProperty(prefix+"plWeakWorsening")); if (properties.getProperty(prefix+"plMutualOnly")!=null) this.plMutualOnly=Boolean.parseBoolean(properties.getProperty(prefix+"plMutualOnly")); if (properties.getProperty(prefix+"plMutualOnly")!=null) this.plMutualOnly=Boolean.parseBoolean(properties.getProperty(prefix+"plMutualOnly")); if (properties.getProperty(prefix+"plFillSquares")!=null) this.plFillSquares=Boolean.parseBoolean(properties.getProperty(prefix+"plFillSquares")); if (properties.getProperty(prefix+"plFillSquares")!=null) this.plFillSquares=Boolean.parseBoolean(properties.getProperty(prefix+"plFillSquares")); Loading Loading @@ -2930,6 +2936,7 @@ public class EyesisCorrectionParameters { gd.addNumericField("Increase disparity (from maximal tried) if nothing found in that tile", this.grow_disp_step, 6); gd.addNumericField("Increase disparity (from maximal tried) if nothing found in that tile", this.grow_disp_step, 6); gd.addNumericField("Grow more only if at least one channel has higher variance from others for the tile", this.grow_min_diff, 6); gd.addNumericField("Grow more only if at least one channel has higher variance from others for the tile", this.grow_min_diff, 6); gd.addMessage ("--- Planes detection ---"); gd.addMessage ("--- Planes detection ---"); gd.addCheckbox ("Always start with disparity-most axis (false - lowest eigenvalue)", this.plPreferDisparity); gd.addNumericField("Normalize disparities to the average if above", this.plDispNorm, 6); gd.addNumericField("Normalize disparities to the average if above", this.plDispNorm, 6); gd.addNumericField("Minimal number of points for plane detection", this.plMinPoints, 0); gd.addNumericField("Minimal number of points for plane detection", this.plMinPoints, 0); gd.addNumericField("Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below", this.plTargetEigen, 6); gd.addNumericField("Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below", this.plTargetEigen, 6); Loading @@ -2937,8 +2944,9 @@ 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.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("Relax merge requirements for weaker planes", this.plWeakWorsening, 6); gd.addCheckbox ("Keep only mutual links, remove weakest if conflict", this.plMutualOnly); gd.addCheckbox ("Keep only mutual links, remove weakest if conflict", this.plMutualOnly); gd.addCheckbox ("Add diagonals to full squares", this.plFillSquares); gd.addCheckbox ("Add diagonals to full squares", this.plFillSquares); Loading Loading @@ -3191,6 +3199,7 @@ public class EyesisCorrectionParameters { this.grow_disp_step= gd.getNextNumber(); this.grow_disp_step= gd.getNextNumber(); this.grow_min_diff= gd.getNextNumber(); this.grow_min_diff= gd.getNextNumber(); this.plPreferDisparity= gd.getNextBoolean(); this.plDispNorm= gd.getNextNumber(); this.plDispNorm= gd.getNextNumber(); this.plMinPoints= (int) gd.getNextNumber(); this.plMinPoints= (int) gd.getNextNumber(); this.plTargetEigen= gd.getNextNumber(); this.plTargetEigen= gd.getNextNumber(); Loading @@ -3200,6 +3209,7 @@ public class EyesisCorrectionParameters { this.plMaxEigen= gd.getNextNumber(); this.plMaxEigen= gd.getNextNumber(); this.plDbgMerge= gd.getNextBoolean(); this.plDbgMerge= gd.getNextBoolean(); this.plWorstWorsening= gd.getNextNumber(); this.plWorstWorsening= gd.getNextNumber(); this.plWeakWorsening= gd.getNextNumber(); this.plMutualOnly= gd.getNextBoolean(); this.plMutualOnly= gd.getNextBoolean(); this.plFillSquares= gd.getNextBoolean(); this.plFillSquares= gd.getNextBoolean(); Loading
src/main/java/SuperTiles.java +50 −39 Original line number Original line Diff line number Diff line Loading @@ -1168,7 +1168,6 @@ public class SuperTiles{ public void processPlanes2( public void processPlanes2( final boolean [] selected, // or null final boolean [] selected, // or null final double min_disp, final double min_disp, final boolean invert_disp, // use 1/disparity final boolean invert_disp, // use 1/disparity Loading @@ -1177,6 +1176,7 @@ public class SuperTiles{ final double plTargetEigen, // = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below final double plTargetEigen, // = 0.1; // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below final double plFractOutliers, // = 0.3; // Maximal fraction of outliers to remove final double plFractOutliers, // = 0.3; // Maximal fraction of outliers to remove final int plMaxOutliers, // = 20; // Maximal number of outliers to remove final int plMaxOutliers, // = 20; // Maximal number of outliers to remove final boolean plPreferDisparity, // Always start with disparity-most axis (false - lowest eigenvalue) final GeometryCorrection geometryCorrection, final GeometryCorrection geometryCorrection, final boolean correct_distortions, final boolean correct_distortions, final int debugLevel, final int debugLevel, Loading Loading @@ -1262,27 +1262,19 @@ public class SuperTiles{ } } } } planes[nsTile] = null; planes[nsTile] = null; if (sw >0){ if (sw >0){ // there are some non-zero tiles, process them (all points, not clustered by disparity value) ArrayList<TilePlanes.PlaneData> st_planes = new ArrayList<TilePlanes.PlaneData>(); ArrayList<TilePlanes.PlaneData> st_planes = new ArrayList<TilePlanes.PlaneData>(); // int dl = ((nsTile >= debug_stile-1) && (nsTile <= debug_stile+1) ) ? 1 : 0; // int dl = ((stileY == 17) && (stileX > 4)) ? 1 : 0; // int dl = (stileY >= 0) ? 1 : 0; int dl1 = (nsTile == debug_stile) ? 3 : 0; int dl1 = (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 == 16) && (stileX == 27) ) ? 3 : 0; int dl = (nsTile == debug_stile) ? 3 : 0; int dl = (nsTile == debug_stile) ? 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(); TilePlanes.PlaneData pd = tpl.getPlane( TilePlanes.PlaneData pd = tpl.getPlane( sTiles, sTiles, stDisparity, stDisparity, stStrength, stStrength, sel_all, sel_all, plPreferDisparity, 0); // debugLevel); 0); // debugLevel); if (pd != null) { if (pd != null) { // not too few points, probably //correct_distortions //correct_distortions double swc_common = pd.getWeight(); double swc_common = pd.getWeight(); if (dl > 0) { if (dl > 0) { Loading @@ -1301,19 +1293,11 @@ public class SuperTiles{ // now try to remove outliers // now try to remove outliers int max_outliers = (int) Math.round(pd.getNumPoints() * plFractOutliers); int max_outliers = (int) Math.round(pd.getNumPoints() * plFractOutliers); if (max_outliers > plMaxOutliers) max_outliers = plMaxOutliers; if (max_outliers > plMaxOutliers) max_outliers = plMaxOutliers; /* double targetV = plTargetEigen; double z0 = pd.getZxy()[0]; if ((plTargetEigen > 0.0) && (z0 > plDispNorm)) { double dd = (plDispNorm + z0)/ plDispNorm; // > 1 targetV *= dd * dd; // > original } */ double targetV = corrMaxEigen( double targetV = corrMaxEigen( plTargetEigen, plTargetEigen, plDispNorm, plDispNorm, pd); pd); if (pd.getValues()[0] > targetV) { if (pd.getValue() > targetV) { pd = tpl.removePlaneOutliers( pd = tpl.removePlaneOutliers( pd, pd, sTiles, sTiles, Loading @@ -1323,7 +1307,9 @@ public class SuperTiles{ targetV, // double targetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant) targetV, // double targetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant) max_outliers, // int maxRemoved, // maximal number of tiles to remove (not a constant) max_outliers, // int maxRemoved, // maximal number of tiles to remove (not a constant) plMinPoints, // int minLeft, // minimal number of tiles to keep plMinPoints, // int minLeft, // minimal number of tiles to keep plPreferDisparity, dl1); // 0); // debugLevel); dl1); // 0); // debugLevel); if (pd == null) continue; if (dl > 0) { if (dl > 0) { if (swc_common > 0.3) { // 1.0) { if (swc_common > 0.3) { // 1.0) { System.out.println("Removed outliers["+nsTile+"]"+ System.out.println("Removed outliers["+nsTile+"]"+ Loading @@ -1350,9 +1336,9 @@ public class SuperTiles{ norm_xyz[0]+", "+norm_xyz[1]+", "+norm_xyz[2]+"}"); norm_xyz[0]+", "+norm_xyz[1]+", "+norm_xyz[2]+"}"); } } st_planes.add(pd); st_planes.add(pd); // adding [0] - all supertile tiles, not clustered by disparity value // now try for each of the disparity-separated clusters // now try for each of the disparity-separated clusters (only for multi-peak histograms) double [][] mm = maxMinMax[nsTile]; double [][] mm = maxMinMax[nsTile]; Loading Loading @@ -1392,6 +1378,7 @@ public class SuperTiles{ stDisparity, stDisparity, stStrength, stStrength, stSels[m], stSels[m], plPreferDisparity, 0); // debugLevel); 0); // debugLevel); if (pd != null) { if (pd != null) { if (dl > 0) { if (dl > 0) { Loading Loading @@ -1426,7 +1413,11 @@ public class SuperTiles{ targetV, // double targetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant) targetV, // double targetEigen, // target eigenvalue for primary axis (is disparity-dependent, so is non-constant) max_outliers, // int maxRemoved, // maximal number of tiles to remove (not a constant) max_outliers, // int maxRemoved, // maximal number of tiles to remove (not a constant) plMinPoints, // int minLeft, // minimal number of tiles to keep plMinPoints, // int minLeft, // minimal number of tiles to keep plPreferDisparity, dl1); // 0); // debugLevel); dl1); // 0); // debugLevel); if (pd == null) { continue; } if (dl > 0) { if (dl > 0) { if (swc_common > 1.0) { if (swc_common > 1.0) { System.out.println("Removed outliers["+nsTile+"]["+m+"]"+ System.out.println("Removed outliers["+nsTile+"]["+m+"]"+ Loading Loading @@ -1485,6 +1476,7 @@ public class SuperTiles{ 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 boolean preferDisparity, final boolean dbgMerge, // Combine 'other' plane with current final boolean dbgMerge, // Combine 'other' plane with current final int dbg_X, final int dbg_X, final int dbg_Y final int dbg_Y Loading Loading @@ -1548,12 +1540,14 @@ public class SuperTiles{ planes[nsTile0][indx], // PlaneData otherPd, planes[nsTile0][indx], // PlaneData otherPd, 1.0, // double scale_other, 1.0, // double scale_other, true, // boolean ignore_weights, true, // boolean ignore_weights, preferDisparity, (nsTile0 == debug_stile)? 1:0); // int debugLevel) (nsTile0 == debug_stile)? 1:0); // int debugLevel) System.out.println("other with other, same weight:"); System.out.println("other with other, same weight:"); TilePlanes.PlaneData other_other_pd = other_pd.mergePlaneToThis( TilePlanes.PlaneData other_other_pd = other_pd.mergePlaneToThis( other_pd, // PlaneData otherPd, other_pd, // PlaneData otherPd, 1.0, // double scale_other, 1.0, // double scale_other, true, // boolean ignore_weights, true, // boolean ignore_weights, preferDisparity, (nsTile0 == debug_stile)? 1:0); // int debugLevel) (nsTile0 == debug_stile)? 1:0); // int debugLevel) System.out.println("other with this, same weight:"); System.out.println("other with this, same weight:"); } } Loading @@ -1561,6 +1555,7 @@ public class SuperTiles{ other_pd, // PlaneData otherPd, other_pd, // PlaneData otherPd, 1.0, // double scale_other, 1.0, // double scale_other, true, // boolean ignore_weights, true, // boolean ignore_weights, preferDisparity, (nsTile0 == debug_stile)? 1:0); // int debugLevel) (nsTile0 == debug_stile)? 1:0); // int debugLevel) if (!(merged_pd.getValue() > best_value)) { // Double.isNaN(best_value) will work too if (!(merged_pd.getValue() > best_value)) { // Double.isNaN(best_value) will work too best_value = merged_pd.getValue(); best_value = merged_pd.getValue(); Loading @@ -1576,6 +1571,7 @@ public class SuperTiles{ other_pd, // PlaneData otherPd, other_pd, // PlaneData otherPd, 1.0, // double scale_other, 1.0, // double scale_other, false, // boolean ignore_weights, false, // boolean ignore_weights, preferDisparity, (nsTile0 == debug_stile)? 1:0); // int debugLevel) (nsTile0 == debug_stile)? 1:0); // int debugLevel) neib_planes[nsTile0][np] = merged_pd; neib_planes[nsTile0][np] = merged_pd; } else { } else { Loading Loading @@ -1618,6 +1614,7 @@ public class SuperTiles{ } } public void matchPlanes( public void matchPlanes( final boolean preferDisparity, // Always start with disparity-most axis (false - lowest eigenvalue) final int dbg_X, final int dbg_X, final int dbg_Y) final int dbg_Y) { { Loading @@ -1636,6 +1633,7 @@ public class SuperTiles{ final Thread[] threads = ImageDtt.newThreadArray(tileProcessor.threadsMax); final Thread[] threads = ImageDtt.newThreadArray(tileProcessor.threadsMax); final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0); // Select best symmetrical match, consider only N, NE, E, SE - later opposite ones will be copied for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) { threads[ithread] = new Thread() { threads[ithread] = new Thread() { public void run() { public void run() { Loading Loading @@ -1673,6 +1671,7 @@ public class SuperTiles{ other_plane, // PlaneData otherPd, other_plane, // PlaneData otherPd, 1.0, // double scale_other, 1.0, // double scale_other, false, // boolean ignore_weights, false, // boolean ignore_weights, preferDisparity, dl); // int debugLevel) dl); // int debugLevel) if (merged_pd !=null) { // now always, but may add later if (merged_pd !=null) { // now always, but may add later this_plane.setNeibMatch(dir, np, merged_pd.getValue()); // smallest eigenValue this_plane.setNeibMatch(dir, np, merged_pd.getValue()); // smallest eigenValue Loading Loading @@ -1706,28 +1705,18 @@ public class SuperTiles{ if ( planes[nsTile0] != null) { if ( planes[nsTile0] != null) { for (int np0 = 0; np0 < planes[nsTile0].length; np0++){ // nu for (int np0 = 0; np0 < planes[nsTile0].length; np0++){ // nu TilePlanes.PlaneData this_plane = planes[nsTile0][np0]; TilePlanes.PlaneData this_plane = planes[nsTile0][np0]; // this_plane.initMergedValue(); for (int dir = 4; dir < 8; dir++){ // other half - copy from opposite for (int dir = 4; dir < 8; dir++){ // other half - copy from opposite int stx = stx0 + dirsYX[dir][1]; int stx = stx0 + dirsYX[dir][1]; int sty = sty0 + dirsYX[dir][0]; int sty = sty0 + dirsYX[dir][0]; // if ((stx < stilesX) && (sty < stilesY) && (sty > 0)) { if ((sty < stilesY) && (sty > 0) && (stx > 0)) { if ((sty < stilesY) && (sty > 0) && (stx > 0)) { int nsTile = sty * stilesX + stx; // from where to get int nsTile = sty * stilesX + stx; // from where to get TilePlanes.PlaneData [] other_planes = planes[nsTile]; TilePlanes.PlaneData [] other_planes = planes[nsTile]; if (other_planes !=null) { if (other_planes !=null) { this_plane.initMergedValue(dir,other_planes.length); // filled with NaN this_plane.initMergedValue(dir,other_planes.length); // filled with NaN for (int np = 0; np < other_planes.length; np ++){ for (int np = 0; np < other_planes.length; np ++){ /* if ((other_planes[np] != null) && (other_planes[np].getMergedValue(dir-4) != null)) { double [] dbg_nm = other_planes[np].getMergedValue(dir-4); this_plane.setNeibMatch(dir,np, other_planes[np].getMergedValue(dir-4, np0)); // } */ if (other_planes[np] != null) { // && (other_planes[np].getMergedValue(dir-4) != null)) { if (other_planes[np] != null) { // && (other_planes[np].getMergedValue(dir-4) != null)) { double [] nm = other_planes[np].getMergedValue(dir-4); double [] nm = other_planes[np].getMergedValue(dir-4); if (nm != null) { if (nm != null) { // this_plane.setNeibMatch(dir,np, other_planes[np].getMergedValue(dir-4, np0)); // this_plane.setNeibMatch(dir,np, nm[np0]); // this_plane.setNeibMatch(dir,np, nm[np0]); // } } } } Loading Loading @@ -1859,7 +1848,7 @@ public class SuperTiles{ ImageDtt.startAndJoin(threads); ImageDtt.startAndJoin(threads); } } } } public void fillSquares() public int fillSquares() { { final int tilesX = tileProcessor.getTilesX(); final int tilesX = tileProcessor.getTilesX(); final int tilesY = tileProcessor.getTilesY(); final int tilesY = tileProcessor.getTilesY(); Loading @@ -1868,6 +1857,7 @@ public class SuperTiles{ 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 nStiles = stilesX * stilesY; final int nStiles = stilesX * stilesY; int num_added = 0; for (int stY = 0; stY < (stilesY - 1); stY++ ) { for (int stY = 0; stY < (stilesY - 1); stY++ ) { for (int stX = 0; stX < (stilesX - 1); stX++ ) { for (int stX = 0; stX < (stilesX - 1); stX++ ) { int nsTile = stY * stilesX + stX; int nsTile = stY * stilesX + stX; Loading @@ -1891,18 +1881,21 @@ public class SuperTiles{ if (neibs0[3] < 0) { if (neibs0[3] < 0) { neibs0[3] = neibs1[4]; neibs0[3] = neibs1[4]; neibs3[7] = np; neibs3[7] = np; num_added++; } } if (neibs1[5] < 0){ if (neibs1[5] < 0){ neibs1[5] = neibs0[4]; neibs1[5] = neibs0[4]; neibs2[1] = neibs0[2]; neibs2[1] = neibs0[2]; num_added++; } } } } } } } } } } return num_added; } } public void cutCorners() public int cutCorners() { { final int tilesX = tileProcessor.getTilesX(); final int tilesX = tileProcessor.getTilesX(); final int tilesY = tileProcessor.getTilesY(); final int tilesY = tileProcessor.getTilesY(); Loading @@ -1910,7 +1903,8 @@ 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 nStiles = stilesX * stilesY; // final int nStiles = stilesX * stilesY; int num_added = 0; for (int stY = 0; stY < (stilesY - 1); stY++ ) { for (int stY = 0; stY < (stilesY - 1); stY++ ) { for (int stX = 0; stX < (stilesX - 1); stX++ ) { for (int stX = 0; stX < (stilesX - 1); stX++ ) { int nsTile = stY * stilesX + stX; int nsTile = stY * stilesX + stX; Loading @@ -1931,6 +1925,7 @@ public class SuperTiles{ neibs0[4] = neibs1[5]; neibs0[4] = neibs1[5]; int [] neibs2 = planes4[2][neibs1[5]].getNeibBest(); int [] neibs2 = planes4[2][neibs1[5]].getNeibBest(); neibs2[0] = np; //? neibs2[0] = np; //? num_added++; } } } } } } Loading @@ -1942,6 +1937,7 @@ public class SuperTiles{ neibs0[2] = neibs2[1]; neibs0[2] = neibs2[1]; int [] neibs1 = planes4[1][neibs2[1]].getNeibBest(); int [] neibs1 = planes4[1][neibs2[1]].getNeibBest(); neibs1[6] = np; neibs1[6] = np; num_added++; } } } } } } Loading @@ -1951,6 +1947,7 @@ public class SuperTiles{ if (neibs1[4] < 0) { if (neibs1[4] < 0) { neibs1[4] = neibs0[3]; neibs1[4] = neibs0[3]; neibs3[0] = neibs0[2]; //? neibs3[0] = neibs0[2]; //? num_added++; } } } } if ((neibs0[3] >= 0) && (neibs0[4] >= 0)){ if ((neibs0[3] >= 0) && (neibs0[4] >= 0)){ Loading @@ -1959,6 +1956,7 @@ public class SuperTiles{ if (neibs2[2] < 0) { if (neibs2[2] < 0) { neibs2[2] = neibs0[3]; neibs2[2] = neibs0[3]; neibs3[6] = neibs0[4]; neibs3[6] = neibs0[4]; num_added++; } } } } } } Loading @@ -1975,6 +1973,7 @@ public class SuperTiles{ if (neibs0[2] < 0) { if (neibs0[2] < 0) { neibs0[2] = neibs3[0]; neibs0[2] = neibs3[0]; neibs1[6] = neibs3[7]; neibs1[6] = neibs3[7]; num_added++; } } } } Loading @@ -1985,6 +1984,7 @@ public class SuperTiles{ if (neibs0[4] < 0) { if (neibs0[4] < 0) { neibs0[4] = neibs3[6]; neibs0[4] = neibs3[6]; neibs2[0] = neibs3[7]; //? neibs2[0] = neibs3[7]; //? num_added++; } } } } Loading @@ -1996,6 +1996,7 @@ public class SuperTiles{ int [] neibs2 = planes4[2][neibs0[4]].getNeibBest(); int [] neibs2 = planes4[2][neibs0[4]].getNeibBest(); neibs3[6] = neibs0[4]; neibs3[6] = neibs0[4]; neibs2[2] = np; //? neibs2[2] = np; //? num_added++; } } } } Loading @@ -2006,6 +2007,7 @@ public class SuperTiles{ int [] neibs1 = planes4[1][neibs2[1]].getNeibBest(); int [] neibs1 = planes4[1][neibs2[1]].getNeibBest(); neibs3[0] = neibs2[1]; //? neibs3[0] = neibs2[1]; //? neibs1[4] = np; neibs1[4] = np; num_added++; } } } } } } Loading @@ -2013,6 +2015,8 @@ public class SuperTiles{ } } } } } } return num_added; } } /** /** Loading @@ -2027,6 +2031,7 @@ public class SuperTiles{ */ */ public void selectNeighborPlanesMutual( public void selectNeighborPlanesMutual( final double rquality, final double rquality, final double weakWorsening, final double dispNorm, final double dispNorm, final double maxEigen, // maximal eigenvalue of planes to consider final double maxEigen, // maximal eigenvalue of planes to consider final double minWeight, // minimal pain weight to consider final double minWeight, // minimal pain weight to consider Loading Loading @@ -2130,8 +2135,9 @@ public class SuperTiles{ merge_ev[np], // double L, merge_ev[np], // double L, w1, // double w1, w1, // double w1, w2); // double w2) w2); // double w2) // if (this_rq <= rquality) { // compare with the threshold before applying strengths double this_rq_norm = this_rq; if ((w1 + w2) * this_rq <= rquality) { // forgive more for weak planes if ((w1 + w2) < weakWorsening) this_rq_norm *= (w1 + w2) / weakWorsening; // forgive more for weak planes if (this_rq_norm <= rquality) { this_rq /= (w1 + w2); // for comparision reduce this value for stronger planes this_rq /= (w1 + w2); // for comparision reduce this value for stronger planes if (Double.isNaN(best_rqual) || (this_rq < best_rqual)){ // OK if Double.isNaN(this_rq[np]) if (Double.isNaN(best_rqual) || (this_rq < best_rqual)){ // OK if Double.isNaN(this_rq[np]) best_rqual = this_rq; best_rqual = this_rq; Loading Loading @@ -2504,6 +2510,7 @@ public class SuperTiles{ final double meas_pull,// relative pull of the original (measured) plane with respect to the average of the neighbors final double meas_pull,// relative pull of the original (measured) plane with respect to the average of the neighbors final int num_passes, final int num_passes, final double maxDiff, // maximal change in any of the disparity values final double maxDiff, // maximal change in any of the disparity values final boolean preferDisparity, // Always start with disparity-most axis (false - lowest eigenvalue) final int debugLevel, final int debugLevel, final int dbg_X, final int dbg_X, final int dbg_Y) final int dbg_Y) Loading @@ -2517,6 +2524,7 @@ public class SuperTiles{ this.planes, // final TilePlanes.PlaneData[][] measured_planes, this.planes, // final TilePlanes.PlaneData[][] measured_planes, this.planes_mod, // final TilePlanes.PlaneData[][] mod_planes, this.planes_mod, // final TilePlanes.PlaneData[][] mod_planes, true, // final boolean calc_diff, true, // final boolean calc_diff, preferDisparity, (pass < 10)? debugLevel: 0, (pass < 10)? debugLevel: 0, dbg_X, dbg_X, dbg_Y); dbg_Y); Loading @@ -2539,6 +2547,7 @@ public class SuperTiles{ final TilePlanes.PlaneData[][] measured_planes, final TilePlanes.PlaneData[][] measured_planes, final TilePlanes.PlaneData[][] mod_planes, final TilePlanes.PlaneData[][] mod_planes, final boolean calc_diff, final boolean calc_diff, final boolean preferDisparity, // Always start with disparity-most axis (false - lowest eigenvalue) final int debugLevel, final int debugLevel, final int dbg_X, final int dbg_X, final int dbg_Y) final int dbg_Y) Loading Loading @@ -2600,6 +2609,7 @@ public class SuperTiles{ other_plane, // PlaneData otherPd, other_plane, // PlaneData otherPd, 1.0, // double scale_other, 1.0, // double scale_other, false, // boolean ignore_weights, false, // boolean ignore_weights, preferDisparity, dl); // int debugLevel) dl); // int debugLevel) } else { } else { this_new_plane = other_plane; this_new_plane = other_plane; Loading @@ -2619,6 +2629,7 @@ public class SuperTiles{ measured_planes[nsTile0][np0], // PlaneData otherPd, measured_planes[nsTile0][np0], // PlaneData otherPd, meas_pull, // double scale_other, meas_pull, // double scale_other, false, // boolean ignore_weights, false, // boolean ignore_weights, preferDisparity, dl); // int debugLevel) dl); // int debugLevel) } else { } else { this_new_plane = measured_planes[nsTile0][np0].clone(); this_new_plane = measured_planes[nsTile0][np0].clone(); Loading