Loading src/main/java/EyesisCorrectionParameters.java +10 −1 Original line number Original line Diff line number Diff line Loading @@ -2186,7 +2186,8 @@ public class EyesisCorrectionParameters { public double plWeakWeight2 = 10.0 ; // Maximal weight of the weak plane to merge (second variant) public double plWeakWeight2 = 10.0 ; // Maximal weight of the weak plane to merge (second variant) public double plWeakEigen2 = 0.05; // Maximal eigenvalue of the result of non-weighted merge (second variant) public double plWeakEigen2 = 0.05; // Maximal eigenvalue of the result of non-weighted merge (second variant) public double plSumThick = 1.2; // Do not merge if any sqrt of merged eigenvalue exceeds scaled sum of components public double plSumThick = 1.2; // Do not merge if any sqrt of merged eigenvalue exceeds scaled sum of components 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 cenrter plane relative weight public double plMaxZRatio = 2.0; // Maximal ratio of Z to allow plane merging public double plMaxZRatio = 2.0; // Maximal ratio of Z to allow plane merging public double plMaxDisp = 0.6; // Maximal disparity of one of the planes to apply maximal ratio public double plMaxDisp = 0.6; // Maximal disparity of one of the planes to apply maximal ratio public double plCutTail = 1.4; // When merging with neighbors cut the tail that is worse than scaled best public double plCutTail = 1.4; // When merging with neighbors cut the tail that is worse than scaled best Loading Loading @@ -2596,6 +2597,8 @@ public class EyesisCorrectionParameters { properties.setProperty(prefix+"plWeakWeight2", this.plWeakWeight2 +""); properties.setProperty(prefix+"plWeakWeight2", this.plWeakWeight2 +""); properties.setProperty(prefix+"plWeakEigen2", this.plWeakEigen2 +""); properties.setProperty(prefix+"plWeakEigen2", this.plWeakEigen2 +""); properties.setProperty(prefix+"plSumThick", this.plSumThick +""); properties.setProperty(prefix+"plSumThick", this.plSumThick +""); properties.setProperty(prefix+"plNeNeibCost", this.plNeNeibCost +""); properties.setProperty(prefix+"plNeOwn", this.plNeOwn +""); properties.setProperty(prefix+"plMaxZRatio", this.plMaxZRatio +""); properties.setProperty(prefix+"plMaxZRatio", this.plMaxZRatio +""); properties.setProperty(prefix+"plMaxDisp", this.plMaxDisp +""); properties.setProperty(prefix+"plMaxDisp", this.plMaxDisp +""); Loading Loading @@ -2981,6 +2984,8 @@ public class EyesisCorrectionParameters { if (properties.getProperty(prefix+"plWeakWeight2")!=null) this.plWeakWeight2=Double.parseDouble(properties.getProperty(prefix+"plWeakWeight2")); if (properties.getProperty(prefix+"plWeakWeight2")!=null) this.plWeakWeight2=Double.parseDouble(properties.getProperty(prefix+"plWeakWeight2")); if (properties.getProperty(prefix+"plWeakEigen2")!=null) this.plWeakEigen2=Double.parseDouble(properties.getProperty(prefix+"plWeakEigen2")); if (properties.getProperty(prefix+"plWeakEigen2")!=null) this.plWeakEigen2=Double.parseDouble(properties.getProperty(prefix+"plWeakEigen2")); if (properties.getProperty(prefix+"plSumThick")!=null) this.plSumThick=Double.parseDouble(properties.getProperty(prefix+"plSumThick")); if (properties.getProperty(prefix+"plSumThick")!=null) this.plSumThick=Double.parseDouble(properties.getProperty(prefix+"plSumThick")); if (properties.getProperty(prefix+"plNeNeibCost")!=null) this.plNeNeibCost=Double.parseDouble(properties.getProperty(prefix+"plNeNeibCost")); if (properties.getProperty(prefix+"plNeOwn")!=null) this.plNeOwn=Double.parseDouble(properties.getProperty(prefix+"plNeOwn")); if (properties.getProperty(prefix+"plMaxZRatio")!=null) this.plMaxZRatio=Double.parseDouble(properties.getProperty(prefix+"plMaxZRatio")); if (properties.getProperty(prefix+"plMaxZRatio")!=null) this.plMaxZRatio=Double.parseDouble(properties.getProperty(prefix+"plMaxZRatio")); if (properties.getProperty(prefix+"plMaxDisp")!=null) this.plMaxDisp=Double.parseDouble(properties.getProperty(prefix+"plMaxDisp")); if (properties.getProperty(prefix+"plMaxDisp")!=null) this.plMaxDisp=Double.parseDouble(properties.getProperty(prefix+"plMaxDisp")); Loading Loading @@ -3395,6 +3400,8 @@ public class EyesisCorrectionParameters { gd.addNumericField("Maximal weight of the weak plane to merge (second variant)", this.plWeakWeight2, 6); gd.addNumericField("Maximal weight of the weak plane to merge (second variant)", this.plWeakWeight2, 6); gd.addNumericField("Maximal eigenvalue of the result of non-weighted merge (second variant)", this.plWeakEigen2, 6); gd.addNumericField("Maximal eigenvalue of the result of non-weighted merge (second variant)", this.plWeakEigen2, 6); gd.addNumericField("Do not merge if any sqrt of merged eigenvalue exceeds scaled sum of components", this.plSumThick, 6); gd.addNumericField("Do not merge if any sqrt of merged eigenvalue exceeds scaled sum of components", this.plSumThick, 6); gd.addNumericField("When calculating non-exclusive planes, do not use neighbors with high cost", this.plNeNeibCost, 6); gd.addNumericField("When calculating non-exclusive planes, use cenrter plane relative weight", this.plNeOwn, 6); gd.addMessage ("--- ---"); gd.addMessage ("--- ---"); gd.addNumericField("Maximal ratio of Z to allow plane merging", this.plMaxZRatio, 6); gd.addNumericField("Maximal ratio of Z to allow plane merging", this.plMaxZRatio, 6); Loading Loading @@ -3796,6 +3803,8 @@ public class EyesisCorrectionParameters { this.plWeakWeight2= gd.getNextNumber(); this.plWeakWeight2= gd.getNextNumber(); this.plWeakEigen2= gd.getNextNumber(); this.plWeakEigen2= gd.getNextNumber(); this.plSumThick= gd.getNextNumber(); this.plSumThick= gd.getNextNumber(); this.plNeNeibCost= gd.getNextNumber(); this.plNeOwn= gd.getNextNumber(); this.plMaxZRatio= gd.getNextNumber(); this.plMaxZRatio= gd.getNextNumber(); this.plMaxDisp= gd.getNextNumber(); this.plMaxDisp= gd.getNextNumber(); Loading src/main/java/LinkPlanes.java +313 −24 File changed.Preview size limit exceeded, changes collapsed. Show changes src/main/java/SuperTiles.java +16 −12 Original line number Original line Diff line number Diff line Loading @@ -1156,6 +1156,7 @@ public class SuperTiles{ int num_p = (selections == null) ? 0: selections.length; int num_p = (selections == null) ? 0: selections.length; int num_pm = num_ml * num_p; int num_pm = num_ml * num_p; int num_pd = (planes != null) ? (planes.length - LOWEST_PLANE(planes.length)) : 0; int num_pd = (planes != null) ? (planes.length - LOWEST_PLANE(planes.length)) : 0; final double [][] lapWeight = getLapWeights(); double [][] data = new double [num_pm + 3 * num_ml + 4 * num_pd ][]; // 4* superTileSize*superTileSize]; double [][] data = new double [num_pm + 3 * num_ml + 4 * num_pd ][]; // 4* superTileSize*superTileSize]; for (int np = 0; np < num_p; np++) if (selections [np] != null){ for (int np = 0; np < num_p; np++) if (selections [np] != null){ for (int ml = 0; ml < num_ml; ml++) if ((disp_strength[ml]!=null) && (selections[np][ml] != null)){ for (int ml = 0; ml < num_ml; ml++) if ((disp_strength[ml]!=null) && (selections[np][ml] != null)){ Loading Loading @@ -1185,7 +1186,14 @@ public class SuperTiles{ } } } } data [num_pm + 0 * num_ml + ml] = disp_strength[ml][0]; data [num_pm + 0 * num_ml + ml] = disp_strength[ml][0]; data [num_pm + 1 * num_ml + ml] = disp_strength[ml][1]; data [num_pm + 1 * num_ml + ml] = disp_strength[ml][1].clone(); // undo lapweight to show for (int sty = 0; sty < 2 * superTileSize; sty++){ for (int stx = 0; stx < 2 * superTileSize; stx++){ data [num_pm + 1 * num_ml + ml][stx + 2 * superTileSize * sty] /= lapWeight[sty][stx]; } } } } for (int npd = 0; npd < num_pd; npd++) if (planes[npd +LOWEST_PLANE(planes.length)] != null){ for (int npd = 0; npd < num_pd; npd++) if (planes[npd +LOWEST_PLANE(planes.length)] != null){ double [][] ellipsoids = planes[npd +LOWEST_PLANE(planes.length)].getDoublePlaneDisparityStrength( double [][] ellipsoids = planes[npd +LOWEST_PLANE(planes.length)].getDoublePlaneDisparityStrength( Loading Loading @@ -2099,15 +2107,11 @@ public class SuperTiles{ // separately merge corresponding nonexclusiveStar and nonexclusiveStarEq of these planes - kit is not exact, // separately merge corresponding nonexclusiveStar and nonexclusiveStarEq of these planes - kit is not exact, // but is needed just for a hint and is compatible with multithreading without recalculating other planes // but is needed just for a hint and is compatible with multithreading without recalculating other planes TilePlanes.PlaneData plane1Ex = these_planes[merge_planes[0]].getNonexclusiveStar(); TilePlanes.PlaneData plane1Ex = these_planes[merge_planes[0]].getNonexclusiveStarFb(); if (plane1Ex == null) plane1Ex = these_planes[merge_planes[0]]; TilePlanes.PlaneData plane1ExEq = these_planes[merge_planes[0]].getNonexclusiveStarEqFb(); TilePlanes.PlaneData plane1ExEq = these_planes[merge_planes[0]].getNonexclusiveStarEq(); if (plane1ExEq == null) plane1ExEq = these_planes[merge_planes[0]]; TilePlanes.PlaneData plane2Ex = these_planes[merge_planes[1]].getNonexclusiveStar(); TilePlanes.PlaneData plane2Ex = these_planes[merge_planes[1]].getNonexclusiveStarFb(); if (plane2Ex == null) plane2Ex = these_planes[merge_planes[1]]; TilePlanes.PlaneData plane2ExEq = these_planes[merge_planes[1]].getNonexclusiveStarEqFb(); TilePlanes.PlaneData plane2ExEq = these_planes[merge_planes[1]].getNonexclusiveStarEq(); if (plane2ExEq == null) plane2ExEq = these_planes[merge_planes[1]]; TilePlanes.PlaneData plane1NonExcl = plane1Ex.mergePlaneToThis( TilePlanes.PlaneData plane1NonExcl = plane1Ex.mergePlaneToThis( plane2Ex, // PlaneData otherPd, plane2Ex, // PlaneData otherPd, Loading Loading @@ -5816,7 +5820,7 @@ public class SuperTiles{ int [] neibs = this_new_plane.getNeibBest(); int [] neibs = this_new_plane.getNeibBest(); double [][] costs = new double[neibs.length][]; double [][] costs = new double[neibs.length][]; double [] weights = new double[neibs.length]; double [] weights = new double[neibs.length]; int cost_index = 1; int cost_index = 2; // overall cost double sum_rcosts = 0.0; double sum_rcosts = 0.0; int non_zero = 0; int non_zero = 0; for (int dir = 0; dir < neibs.length; dir++) if (neibs[dir] >= 0) { for (int dir = 0; dir < neibs.length; dir++) if (neibs[dir] >= 0) { Loading @@ -5841,7 +5845,7 @@ public class SuperTiles{ sum_rcosts += weights[dir]; sum_rcosts += weights[dir]; } } for (int dir = 0; dir < neibs.length; dir++) if (neibs[dir] >= 0) { for (int dir = 0; dir < neibs.length; dir++) if (neibs[dir] >= 0) { weights[dir] *= non_zero/sum_rcosts; // average weight fcor active links will be 1.0 weights[dir] *= non_zero/sum_rcosts; // average weight for active links will be 1.0 } } if (dl > 0) { if (dl > 0) { for (int dir = 0; dir <8; dir++)if (costs[dir] != null){ for (int dir = 0; dir <8; dir++)if (costs[dir] != null){ Loading @@ -5856,7 +5860,7 @@ public class SuperTiles{ System.out.println(); System.out.println(); } } this_new_plane =this_new_plane.clone(); // not to change weight! this_new_plane.setWeight(0.0); // this_new_plane.setWeight(0.0); // double num_merged = 0.0; // double to add fractional pull weight of the center double num_merged = 0.0; // double to add fractional pull weight of the center for (int dir = 0; dir < neibs.length; dir++){ for (int dir = 0; dir < neibs.length; dir++){ Loading src/main/java/TilePlanes.java +42 −17 Original line number Original line Diff line number Diff line Loading @@ -294,6 +294,12 @@ public class TilePlanes { { { return this.nonexclusiveStar; return this.nonexclusiveStar; } } public PlaneData getNonexclusiveStarFb() // fallback to this plane if nonexclusiveStar is not available { if (this.nonexclusiveStar != null) return this.nonexclusiveStar; return this; } public void setNonexclusiveStar( PlaneData pd) public void setNonexclusiveStar( PlaneData pd) { { this.nonexclusiveStar = pd; this.nonexclusiveStar = pd; Loading @@ -303,6 +309,14 @@ public class TilePlanes { { { return this.nonexclusiveStarEq; return this.nonexclusiveStarEq; } } public PlaneData getNonexclusiveStarEqFb() // fallback to this plane if nonexclusiveStarEq is not available { if (this.nonexclusiveStarEq != null) return this.nonexclusiveStarEq; return this; } public void setNonexclusiveStarEq( PlaneData pd) public void setNonexclusiveStarEq( PlaneData pd) { { this.nonexclusiveStarEq = pd; this.nonexclusiveStarEq = pd; Loading Loading @@ -2792,7 +2806,7 @@ public class TilePlanes { System.out.println("Zero eigenvalue"); System.out.println("Zero eigenvalue"); debugLevel = 10; debugLevel = 10; } } if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("other_eig_vals"); System.out.println("other_eig_vals"); other_eig_vals.print(8, 6); other_eig_vals.print(8, 6); System.out.println("this_eig_vals"); System.out.println("this_eig_vals"); Loading Loading @@ -2820,7 +2834,7 @@ public class TilePlanes { Matrix other_covar = other_eig_vectors.times(other_eig_vals.times(other_eig_vectors.transpose())); Matrix other_covar = other_eig_vectors.times(other_eig_vals.times(other_eig_vectors.transpose())); Matrix this_covar = this_eig_vectors.times(this_eig_vals.times(this_eig_vectors.transpose())); Matrix this_covar = this_eig_vectors.times(this_eig_vals.times(this_eig_vectors.transpose())); Matrix covar = (new Matrix(acovar)).times(other_fraction*(1.0-other_fraction)); // only centers with all masses Matrix covar = (new Matrix(acovar)).times(other_fraction*(1.0-other_fraction)); // only centers with all masses if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("other_covar"); System.out.println("other_covar"); other_covar.print(8, 6); other_covar.print(8, 6); System.out.println("this_covar"); System.out.println("this_covar"); Loading @@ -2830,12 +2844,12 @@ public class TilePlanes { } } covar.plusEquals(other_covar.times(other_fraction)); covar.plusEquals(other_covar.times(other_fraction)); if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("covar with other_covar"); System.out.println("covar with other_covar"); covar.print(8, 6); covar.print(8, 6); } } covar.plusEquals(this_covar.times(1.0 - other_fraction)); covar.plusEquals(this_covar.times(1.0 - other_fraction)); if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("covar with other_covar and this_covar"); System.out.println("covar with other_covar and this_covar"); covar.print(8, 6); covar.print(8, 6); } } Loading @@ -2847,7 +2861,7 @@ public class TilePlanes { EigenvalueDecomposition eig = covar.eig(); // verify NaN - it gets stuck EigenvalueDecomposition eig = covar.eig(); // verify NaN - it gets stuck // eig.getD().getArray(), // eig.getD().getArray(), // eig.getV().getArray(), // eig.getV().getArray(), if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("eig.getV()"); System.out.println("eig.getV()"); eig.getV().print(8, 6); eig.getV().print(8, 6); System.out.println("eig.getD()"); System.out.println("eig.getD()"); Loading Loading @@ -2985,7 +2999,7 @@ public class TilePlanes { System.out.println("Zero eigenvalue"); System.out.println("Zero eigenvalue"); debugLevel = 10; debugLevel = 10; } } if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("other_eig_vals"); System.out.println("other_eig_vals"); other_eig_vals.print(8, 6); other_eig_vals.print(8, 6); System.out.println("this_eig_vals"); System.out.println("this_eig_vals"); Loading Loading @@ -3013,7 +3027,7 @@ public class TilePlanes { Matrix other_covar = other_eig_vectors.times(other_eig_vals.times(other_eig_vectors.transpose())); Matrix other_covar = other_eig_vectors.times(other_eig_vals.times(other_eig_vectors.transpose())); Matrix this_covar = this_eig_vectors.times(this_eig_vals.times(this_eig_vectors.transpose())); Matrix this_covar = this_eig_vectors.times(this_eig_vals.times(this_eig_vectors.transpose())); Matrix covar = (new Matrix(acovar)).times(other_fraction*(1.0-other_fraction)); // only centers with all masses Matrix covar = (new Matrix(acovar)).times(other_fraction*(1.0-other_fraction)); // only centers with all masses if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("other_covar"); System.out.println("other_covar"); other_covar.print(8, 6); other_covar.print(8, 6); System.out.println("this_covar"); System.out.println("this_covar"); Loading @@ -3023,12 +3037,12 @@ public class TilePlanes { } } covar.plusEquals(other_covar.times(other_fraction)); covar.plusEquals(other_covar.times(other_fraction)); if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("covar with other_covar"); System.out.println("covar with other_covar"); covar.print(8, 6); covar.print(8, 6); } } covar.plusEquals(this_covar.times(1.0 - other_fraction)); covar.plusEquals(this_covar.times(1.0 - other_fraction)); if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("covar with other_covar and this_covar"); System.out.println("covar with other_covar and this_covar"); covar.print(8, 6); covar.print(8, 6); } } Loading @@ -3040,7 +3054,7 @@ public class TilePlanes { EigenvalueDecomposition eig = covar.eig(); // verify NaN - it gets stuck EigenvalueDecomposition eig = covar.eig(); // verify NaN - it gets stuck // eig.getD().getArray(), // eig.getD().getArray(), // eig.getV().getArray(), // eig.getV().getArray(), if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("eig.getV()"); System.out.println("eig.getV()"); eig.getV().print(8, 6); eig.getV().print(8, 6); System.out.println("eig.getD()"); System.out.println("eig.getD()"); Loading Loading @@ -3093,9 +3107,6 @@ public class TilePlanes { for (int i = 0; i < 3; i ++) plane[2][i] = -plane[2][i]; for (int i = 0; i < 3; i ++) plane[2][i] = -plane[2][i]; } } // PlaneData pd = this.clone(); // will copy selections too // pd.invalidateCalculated(); // real world vectors pd_partial.setWValues(eig_val[oindx][oindx],eig_val[vindx][vindx],eig_val[hindx][hindx]); // eigenvalues [0] - thickness, 2 other to detect skinny (poles) pd_partial.setWValues(eig_val[oindx][oindx],eig_val[vindx][vindx],eig_val[hindx][hindx]); // eigenvalues [0] - thickness, 2 other to detect skinny (poles) pd_partial.setWVectors(plane); pd_partial.setWVectors(plane); Loading @@ -3114,6 +3125,20 @@ public class TilePlanes { } } pd_partial.setWeight(new_weight); pd_partial.setWeight(new_weight); } } if (debugLevel > 2) { double L1 = getWValue(); double L2 = otherPd.getWValue(); double W1 = 1.0 - other_fraction; double W2 = other_fraction; double Lav = (L1*W1 + L2*W2)/(W1+W2); double L = pd_partial.getWValue(); if ((L*1.000001 < Lav) || (debugLevel > 0)){ System.out.println("========== mergePlaneToThisWorld(): L1="+L1+", L2 = "+L2+", W1="+W1+", W2="+W2+", Lav = "+Lav+", L="+L+ ", L-Lav="+(L-Lav)+", scale_other="+scale_other+", other_fraction="+other_fraction); System.out.println(); } } return pd_partial; return pd_partial; } } Loading Loading @@ -4140,12 +4165,12 @@ public class TilePlanes { } } } } mask[np] = prev_used[np].clone(); mask[np] = prev_used[np].clone(); if (plDiscrGrown > 0) { if (plDiscrGrown > 100) { // >0 tileNeibs.growSelection( tileNeibs.growSelection( plDiscrGrown, // int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more plDiscrGrown, // int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more mask[np], // boolean [] tiles, mask[np], // boolean [] tiles, null); // boolean [] prohibit) null); // boolean [] prohibit) } else if (plDiscrGrown < 0){ } else if (plDiscrGrown < 100){ //< 0 for (int indx = 0; indx < size2; indx++) mask[np][indx] = true; for (int indx = 0; indx < size2; indx++) mask[np][indx] = true; } } Loading @@ -4162,7 +4187,7 @@ public class TilePlanes { } } } } } } if (plDiscrSteal > 0){ if (0 * plDiscrSteal > 0){ // 0* for (int np = 0; np < num_planes; np++){ for (int np = 0; np < num_planes; np++){ for (int np1 = 0; np1 < num_planes; np1++) if (np1 != np){ for (int np1 = 0; np1 < num_planes; np1++) if (np1 != np){ for (int indx = 0; indx < size2; indx++){ for (int indx = 0; indx < size2; indx++){ Loading src/main/java/TileProcessor.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -3307,6 +3307,7 @@ public class TileProcessor { merge_candidates, // final int [][][] merge_candidates, merge_candidates, // final int [][][] merge_candidates, plane_nooverlaps, // final boolean [][][] valid_candidates, // will be updated plane_nooverlaps, // final boolean [][][] valid_candidates, // will be updated true, // final boolean merge_low_eigen, here it should be true true, // final boolean merge_low_eigen, here it should be true true, // final boolean useNonExcl, // consider only directions available for non-exclusive merges 2, // -1, // debugLevel, // final int debugLevel) 2, // -1, // debugLevel, // final int debugLevel) clt_parameters.tileX, clt_parameters.tileX, clt_parameters.tileY); clt_parameters.tileY); Loading Loading @@ -3766,7 +3767,7 @@ public class TileProcessor { clt_parameters.plNormPow, // 0.0: 8 neighbors pull 8 times as 1, 1.0 - same as 1 clt_parameters.plNormPow, // 0.0: 8 neighbors pull 8 times as 1, 1.0 - same as 1 Math.pow(10.0, -clt_parameters.plPrecision), // final double maxDiff, // maximal change in any of the disparity values Math.pow(10.0, -clt_parameters.plPrecision), // final double maxDiff, // maximal change in any of the disparity values clt_parameters.plPreferDisparity, clt_parameters.plPreferDisparity, 1,// 0, // final int debugLevel) 0, // 1,// 0, // final int debugLevel) clt_parameters.tileX, clt_parameters.tileX, clt_parameters.tileY); clt_parameters.tileY); } else { } else { Loading Loading
src/main/java/EyesisCorrectionParameters.java +10 −1 Original line number Original line Diff line number Diff line Loading @@ -2186,7 +2186,8 @@ public class EyesisCorrectionParameters { public double plWeakWeight2 = 10.0 ; // Maximal weight of the weak plane to merge (second variant) public double plWeakWeight2 = 10.0 ; // Maximal weight of the weak plane to merge (second variant) public double plWeakEigen2 = 0.05; // Maximal eigenvalue of the result of non-weighted merge (second variant) public double plWeakEigen2 = 0.05; // Maximal eigenvalue of the result of non-weighted merge (second variant) public double plSumThick = 1.2; // Do not merge if any sqrt of merged eigenvalue exceeds scaled sum of components public double plSumThick = 1.2; // Do not merge if any sqrt of merged eigenvalue exceeds scaled sum of components 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 cenrter plane relative weight public double plMaxZRatio = 2.0; // Maximal ratio of Z to allow plane merging public double plMaxZRatio = 2.0; // Maximal ratio of Z to allow plane merging public double plMaxDisp = 0.6; // Maximal disparity of one of the planes to apply maximal ratio public double plMaxDisp = 0.6; // Maximal disparity of one of the planes to apply maximal ratio public double plCutTail = 1.4; // When merging with neighbors cut the tail that is worse than scaled best public double plCutTail = 1.4; // When merging with neighbors cut the tail that is worse than scaled best Loading Loading @@ -2596,6 +2597,8 @@ public class EyesisCorrectionParameters { properties.setProperty(prefix+"plWeakWeight2", this.plWeakWeight2 +""); properties.setProperty(prefix+"plWeakWeight2", this.plWeakWeight2 +""); properties.setProperty(prefix+"plWeakEigen2", this.plWeakEigen2 +""); properties.setProperty(prefix+"plWeakEigen2", this.plWeakEigen2 +""); properties.setProperty(prefix+"plSumThick", this.plSumThick +""); properties.setProperty(prefix+"plSumThick", this.plSumThick +""); properties.setProperty(prefix+"plNeNeibCost", this.plNeNeibCost +""); properties.setProperty(prefix+"plNeOwn", this.plNeOwn +""); properties.setProperty(prefix+"plMaxZRatio", this.plMaxZRatio +""); properties.setProperty(prefix+"plMaxZRatio", this.plMaxZRatio +""); properties.setProperty(prefix+"plMaxDisp", this.plMaxDisp +""); properties.setProperty(prefix+"plMaxDisp", this.plMaxDisp +""); Loading Loading @@ -2981,6 +2984,8 @@ public class EyesisCorrectionParameters { if (properties.getProperty(prefix+"plWeakWeight2")!=null) this.plWeakWeight2=Double.parseDouble(properties.getProperty(prefix+"plWeakWeight2")); if (properties.getProperty(prefix+"plWeakWeight2")!=null) this.plWeakWeight2=Double.parseDouble(properties.getProperty(prefix+"plWeakWeight2")); if (properties.getProperty(prefix+"plWeakEigen2")!=null) this.plWeakEigen2=Double.parseDouble(properties.getProperty(prefix+"plWeakEigen2")); if (properties.getProperty(prefix+"plWeakEigen2")!=null) this.plWeakEigen2=Double.parseDouble(properties.getProperty(prefix+"plWeakEigen2")); if (properties.getProperty(prefix+"plSumThick")!=null) this.plSumThick=Double.parseDouble(properties.getProperty(prefix+"plSumThick")); if (properties.getProperty(prefix+"plSumThick")!=null) this.plSumThick=Double.parseDouble(properties.getProperty(prefix+"plSumThick")); if (properties.getProperty(prefix+"plNeNeibCost")!=null) this.plNeNeibCost=Double.parseDouble(properties.getProperty(prefix+"plNeNeibCost")); if (properties.getProperty(prefix+"plNeOwn")!=null) this.plNeOwn=Double.parseDouble(properties.getProperty(prefix+"plNeOwn")); if (properties.getProperty(prefix+"plMaxZRatio")!=null) this.plMaxZRatio=Double.parseDouble(properties.getProperty(prefix+"plMaxZRatio")); if (properties.getProperty(prefix+"plMaxZRatio")!=null) this.plMaxZRatio=Double.parseDouble(properties.getProperty(prefix+"plMaxZRatio")); if (properties.getProperty(prefix+"plMaxDisp")!=null) this.plMaxDisp=Double.parseDouble(properties.getProperty(prefix+"plMaxDisp")); if (properties.getProperty(prefix+"plMaxDisp")!=null) this.plMaxDisp=Double.parseDouble(properties.getProperty(prefix+"plMaxDisp")); Loading Loading @@ -3395,6 +3400,8 @@ public class EyesisCorrectionParameters { gd.addNumericField("Maximal weight of the weak plane to merge (second variant)", this.plWeakWeight2, 6); gd.addNumericField("Maximal weight of the weak plane to merge (second variant)", this.plWeakWeight2, 6); gd.addNumericField("Maximal eigenvalue of the result of non-weighted merge (second variant)", this.plWeakEigen2, 6); gd.addNumericField("Maximal eigenvalue of the result of non-weighted merge (second variant)", this.plWeakEigen2, 6); gd.addNumericField("Do not merge if any sqrt of merged eigenvalue exceeds scaled sum of components", this.plSumThick, 6); gd.addNumericField("Do not merge if any sqrt of merged eigenvalue exceeds scaled sum of components", this.plSumThick, 6); gd.addNumericField("When calculating non-exclusive planes, do not use neighbors with high cost", this.plNeNeibCost, 6); gd.addNumericField("When calculating non-exclusive planes, use cenrter plane relative weight", this.plNeOwn, 6); gd.addMessage ("--- ---"); gd.addMessage ("--- ---"); gd.addNumericField("Maximal ratio of Z to allow plane merging", this.plMaxZRatio, 6); gd.addNumericField("Maximal ratio of Z to allow plane merging", this.plMaxZRatio, 6); Loading Loading @@ -3796,6 +3803,8 @@ public class EyesisCorrectionParameters { this.plWeakWeight2= gd.getNextNumber(); this.plWeakWeight2= gd.getNextNumber(); this.plWeakEigen2= gd.getNextNumber(); this.plWeakEigen2= gd.getNextNumber(); this.plSumThick= gd.getNextNumber(); this.plSumThick= gd.getNextNumber(); this.plNeNeibCost= gd.getNextNumber(); this.plNeOwn= gd.getNextNumber(); this.plMaxZRatio= gd.getNextNumber(); this.plMaxZRatio= gd.getNextNumber(); this.plMaxDisp= gd.getNextNumber(); this.plMaxDisp= gd.getNextNumber(); Loading
src/main/java/LinkPlanes.java +313 −24 File changed.Preview size limit exceeded, changes collapsed. Show changes
src/main/java/SuperTiles.java +16 −12 Original line number Original line Diff line number Diff line Loading @@ -1156,6 +1156,7 @@ public class SuperTiles{ int num_p = (selections == null) ? 0: selections.length; int num_p = (selections == null) ? 0: selections.length; int num_pm = num_ml * num_p; int num_pm = num_ml * num_p; int num_pd = (planes != null) ? (planes.length - LOWEST_PLANE(planes.length)) : 0; int num_pd = (planes != null) ? (planes.length - LOWEST_PLANE(planes.length)) : 0; final double [][] lapWeight = getLapWeights(); double [][] data = new double [num_pm + 3 * num_ml + 4 * num_pd ][]; // 4* superTileSize*superTileSize]; double [][] data = new double [num_pm + 3 * num_ml + 4 * num_pd ][]; // 4* superTileSize*superTileSize]; for (int np = 0; np < num_p; np++) if (selections [np] != null){ for (int np = 0; np < num_p; np++) if (selections [np] != null){ for (int ml = 0; ml < num_ml; ml++) if ((disp_strength[ml]!=null) && (selections[np][ml] != null)){ for (int ml = 0; ml < num_ml; ml++) if ((disp_strength[ml]!=null) && (selections[np][ml] != null)){ Loading Loading @@ -1185,7 +1186,14 @@ public class SuperTiles{ } } } } data [num_pm + 0 * num_ml + ml] = disp_strength[ml][0]; data [num_pm + 0 * num_ml + ml] = disp_strength[ml][0]; data [num_pm + 1 * num_ml + ml] = disp_strength[ml][1]; data [num_pm + 1 * num_ml + ml] = disp_strength[ml][1].clone(); // undo lapweight to show for (int sty = 0; sty < 2 * superTileSize; sty++){ for (int stx = 0; stx < 2 * superTileSize; stx++){ data [num_pm + 1 * num_ml + ml][stx + 2 * superTileSize * sty] /= lapWeight[sty][stx]; } } } } for (int npd = 0; npd < num_pd; npd++) if (planes[npd +LOWEST_PLANE(planes.length)] != null){ for (int npd = 0; npd < num_pd; npd++) if (planes[npd +LOWEST_PLANE(planes.length)] != null){ double [][] ellipsoids = planes[npd +LOWEST_PLANE(planes.length)].getDoublePlaneDisparityStrength( double [][] ellipsoids = planes[npd +LOWEST_PLANE(planes.length)].getDoublePlaneDisparityStrength( Loading Loading @@ -2099,15 +2107,11 @@ public class SuperTiles{ // separately merge corresponding nonexclusiveStar and nonexclusiveStarEq of these planes - kit is not exact, // separately merge corresponding nonexclusiveStar and nonexclusiveStarEq of these planes - kit is not exact, // but is needed just for a hint and is compatible with multithreading without recalculating other planes // but is needed just for a hint and is compatible with multithreading without recalculating other planes TilePlanes.PlaneData plane1Ex = these_planes[merge_planes[0]].getNonexclusiveStar(); TilePlanes.PlaneData plane1Ex = these_planes[merge_planes[0]].getNonexclusiveStarFb(); if (plane1Ex == null) plane1Ex = these_planes[merge_planes[0]]; TilePlanes.PlaneData plane1ExEq = these_planes[merge_planes[0]].getNonexclusiveStarEqFb(); TilePlanes.PlaneData plane1ExEq = these_planes[merge_planes[0]].getNonexclusiveStarEq(); if (plane1ExEq == null) plane1ExEq = these_planes[merge_planes[0]]; TilePlanes.PlaneData plane2Ex = these_planes[merge_planes[1]].getNonexclusiveStar(); TilePlanes.PlaneData plane2Ex = these_planes[merge_planes[1]].getNonexclusiveStarFb(); if (plane2Ex == null) plane2Ex = these_planes[merge_planes[1]]; TilePlanes.PlaneData plane2ExEq = these_planes[merge_planes[1]].getNonexclusiveStarEqFb(); TilePlanes.PlaneData plane2ExEq = these_planes[merge_planes[1]].getNonexclusiveStarEq(); if (plane2ExEq == null) plane2ExEq = these_planes[merge_planes[1]]; TilePlanes.PlaneData plane1NonExcl = plane1Ex.mergePlaneToThis( TilePlanes.PlaneData plane1NonExcl = plane1Ex.mergePlaneToThis( plane2Ex, // PlaneData otherPd, plane2Ex, // PlaneData otherPd, Loading Loading @@ -5816,7 +5820,7 @@ public class SuperTiles{ int [] neibs = this_new_plane.getNeibBest(); int [] neibs = this_new_plane.getNeibBest(); double [][] costs = new double[neibs.length][]; double [][] costs = new double[neibs.length][]; double [] weights = new double[neibs.length]; double [] weights = new double[neibs.length]; int cost_index = 1; int cost_index = 2; // overall cost double sum_rcosts = 0.0; double sum_rcosts = 0.0; int non_zero = 0; int non_zero = 0; for (int dir = 0; dir < neibs.length; dir++) if (neibs[dir] >= 0) { for (int dir = 0; dir < neibs.length; dir++) if (neibs[dir] >= 0) { Loading @@ -5841,7 +5845,7 @@ public class SuperTiles{ sum_rcosts += weights[dir]; sum_rcosts += weights[dir]; } } for (int dir = 0; dir < neibs.length; dir++) if (neibs[dir] >= 0) { for (int dir = 0; dir < neibs.length; dir++) if (neibs[dir] >= 0) { weights[dir] *= non_zero/sum_rcosts; // average weight fcor active links will be 1.0 weights[dir] *= non_zero/sum_rcosts; // average weight for active links will be 1.0 } } if (dl > 0) { if (dl > 0) { for (int dir = 0; dir <8; dir++)if (costs[dir] != null){ for (int dir = 0; dir <8; dir++)if (costs[dir] != null){ Loading @@ -5856,7 +5860,7 @@ public class SuperTiles{ System.out.println(); System.out.println(); } } this_new_plane =this_new_plane.clone(); // not to change weight! this_new_plane.setWeight(0.0); // this_new_plane.setWeight(0.0); // double num_merged = 0.0; // double to add fractional pull weight of the center double num_merged = 0.0; // double to add fractional pull weight of the center for (int dir = 0; dir < neibs.length; dir++){ for (int dir = 0; dir < neibs.length; dir++){ Loading
src/main/java/TilePlanes.java +42 −17 Original line number Original line Diff line number Diff line Loading @@ -294,6 +294,12 @@ public class TilePlanes { { { return this.nonexclusiveStar; return this.nonexclusiveStar; } } public PlaneData getNonexclusiveStarFb() // fallback to this plane if nonexclusiveStar is not available { if (this.nonexclusiveStar != null) return this.nonexclusiveStar; return this; } public void setNonexclusiveStar( PlaneData pd) public void setNonexclusiveStar( PlaneData pd) { { this.nonexclusiveStar = pd; this.nonexclusiveStar = pd; Loading @@ -303,6 +309,14 @@ public class TilePlanes { { { return this.nonexclusiveStarEq; return this.nonexclusiveStarEq; } } public PlaneData getNonexclusiveStarEqFb() // fallback to this plane if nonexclusiveStarEq is not available { if (this.nonexclusiveStarEq != null) return this.nonexclusiveStarEq; return this; } public void setNonexclusiveStarEq( PlaneData pd) public void setNonexclusiveStarEq( PlaneData pd) { { this.nonexclusiveStarEq = pd; this.nonexclusiveStarEq = pd; Loading Loading @@ -2792,7 +2806,7 @@ public class TilePlanes { System.out.println("Zero eigenvalue"); System.out.println("Zero eigenvalue"); debugLevel = 10; debugLevel = 10; } } if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("other_eig_vals"); System.out.println("other_eig_vals"); other_eig_vals.print(8, 6); other_eig_vals.print(8, 6); System.out.println("this_eig_vals"); System.out.println("this_eig_vals"); Loading Loading @@ -2820,7 +2834,7 @@ public class TilePlanes { Matrix other_covar = other_eig_vectors.times(other_eig_vals.times(other_eig_vectors.transpose())); Matrix other_covar = other_eig_vectors.times(other_eig_vals.times(other_eig_vectors.transpose())); Matrix this_covar = this_eig_vectors.times(this_eig_vals.times(this_eig_vectors.transpose())); Matrix this_covar = this_eig_vectors.times(this_eig_vals.times(this_eig_vectors.transpose())); Matrix covar = (new Matrix(acovar)).times(other_fraction*(1.0-other_fraction)); // only centers with all masses Matrix covar = (new Matrix(acovar)).times(other_fraction*(1.0-other_fraction)); // only centers with all masses if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("other_covar"); System.out.println("other_covar"); other_covar.print(8, 6); other_covar.print(8, 6); System.out.println("this_covar"); System.out.println("this_covar"); Loading @@ -2830,12 +2844,12 @@ public class TilePlanes { } } covar.plusEquals(other_covar.times(other_fraction)); covar.plusEquals(other_covar.times(other_fraction)); if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("covar with other_covar"); System.out.println("covar with other_covar"); covar.print(8, 6); covar.print(8, 6); } } covar.plusEquals(this_covar.times(1.0 - other_fraction)); covar.plusEquals(this_covar.times(1.0 - other_fraction)); if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("covar with other_covar and this_covar"); System.out.println("covar with other_covar and this_covar"); covar.print(8, 6); covar.print(8, 6); } } Loading @@ -2847,7 +2861,7 @@ public class TilePlanes { EigenvalueDecomposition eig = covar.eig(); // verify NaN - it gets stuck EigenvalueDecomposition eig = covar.eig(); // verify NaN - it gets stuck // eig.getD().getArray(), // eig.getD().getArray(), // eig.getV().getArray(), // eig.getV().getArray(), if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("eig.getV()"); System.out.println("eig.getV()"); eig.getV().print(8, 6); eig.getV().print(8, 6); System.out.println("eig.getD()"); System.out.println("eig.getD()"); Loading Loading @@ -2985,7 +2999,7 @@ public class TilePlanes { System.out.println("Zero eigenvalue"); System.out.println("Zero eigenvalue"); debugLevel = 10; debugLevel = 10; } } if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("other_eig_vals"); System.out.println("other_eig_vals"); other_eig_vals.print(8, 6); other_eig_vals.print(8, 6); System.out.println("this_eig_vals"); System.out.println("this_eig_vals"); Loading Loading @@ -3013,7 +3027,7 @@ public class TilePlanes { Matrix other_covar = other_eig_vectors.times(other_eig_vals.times(other_eig_vectors.transpose())); Matrix other_covar = other_eig_vectors.times(other_eig_vals.times(other_eig_vectors.transpose())); Matrix this_covar = this_eig_vectors.times(this_eig_vals.times(this_eig_vectors.transpose())); Matrix this_covar = this_eig_vectors.times(this_eig_vals.times(this_eig_vectors.transpose())); Matrix covar = (new Matrix(acovar)).times(other_fraction*(1.0-other_fraction)); // only centers with all masses Matrix covar = (new Matrix(acovar)).times(other_fraction*(1.0-other_fraction)); // only centers with all masses if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("other_covar"); System.out.println("other_covar"); other_covar.print(8, 6); other_covar.print(8, 6); System.out.println("this_covar"); System.out.println("this_covar"); Loading @@ -3023,12 +3037,12 @@ public class TilePlanes { } } covar.plusEquals(other_covar.times(other_fraction)); covar.plusEquals(other_covar.times(other_fraction)); if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("covar with other_covar"); System.out.println("covar with other_covar"); covar.print(8, 6); covar.print(8, 6); } } covar.plusEquals(this_covar.times(1.0 - other_fraction)); covar.plusEquals(this_covar.times(1.0 - other_fraction)); if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("covar with other_covar and this_covar"); System.out.println("covar with other_covar and this_covar"); covar.print(8, 6); covar.print(8, 6); } } Loading @@ -3040,7 +3054,7 @@ public class TilePlanes { EigenvalueDecomposition eig = covar.eig(); // verify NaN - it gets stuck EigenvalueDecomposition eig = covar.eig(); // verify NaN - it gets stuck // eig.getD().getArray(), // eig.getD().getArray(), // eig.getV().getArray(), // eig.getV().getArray(), if (debugLevel > 0) { if (debugLevel > 1) { System.out.println("eig.getV()"); System.out.println("eig.getV()"); eig.getV().print(8, 6); eig.getV().print(8, 6); System.out.println("eig.getD()"); System.out.println("eig.getD()"); Loading Loading @@ -3093,9 +3107,6 @@ public class TilePlanes { for (int i = 0; i < 3; i ++) plane[2][i] = -plane[2][i]; for (int i = 0; i < 3; i ++) plane[2][i] = -plane[2][i]; } } // PlaneData pd = this.clone(); // will copy selections too // pd.invalidateCalculated(); // real world vectors pd_partial.setWValues(eig_val[oindx][oindx],eig_val[vindx][vindx],eig_val[hindx][hindx]); // eigenvalues [0] - thickness, 2 other to detect skinny (poles) pd_partial.setWValues(eig_val[oindx][oindx],eig_val[vindx][vindx],eig_val[hindx][hindx]); // eigenvalues [0] - thickness, 2 other to detect skinny (poles) pd_partial.setWVectors(plane); pd_partial.setWVectors(plane); Loading @@ -3114,6 +3125,20 @@ public class TilePlanes { } } pd_partial.setWeight(new_weight); pd_partial.setWeight(new_weight); } } if (debugLevel > 2) { double L1 = getWValue(); double L2 = otherPd.getWValue(); double W1 = 1.0 - other_fraction; double W2 = other_fraction; double Lav = (L1*W1 + L2*W2)/(W1+W2); double L = pd_partial.getWValue(); if ((L*1.000001 < Lav) || (debugLevel > 0)){ System.out.println("========== mergePlaneToThisWorld(): L1="+L1+", L2 = "+L2+", W1="+W1+", W2="+W2+", Lav = "+Lav+", L="+L+ ", L-Lav="+(L-Lav)+", scale_other="+scale_other+", other_fraction="+other_fraction); System.out.println(); } } return pd_partial; return pd_partial; } } Loading Loading @@ -4140,12 +4165,12 @@ public class TilePlanes { } } } } mask[np] = prev_used[np].clone(); mask[np] = prev_used[np].clone(); if (plDiscrGrown > 0) { if (plDiscrGrown > 100) { // >0 tileNeibs.growSelection( tileNeibs.growSelection( plDiscrGrown, // int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more plDiscrGrown, // int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more mask[np], // boolean [] tiles, mask[np], // boolean [] tiles, null); // boolean [] prohibit) null); // boolean [] prohibit) } else if (plDiscrGrown < 0){ } else if (plDiscrGrown < 100){ //< 0 for (int indx = 0; indx < size2; indx++) mask[np][indx] = true; for (int indx = 0; indx < size2; indx++) mask[np][indx] = true; } } Loading @@ -4162,7 +4187,7 @@ public class TilePlanes { } } } } } } if (plDiscrSteal > 0){ if (0 * plDiscrSteal > 0){ // 0* for (int np = 0; np < num_planes; np++){ for (int np = 0; np < num_planes; np++){ for (int np1 = 0; np1 < num_planes; np1++) if (np1 != np){ for (int np1 = 0; np1 < num_planes; np1++) if (np1 != np){ for (int indx = 0; indx < size2; indx++){ for (int indx = 0; indx < size2; indx++){ Loading
src/main/java/TileProcessor.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -3307,6 +3307,7 @@ public class TileProcessor { merge_candidates, // final int [][][] merge_candidates, merge_candidates, // final int [][][] merge_candidates, plane_nooverlaps, // final boolean [][][] valid_candidates, // will be updated plane_nooverlaps, // final boolean [][][] valid_candidates, // will be updated true, // final boolean merge_low_eigen, here it should be true true, // final boolean merge_low_eigen, here it should be true true, // final boolean useNonExcl, // consider only directions available for non-exclusive merges 2, // -1, // debugLevel, // final int debugLevel) 2, // -1, // debugLevel, // final int debugLevel) clt_parameters.tileX, clt_parameters.tileX, clt_parameters.tileY); clt_parameters.tileY); Loading Loading @@ -3766,7 +3767,7 @@ public class TileProcessor { clt_parameters.plNormPow, // 0.0: 8 neighbors pull 8 times as 1, 1.0 - same as 1 clt_parameters.plNormPow, // 0.0: 8 neighbors pull 8 times as 1, 1.0 - same as 1 Math.pow(10.0, -clt_parameters.plPrecision), // final double maxDiff, // maximal change in any of the disparity values Math.pow(10.0, -clt_parameters.plPrecision), // final double maxDiff, // maximal change in any of the disparity values clt_parameters.plPreferDisparity, clt_parameters.plPreferDisparity, 1,// 0, // final int debugLevel) 0, // 1,// 0, // final int debugLevel) clt_parameters.tileX, clt_parameters.tileX, clt_parameters.tileY); clt_parameters.tileY); } else { } else { Loading