Commit 73b9d03b authored by Andrey Filippov's avatar Andrey Filippov
Browse files

redesigning shell extraction

parent c5a866f4
Loading
Loading
Loading
Loading
+38 −5
Original line number Original line Diff line number Diff line
@@ -2155,6 +2155,13 @@ public class EyesisCorrectionParameters {
  		
  		
  		public boolean    plPreferDisparity    =   false;// Always start with disparity-most axis (false - lowest eigenvalue)
  		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 double     plBlurBinVert        =   1.2;  // Blur disparity histograms for constant disparity clusters by this sigma (in bins)
  		public double     plBlurBinHor         =   0.8;  // Blur disparity histograms for horizontal clusters by this sigma (in bins)
  		public double     plMaxDiffVert        =   0.4;  // Maximal normalized disparity difference when initially assigning to vertical plane
  		public double     plMaxDiffHor         =   0.2;  // Maximal normalized disparity difference when initially assigning to horizontal plane
  		public int        plInitPasses         =     3;  // Number of initial passes to assign tiles to vert (const disparity) and hor planes
  		
  		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
  		public double     plFractOutliers      =   0.3;  // Maximal fraction of outliers to remove
  		public double     plFractOutliers      =   0.3;  // Maximal fraction of outliers to remove
@@ -2453,6 +2460,13 @@ public class EyesisCorrectionParameters {


			properties.setProperty(prefix+"plPreferDisparity",this.plPreferDisparity+"");
			properties.setProperty(prefix+"plPreferDisparity",this.plPreferDisparity+"");
			properties.setProperty(prefix+"plDispNorm",       this.plDispNorm +"");
			properties.setProperty(prefix+"plDispNorm",       this.plDispNorm +"");

			properties.setProperty(prefix+"plBlurBinVert",    this.plBlurBinVert +"");
			properties.setProperty(prefix+"plBlurBinHor",     this.plBlurBinHor +"");
			properties.setProperty(prefix+"plMaxDiffVert",    this.plMaxDiffVert +"");
			properties.setProperty(prefix+"plMaxDiffHor",     this.plMaxDiffHor +"");
  			properties.setProperty(prefix+"plInitPasses",     this.plInitPasses+"");
			
			properties.setProperty(prefix+"plMinPoints",      this.plMinPoints+"");
			properties.setProperty(prefix+"plMinPoints",      this.plMinPoints+"");
			properties.setProperty(prefix+"plTargetEigen",    this.plTargetEigen +"");
			properties.setProperty(prefix+"plTargetEigen",    this.plTargetEigen +"");
			properties.setProperty(prefix+"plFractOutliers",  this.plFractOutliers +"");
			properties.setProperty(prefix+"plFractOutliers",  this.plFractOutliers +"");
@@ -2463,10 +2477,8 @@ public class EyesisCorrectionParameters {
			properties.setProperty(prefix+"plWorstWorsening", this.plWorstWorsening +"");
			properties.setProperty(prefix+"plWorstWorsening", this.plWorstWorsening +"");
			properties.setProperty(prefix+"plWeakWorsening",  this.plWeakWorsening +"");
			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+"");
			properties.setProperty(prefix+"plCutCorners",     this.plCutCorners+"");
			properties.setProperty(prefix+"plCutCorners",     this.plCutCorners+"");

			properties.setProperty(prefix+"plPull",           this.plPull +"");
			properties.setProperty(prefix+"plPull",           this.plPull +"");
			properties.setProperty(prefix+"plNormPow",        this.plNormPow +"");
			properties.setProperty(prefix+"plNormPow",        this.plNormPow +"");
  			properties.setProperty(prefix+"plIterations",     this.plIterations+"");
  			properties.setProperty(prefix+"plIterations",     this.plIterations+"");
@@ -2738,6 +2750,13 @@ public class EyesisCorrectionParameters {


  			if (properties.getProperty(prefix+"plPreferDisparity")!=null) this.plPreferDisparity=Boolean.parseBoolean(properties.getProperty(prefix+"plPreferDisparity"));
  			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+"plBlurBinVert")!=null)     this.plBlurBinVert=Double.parseDouble(properties.getProperty(prefix+"plBlurBinVert"));
  			if (properties.getProperty(prefix+"plBlurBinHor")!=null)      this.plBlurBinHor=Double.parseDouble(properties.getProperty(prefix+"plBlurBinHor"));
  			if (properties.getProperty(prefix+"plMaxDiffVert")!=null)     this.plMaxDiffVert=Double.parseDouble(properties.getProperty(prefix+"plMaxDiffVert"));
  			if (properties.getProperty(prefix+"plMaxDiffHor")!=null)      this.plMaxDiffHor=Double.parseDouble(properties.getProperty(prefix+"plMaxDiffHor"));
  			if (properties.getProperty(prefix+"plInitPasses")!=null)      this.plInitPasses=Integer.parseInt(properties.getProperty(prefix+"plInitPasses"));
  			
  			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"));
  			if (properties.getProperty(prefix+"plFractOutliers")!=null)   this.plFractOutliers=Double.parseDouble(properties.getProperty(prefix+"plFractOutliers"));
  			if (properties.getProperty(prefix+"plFractOutliers")!=null)   this.plFractOutliers=Double.parseDouble(properties.getProperty(prefix+"plFractOutliers"));
@@ -3047,6 +3066,13 @@ public class EyesisCorrectionParameters {
  			gd.addMessage     ("--- Planes detection ---");
  			gd.addMessage     ("--- Planes detection ---");
  			gd.addCheckbox    ("Always start with disparity-most axis (false - lowest eigenvalue)",            this.plPreferDisparity);
  			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("Blur disparity histograms for constant disparity clusters by this sigma (in bins)",   this.plBlurBinVert,  6);
  			gd.addNumericField("Blur disparity histograms for horizontal clusters by this sigma (in bins)",           this.plBlurBinHor,  6);
  			gd.addNumericField("Maximal normalized disparity difference when initially assigning to vertical plane",  this.plMaxDiffVert,  6);
  			gd.addNumericField("Maximal normalized disparity difference when initially assigning to horizontal plane",this.plMaxDiffHor,  6);
  			gd.addNumericField("Number of initial passes to assign tiles to vert (const disparity) and hor planes",   this.plInitPasses,  0);
  			
  			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);
  			gd.addNumericField("Maximal fraction of outliers to remove",                                       this.plFractOutliers,  6);
  			gd.addNumericField("Maximal fraction of outliers to remove",                                       this.plFractOutliers,  6);
@@ -3340,6 +3366,13 @@ public class EyesisCorrectionParameters {


  			this.plPreferDisparity=     gd.getNextBoolean();
  			this.plPreferDisparity=     gd.getNextBoolean();
  			this.plDispNorm=            gd.getNextNumber();
  			this.plDispNorm=            gd.getNextNumber();

  			this.plBlurBinVert=         gd.getNextNumber();
  			this.plBlurBinHor=          gd.getNextNumber();
  			this.plMaxDiffVert=         gd.getNextNumber();
  			this.plMaxDiffHor=          gd.getNextNumber();
  			this.plInitPasses=    (int) gd.getNextNumber();
  			
  			this.plMinPoints=     (int) gd.getNextNumber();
  			this.plMinPoints=     (int) gd.getNextNumber();
  			this.plTargetEigen=         gd.getNextNumber();
  			this.plTargetEigen=         gd.getNextNumber();
  			this.plFractOutliers=       gd.getNextNumber();
  			this.plFractOutliers=       gd.getNextNumber();
+823 −230

File changed.

Preview size limit exceeded, changes collapsed.

+98 −43
Original line number Original line Diff line number Diff line
@@ -166,6 +166,10 @@ public class TilePlanes {
			return 	this.measuredSelection[nl];
			return 	this.measuredSelection[nl];
		}
		}


		public boolean [][] getMeasSelection(){
			return 	this.measuredSelection;
		}
		
		
		
		public MeasuredLayers getMeasuredLayers()
		public MeasuredLayers getMeasuredLayers()
		{
		{
@@ -1006,10 +1010,8 @@ public class TilePlanes {
				debugLevel = 20;
				debugLevel = 20;
			}
			}
			
			
//			if (eig.getD().get(0, 0) == 0.0){
			if (debugLevel > 3){
//				debugLevel = 10;
//				if (debugLevel > 0){
//			}
			if (debugLevel > 0){
				System.out.println("getCovar(): sw = "+sw +", swz = "+swz +", swx = "+swx +", swy = "+swy +", covar.det() = "+covar.det());
				System.out.println("getCovar(): sw = "+sw +", swz = "+swz +", swx = "+swx +", swy = "+swy +", covar.det() = "+covar.det());
				System.out.println("getCovar(): covarianvce matrix, number of used points:"+num_tiles);
				System.out.println("getCovar(): covarianvce matrix, number of used points:"+num_tiles);
				covar.print(10, 6); // w,d
				covar.print(10, 6); // w,d
@@ -1022,15 +1024,6 @@ public class TilePlanes {
				return null; // testing with zero eigenvalue
				return null; // testing with zero eigenvalue
				// Problem with zero eigenvalue is with derivatives and coordinate conversion
				// Problem with zero eigenvalue is with derivatives and coordinate conversion
			}
			}
/*			
			double [][][] rslt = {
					eig.getD().getArray(),
					eig.getV().getArray(),
					{
						{sw,kz,numPoints},
						{swz, swx, swy}}};
			return rslt;
*/


			double [][] eig_val =  eig.getD().getArray(); // rslt[0];
			double [][] eig_val =  eig.getD().getArray(); // rslt[0];
			double [][] eig_vect = eig.getV().getArray(); // rslt[1];
			double [][] eig_vect = eig.getV().getArray(); // rslt[1];
@@ -1390,10 +1383,76 @@ public class TilePlanes {
			return plane;
			return plane;
		}
		}


		/**
		 * Get disparity values for the tiles of this overlapping supertile as [2*superTileSize * 2*superTileSize] array
		 * and weights combined from provided window function, optional selection and using ellipsoid projection on the
		 * px, py plane (constant disparity
		 * @param window null or window function as [2*superTileSize * 2*superTileSize] array
		 * @param use_sel use plane selection (this.sel_mask) to select only some part of the plane
		 * @param scale_projection use plane ellipsoid projection for weight: 0 - do not use, > 0 linearly scale ellipsoid 
		 * @return a pair of ar5rays {disparity, strength}, each [2*superTileSize * 2*superTileSize]
		 */
		public double[][] getDoublePlaneDisparityStrength(
				double [] window,
				boolean   use_sel,
				double    scale_projection,
				int       debugLevel)
		{
			double [][] disp_strength = new double[2][4*superTileSize*superTileSize];
			int indx = 0;
			double [] normal = getVector();
			double [] zxy =    getZxy(); // {disparity, x center in pixels, y center in pixels (relative to a supertile center)
			double    weight = getWeight();
			double k_gauss = 0;
			Matrix val2d = null, vect2d = null;
			if (scale_projection > 0.0){
				double [] vals3d =      getValues();
				double [][] vectors3d = getVectors();
				double [][] acovar = new double [2][2];
				for (int i = 0; i < 2; i++){
					for (int j = i; j < 2; j++){
						acovar[i][j] = 0.0;
						for (int k = 0; k < 3; k++){
							acovar[i][j] += vals3d[k] * vectors3d[k][i+1] * vectors3d[k][j+1]; // 0 - z, disparity == 0
						}
						if (i != j) {
							acovar[j][i] =acovar[i][j];
						}
					}
				}
				Matrix covar = new Matrix(acovar); // 2d, x y only
				EigenvalueDecomposition eig = covar.eig();
				val2d = eig.getD();
				vect2d = eig.getV().transpose();
				k_gauss = 0.5/(scale_projection*scale_projection);
			}


//		double px = tileSize*(superTileSize * sTileXY[0] + superTileSize/2) + zxy[1];  // [3] - plane point {disparity, x, y), x=0, y=0 is a 4,4 point of an 8x8 supertile
			for (int sy = -superTileSize; sy < superTileSize; sy++){
//		double py = tileSize*(superTileSize * sTileXY[1] + superTileSize/2) + zxy[2];
				// adding half-tile and half-pixel to match the center of the pixel. Supertile center is between
		
				// pixel 31 and pixel 32 (counting from 0) in both directions
				double y = tileSize * (sy + 0.5) + 0.5  - zxy[2];
				for (int sx = -superTileSize; sx < superTileSize; sx++){
					double x = tileSize * (sx + 0.5) + 0.5 - zxy[1];
					disp_strength[0][indx] = zxy[0] - (normal[1] * x + normal[2] * y)/normal[0];
					double w = weight;
					if (window != null) w *= window[indx];
					if (use_sel && (sel_mask != null) && !(sel_mask[indx])) w = 0.0;
					if ((w > 0.0) && (scale_projection > 0.0)){
						double [] xy = {x,y};
						Matrix vxy = vect2d.times(new Matrix(xy,2)); // verify if it is correct
						double r2 = 0; 
						for (int i = 0; i <2; i++){
							double d = vxy.get(i,0);
							r2 += d * d / val2d.get(i, i);
						}
						w *= Math.exp(-k_gauss*r2); // verify it is correct size - maybe it should be -0.5*r2 ?
					}					
					disp_strength[1][indx] = w;
					indx++;
				}
			}
			return disp_strength;
		}




		/**
		/**
@@ -1956,11 +2015,7 @@ public class TilePlanes {
			System.out.println("getCovar(): Double.isNaN(eig.getV().get(0, 0))");
			System.out.println("getCovar(): Double.isNaN(eig.getV().get(0, 0))");
			debugLevel = 20;
			debugLevel = 20;
		}
		}
		
		if (debugLevel > 3){
//		if (eig.getD().get(0, 0) == 0.0){
//			debugLevel = 10;
//		}
		if (debugLevel > 0){
			System.out.println("getCovar(): sw = "+sw +", swz = "+swz +", swx = "+swx +", swy = "+swy +", covar.det() = "+covar.det());
			System.out.println("getCovar(): sw = "+sw +", swz = "+swz +", swx = "+swx +", swy = "+swy +", covar.det() = "+covar.det());
			System.out.println("getCovar(): covarianvce matrix, number of used points:"+numPoints);
			System.out.println("getCovar(): covarianvce matrix, number of used points:"+numPoints);
			covar.print(10, 6); // w,d
			covar.print(10, 6); // w,d
+104 −23
Original line number Original line Diff line number Diff line
@@ -3042,9 +3042,9 @@ public class TileProcessor {
		
		
// moved here
// moved here
		if (clt_parameters.dbg_migrate) {
		if (clt_parameters.dbg_migrate) {
		st.processPlanes4(
			// separate each supertile data into clusters, trying both horizontal and perpendicular to view planes
//				null, // final boolean [] selected, // or null
			double []  world_hor = {0.0, 1.0, 0.0};
//				0.3, // final double     min_disp,
			st.processPlanes5(
					clt_parameters.stMeasSel,       //      =     1   //Select measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
					clt_parameters.stMeasSel,       //      =     1   //Select measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
					clt_parameters.plDispNorm,      //      =   2.0;  // Normalize disparities to the average if above
					clt_parameters.plDispNorm,      //      =   2.0;  // Normalize disparities to the average if above
					clt_parameters.plMinPoints,     //      =     5;  // Minimal number of points for plane detection
					clt_parameters.plMinPoints,     //      =     5;  // Minimal number of points for plane detection
@@ -3054,17 +3054,50 @@ public class TileProcessor {
					clt_parameters.plPreferDisparity,
					clt_parameters.plPreferDisparity,
					geometryCorrection,
					geometryCorrection,
					clt_parameters.correct_distortions,
					clt_parameters.correct_distortions,

					clt_parameters.stSmplMode ,     // final boolean                    smplMode, //        = true;   // Use sample mode (false - regular tile mode)
					clt_parameters.stSmplMode ,     // final boolean                    smplMode, //        = true;   // Use sample mode (false - regular tile mode)
					clt_parameters.stSmplSide ,     // final int                        smplSide, //        = 2;      // Sample size (side of a square)
					clt_parameters.stSmplSide ,     // final int                        smplSide, //        = 2;      // Sample size (side of a square)
					clt_parameters.stSmplNum ,      // final int                        smplNum, //         = 3;      // Number after removing worst
					clt_parameters.stSmplNum ,      // final int                        smplNum, //         = 3;      // Number after removing worst
					clt_parameters.stSmplRms ,      // final double                     smplRms, //         = 0.1;    // Maximal RMS of the remaining tiles in a sample
					clt_parameters.stSmplRms ,      // final double                     smplRms, //         = 0.1;    // Maximal RMS of the remaining tiles in a sample

					clt_parameters.plBlurBinHor,    // final double     bin_blur_hor,   // Blur disparity histograms for horizontal clusters by this sigma (in bins)
					clt_parameters.plBlurBinVert,   // final double     bin_blur_vert,  // Blur disparity histograms for constant disparity clusters by this sigma (in bins)
					clt_parameters.plMaxDiffHor,    // final double     max_diff_hor,   // maximal disparity difference (to assign to a cluster (of Double.NaN) at first run for horizontal planes
					clt_parameters.plMaxDiffVert,   // final double     max_diff_vert,  // maximal disparity difference (to assign to a cluster (of Double.NaN) at first run for vertical plane
					clt_parameters.plInitPasses,    // final int        max_tries,       // on last run - assign all rfemaining pixels to some cluster (disregard max_diff)

					clt_parameters.stSmallDiff,     //       = 0.4;   // Consider merging initial planes if disparity difference below
					clt_parameters.stSmallDiff,     //       = 0.4;   // Consider merging initial planes if disparity difference below
					clt_parameters.stHighMix,       // stHighMix         = 0.4;   // Consider merging initial planes if jumps between ratio above
					clt_parameters.stHighMix,       // stHighMix         = 0.4;   // Consider merging initial planes if jumps between ratio above
				clt_parameters.vertical_xyz,
					world_hor,                      // final double []  world_hor, // horizontal plane normal (default [0.0, 1.0, 0.0])
					0, // -1,                       // debugLevel,                  // final int        debugLevel)
					0, // -1,                       // debugLevel,                  // final int        debugLevel)
					clt_parameters.tileX,
					clt_parameters.tileX,
					clt_parameters.tileY);
					clt_parameters.tileY);
		} else {
		} else {
			st.processPlanes4(
					clt_parameters.stMeasSel, //            =     1   //Select measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
					clt_parameters.plDispNorm, //           =   2.0;  // Normalize disparities to the average if above
					clt_parameters.plMinPoints, //          =     5;  // Minimal number of points for plane detection
					clt_parameters.plTargetEigen, //        =   0.1;  // Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below
					clt_parameters.plFractOutliers, //      =   0.3;  // Maximal fraction of outliers to remove
					clt_parameters.plMaxOutliers, //        =    20;  // Maximal number of outliers to remove\
					clt_parameters.plPreferDisparity,
					geometryCorrection,
					clt_parameters.correct_distortions,
					clt_parameters.stSmplMode , // final boolean                    smplMode, //        = true;   // Use sample mode (false - regular tile mode)
					clt_parameters.stSmplSide , // final int                        smplSide, //        = 2;      // Sample size (side of a square)
					clt_parameters.stSmplNum ,  // final int                        smplNum, //         = 3;      // Number after removing worst
					clt_parameters.stSmplRms ,  // final double                     smplRms, //         = 0.1;    // Maximal RMS of the remaining tiles in a sample

					clt_parameters.plBlurBinHor,    // final double     bin_blur_hor,   // Blur disparity histograms for horizontal clusters by this sigma (in bins)
					clt_parameters.plBlurBinVert,   // final double     bin_blur_vert,  // Blur disparity histograms for constant disparity clusters by this sigma (in bins)

					clt_parameters.stSmallDiff, //       = 0.4;   // Consider merging initial planes if disparity difference below
					clt_parameters.stHighMix, //stHighMix         = 0.4;   // Consider merging initial planes if jumps between ratio above
					//					clt_parameters.vertical_xyz,
					0, // -1, // debugLevel,                  // final int        debugLevel)
					clt_parameters.tileX,
					clt_parameters.tileY);
/*			
			st.processPlanes3(
			st.processPlanes3(
					null, // final boolean [] selected, // or null
					null, // final boolean [] selected, // or null
					0.3, // final double     min_disp,
					0.3, // final double     min_disp,
@@ -3086,6 +3119,7 @@ public class TileProcessor {
					0, // -1, // debugLevel,                  // final int        debugLevel)
					0, // -1, // debugLevel,                  // final int        debugLevel)
					clt_parameters.tileX,
					clt_parameters.tileX,
					clt_parameters.tileY);
					clt_parameters.tileY);
*/					
		}
		}
		
		
		showDoubleFloatArrays sdfa_instance = null;
		showDoubleFloatArrays sdfa_instance = null;
@@ -3093,6 +3127,7 @@ public class TileProcessor {


		st.matchPlanes(
		st.matchPlanes(
				clt_parameters.plPreferDisparity,
				clt_parameters.plPreferDisparity,
				0, // debugLevel
				clt_parameters.tileX,
				clt_parameters.tileX,
				clt_parameters.tileY); 
				clt_parameters.tileY); 


@@ -3172,6 +3207,7 @@ public class TileProcessor {
			// now re-create connections and best neighbors
			// now re-create connections and best neighbors
			st.matchPlanes(
			st.matchPlanes(
					clt_parameters.plPreferDisparity,
					clt_parameters.plPreferDisparity,
					0, // debugLevel
					clt_parameters.tileX,
					clt_parameters.tileX,
					clt_parameters.tileY); 
					clt_parameters.tileY); 


@@ -3220,6 +3256,8 @@ public class TileProcessor {
					0, // final int debugLevel)
					0, // final int debugLevel)
					clt_parameters.tileX,
					clt_parameters.tileX,
					clt_parameters.tileY); 
					clt_parameters.tileY); 
		} else {
			st.planes_mod = st.planes; // just use the measured ones
		}
		}
		// filter out weak planes, create boolean array [per-supertile][per disparity plane]
		// filter out weak planes, create boolean array [per-supertile][per disparity plane]
		boolean [][] selected_planes =	st.selectPlanes(
		boolean [][] selected_planes =	st.selectPlanes(
@@ -3235,11 +3273,14 @@ public class TileProcessor {
				clt_parameters.plKeepOrphans,             // true, // boolean                   keep_orphans, // single-cell shells
				clt_parameters.plKeepOrphans,             // true, // boolean                   keep_orphans, // single-cell shells
				clt_parameters.plMinOrphan, // orphan_strength // add separate parameter
				clt_parameters.plMinOrphan, // orphan_strength // add separate parameter
				st.getPlanesMod(), // TilePlanes.PlaneData [][] planes,
				st.getPlanesMod(), // TilePlanes.PlaneData [][] planes,
				1); // int                       debugLevel)
				1, // final int debugLevel)
				clt_parameters.tileX,
				clt_parameters.tileY); 
		// save shell indices with SuperTiles instance
		// save shell indices with SuperTiles instance
		st.setShellMap(shells); // persistent
		st.setShellMap(shells); // persistent
		// Create array [per shell][per tile] of shell disparities. tiles of unused supertiles are Double.NaN
		// Create array [per shell][per tile] of shell disparities. tiles of unused supertiles are Double.NaN
		double [][] surfaces = st.getShowShells(
		double [][] surfaces = st.getShowShells(
				0, // int  nlayer, // over multi-layer - do not render more than nlayer on top of each other
				st.getPlanesMod(),   // TilePlanes.PlaneData [][] planes,
				st.getPlanesMod(),   // TilePlanes.PlaneData [][] planes,
				st.getShellMap(), // shells,              // int [][] shells,
				st.getShellMap(), // shells,              // int [][] shells,
				1000,                 // int max_shells,
				1000,                 // int max_shells,
@@ -3313,6 +3354,7 @@ public class TileProcessor {
			sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "plane_data");
			sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "plane_data");
			
			
			plane_data = st.getShowShells(
			plane_data = st.getShowShells(
					0, // int  nlayer, // over multi-layer - do not render more than nlayer on top of each other
					st.getPlanesMod(),   // TilePlanes.PlaneData [][] planes,
					st.getPlanesMod(),   // TilePlanes.PlaneData [][] planes,
					st.getShellMap(), // shells,              // int [][] shells,
					st.getShellMap(), // shells,              // int [][] shells,
					100,                 // int max_shells,
					100,                 // int max_shells,
@@ -3325,6 +3367,20 @@ public class TileProcessor {
			sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "shells_all");
			sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "shells_all");


			plane_data = st.getShowShells(
			plane_data = st.getShowShells(
					1, // int  nlayer, // over multi-layer - do not render more than nlayer on top of each other
					st.getPlanesMod(),   // TilePlanes.PlaneData [][] planes,
					st.getShellMap(), // shells,              // int [][] shells,
					100,                 // int max_shells,
					clt_parameters.plFuse,// boolean fuse,
					false,               // boolean show_connections,
					false,               // boolean use_NaN,
					10.0,                 // double arrow_dark,
					10.0);               // double arrow_white)
			
			sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "shells2_all");
			
			plane_data = st.getShowShells(
					0, // int  nlayer, // over multi-layer - do not render more than nlayer on top of each other
					st.getPlanesMod(),   // TilePlanes.PlaneData [][] planes,
					st.getPlanesMod(),   // TilePlanes.PlaneData [][] planes,
					st.getShellMap(), // shells,              // int [][] shells,
					st.getShellMap(), // shells,              // int [][] shells,
					100,                 // int max_shells,
					100,                 // int max_shells,
@@ -3335,8 +3391,21 @@ public class TileProcessor {
					10.0);               // double arrow_white)
					10.0);               // double arrow_white)
			sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "shells_all_arrows");
			sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "shells_all_arrows");


			plane_data = st.getShowShells(
					1, // int  nlayer, // over multi-layer - do not render more than nlayer on top of each other
					st.getPlanesMod(),   // TilePlanes.PlaneData [][] planes,
					st.getShellMap(), // shells,              // int [][] shells,
					100,                 // int max_shells,
					clt_parameters.plFuse,// boolean fuse,
					true,                // boolean show_connections,
					false,               // boolean use_NaN,
					10.0,                 // double arrow_dark,
					10.0);               // double arrow_white)
			sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "shells2_all_arrows");

			
			
			plane_data = st.getShowShells(
			plane_data = st.getShowShells(
					0, // int  nlayer, // over multi-layer - do not render more than nlayer on top of each other
					st.getPlanesMod(),   // TilePlanes.PlaneData [][] planes,
					st.getPlanesMod(),   // TilePlanes.PlaneData [][] planes,
					st.getShellMap(), // shells,              // int [][] shells,
					st.getShellMap(), // shells,              // int [][] shells,
					100,                 // int max_shells,
					100,                 // int max_shells,
@@ -3346,6 +3415,18 @@ public class TileProcessor {
					10.0,                 // double arrow_dark,
					10.0,                 // double arrow_dark,
					10.0);               // double arrow_white)
					10.0);               // double arrow_white)
			sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "shells");
			sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "shells");

			plane_data = st.getShowShells(
					1, // int  nlayer, // over multi-layer - do not render more than nlayer on top of each other
					st.getPlanesMod(),   // TilePlanes.PlaneData [][] planes,
					st.getShellMap(), // shells,              // int [][] shells,
					100,                 // int max_shells,
					clt_parameters.plFuse,// boolean fuse,
					false,               // boolean show_connections,
					true,               // boolean use_NaN,
					10.0,                 // double arrow_dark,
					10.0);               // double arrow_white)
			sdfa_instance.showArrays(plane_data, wh[0], wh[1], true, "shells2");
// also test snap here			
// also test snap here			
			int [] snap_surf =  st.snapSort(
			int [] snap_surf =  st.snapSort(
					st.cltPass3d.getDisparity(),                  // final double []  disparity,
					st.cltPass3d.getDisparity(),                  // final double []  disparity,
+117 −0
Original line number Original line Diff line number Diff line
/**
 **
 ** TileSurface - hadle tile surfaces
 **
 ** Copyright (C) 2017 Elphel, Inc.
 **
 ** -----------------------------------------------------------------------------**
 **  
 **  TileSurface.java is free software: you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License as published by
 **  the Free Software Foundation, either version 3 of the License, or
 **  (at your option) any later version.
 **
 **  This program is distributed in the hope that it will be useful,
 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 **  GNU General Public License for more details.
 **
 **  You should have received a copy of the GNU General Public License
 **  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ** -----------------------------------------------------------------------------**
 **
 */

public class TileSurface {
//	public 
		private int tileSize;
		private int stSize;
		private int tilesX;
		private int tilesY;
		private int [] st_dirs8;
		
//		private int nsTilesstSize =   0; // 8;
		GeometryCorrection   geometryCorrection = null;
		public TileSurface(
				int tileSize,
				int stSize,
				int tilesX,
				int tilesY,
				GeometryCorrection geometryCorrection){
			this.tileSize = tileSize;
			this.stSize = stSize;
			this.geometryCorrection =geometryCorrection;
			this.tilesX =  tilesX;
			this.tilesY =  tilesY;
			int [] dirs =  {-tilesX, -tilesX + 1, 1, tilesX + 1, tilesX, tilesX - 1, -1, -tilesX - 1};
			this.st_dirs8 = dirs;
		}

		public class TileData{
			double disparity;
			double strength;
			double enable;
			int [] neighbors = null;
		}
		/**
		 * Get tile surface number from supertile number, direction (-1 same) and the supertile plane index
		 * @param nsTile number of the supertile
		 * @param dir direction -1 - same supertile, 0 - N (up), 1 - NE, .. 7 - NW
		 * @param np number of the supertile plane
		 * @param planes array of the per-supertile, per plane plane data (each level can be null)
		 * @return unique tile plane index
		 */
		public int getTileSurfaceNumber (
				int nsTile,
				int dir,              // direction, or -1 (same)
				int np,
				TilePlanes.PlaneData [][] planes
				){
			if ((planes[nsTile] == null) || (planes[nsTile][np] == null)){
				return -1; // empty supertile or supertile plane
			}
			if (dir < 0) {
				return np;
			}
			int tsn = planes[nsTile].length;
			for (int d = 0; d < dir; d ++){
				int nsTile1 = nsTile + st_dirs8[d];
				if (planes[nsTile1] != null){
					tsn += planes[nsTile1].length;
				}
			}
			return tsn + np; 
		}
		/**
		 * Get supertile direction and the plane number that contributeted to a specific tile surface 
		 * @param nsTile supertile index
		 * @param tp tile surface index (generated by getTileSurfaceNumber)
		 * @param planes array of the per-supertile, per plane plane data (each level can be null)
		 * @return a pair of {dir, plane index}. dir is -1 for the plane in the same supertile, 0..7 for neighbors
		 */
		
		public int []  getSuperTileDirPlane (
				int nsTile,
				int tp,
				TilePlanes.PlaneData [][] planes
				)
		{
			int num_planes = (planes[nsTile] == null)? 0: planes[nsTile].length;
			int [] rslt = {-1, tp};
			if (tp < num_planes) return rslt;
			tp -= num_planes;
			for (int d = 0; d < st_dirs8.length; d ++){
				int nsTile1 = nsTile + st_dirs8[d];
				num_planes = (planes[nsTile1] == null)? 0: planes[nsTile1].length;
				if (tp < num_planes){
					rslt[0] = d;
					rslt[1] = tp;
					return rslt;
				}
				tp -= num_planes; 
			}
			return null; // error - invalid input
		}

		
}