Commit c44613be authored by Andrey Filippov's avatar Andrey Filippov
Browse files

changing connection costs calculation

parent 67228555
Loading
Loading
Loading
Loading
+14 −4
Original line number Original line Diff line number Diff line
@@ -2022,7 +2022,7 @@ public class EyesisCorrectionParameters {
  		public double     bgnd_sure        = 0.18;  // minimal strength to be considered definitely background
  		public double     bgnd_sure        = 0.18;  // minimal strength to be considered definitely background
  		public double     bgnd_maybe       = 0.1; // maximal strength to ignore as non-background
  		public double     bgnd_maybe       = 0.1; // maximal strength to ignore as non-background
//  		public double     bgnd_2diff       = 0.005; // maximal strength to ignore as non-background
//  		public double     bgnd_2diff       = 0.005; // maximal strength to ignore as non-background
  		public int        min_clstr_seed   = 2;     // number of tiles in a cluster to seed (just background?)
  		public int        min_clstr_seed   = 4; //2;     // number of tiles in a cluster to seed (just background?)
  		public int        min_clstr_lone   = 4;     // number of tiles in a cluster not close to other clusters (more than 2 tiles apart)
  		public int        min_clstr_lone   = 4;     // number of tiles in a cluster not close to other clusters (more than 2 tiles apart)
  		public double     min_clstr_weight = 0.0;   // Minimal total strength of the cluster 
  		public double     min_clstr_weight = 0.0;   // Minimal total strength of the cluster 
  		public double     min_clstr_max    = 0.25;  // Minimal maximal strength of the cluster 
  		public double     min_clstr_max    = 0.25;  // Minimal maximal strength of the cluster 
@@ -2149,7 +2149,7 @@ public class EyesisCorrectionParameters {
  		
  		
  		// Multi-pass growing disparity
  		// Multi-pass growing disparity
  		public int        grow_sweep         = 8; // Try these number of tiles around known ones 
  		public int        grow_sweep         = 8; // Try these number of tiles around known ones 
  		public double     grow_disp_max =   50.0; // Maximal disparity to try
  		public double     grow_disp_max =   100.0; // Maximal disparity to try
  		public double     grow_disp_trust =  4.0; // Trust measured disparity within +/- this value 
  		public double     grow_disp_trust =  4.0; // Trust measured disparity within +/- this value 
  		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  
@@ -2170,6 +2170,8 @@ public class EyesisCorrectionParameters {
  		public double     plMinStrength        =   0.01; // Minimal total strength of a plane 
  		public double     plMinStrength        =   0.01; // Minimal total strength of a plane 
  		public double     plMaxEigen           =   0.06; // Maximal eigenvalue of a plane 
  		public double     plMaxEigen           =   0.06; // Maximal eigenvalue of a plane 
  		public double     plEigenFloor         =   0.005;// Add to eigenvalues of each participating plane and result to validate connections 
  		public double     plEigenFloor         =   0.005;// Add to eigenvalues of each participating plane and result to validate connections 
  		public double     plEigenStick         =   25.0; // Consider plane to be a "stick" if second eigenvalue is below 
  		public double     plBadPlate           =   0.2;  // Not a plate if sin^2 between normals from disparity and world exceeds this 
  		public boolean    plDbgMerge           =   true; // Combine 'other' plane with current
  		public boolean    plDbgMerge           =   true; // Combine 'other' plane with current
  		public double     plWorstWorsening     =   2.0;  // Worst case worsening after merge
  		public double     plWorstWorsening     =   2.0;  // Worst case worsening after merge
  		public double     plWorstWorsening2    =   5.0;  // Worst case worsening for thin planes
  		public double     plWorstWorsening2    =   5.0;  // Worst case worsening for thin planes
@@ -2583,6 +2585,8 @@ public class EyesisCorrectionParameters {
			properties.setProperty(prefix+"plMinStrength",    this.plMinStrength +"");
			properties.setProperty(prefix+"plMinStrength",    this.plMinStrength +"");
			properties.setProperty(prefix+"plMaxEigen",       this.plMaxEigen +"");
			properties.setProperty(prefix+"plMaxEigen",       this.plMaxEigen +"");
			properties.setProperty(prefix+"plEigenFloor",     this.plEigenFloor +"");
			properties.setProperty(prefix+"plEigenFloor",     this.plEigenFloor +"");
			properties.setProperty(prefix+"plEigenStick",     this.plEigenStick +"");
			properties.setProperty(prefix+"plBadPlate",       this.plBadPlate +"");
			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+"plWorstWorsening2",this.plWorstWorsening2 +"");
			properties.setProperty(prefix+"plWorstWorsening2",this.plWorstWorsening2 +"");
@@ -2971,6 +2975,8 @@ public class EyesisCorrectionParameters {
  			if (properties.getProperty(prefix+"plMinStrength")!=null)     this.plMinStrength=Double.parseDouble(properties.getProperty(prefix+"plMinStrength"));
  			if (properties.getProperty(prefix+"plMinStrength")!=null)     this.plMinStrength=Double.parseDouble(properties.getProperty(prefix+"plMinStrength"));
  			if (properties.getProperty(prefix+"plMaxEigen")!=null)        this.plMaxEigen=Double.parseDouble(properties.getProperty(prefix+"plMaxEigen"));
  			if (properties.getProperty(prefix+"plMaxEigen")!=null)        this.plMaxEigen=Double.parseDouble(properties.getProperty(prefix+"plMaxEigen"));
  			if (properties.getProperty(prefix+"plEigenFloor")!=null)      this.plEigenFloor=Double.parseDouble(properties.getProperty(prefix+"plEigenFloor"));
  			if (properties.getProperty(prefix+"plEigenFloor")!=null)      this.plEigenFloor=Double.parseDouble(properties.getProperty(prefix+"plEigenFloor"));
  			if (properties.getProperty(prefix+"plEigenStick")!=null)      this.plEigenStick=Double.parseDouble(properties.getProperty(prefix+"plEigenStick"));
  			if (properties.getProperty(prefix+"plBadPlate")!=null)        this.plBadPlate=Double.parseDouble(properties.getProperty(prefix+"plBadPlate"));
  			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+"plWorstWorsening2")!=null) this.plWorstWorsening2=Double.parseDouble(properties.getProperty(prefix+"plWorstWorsening2"));
  			if (properties.getProperty(prefix+"plWorstWorsening2")!=null) this.plWorstWorsening2=Double.parseDouble(properties.getProperty(prefix+"plWorstWorsening2"));
@@ -3157,7 +3163,7 @@ public class EyesisCorrectionParameters {
  			gd.addNumericField("Do not try to correct vignetting smaller than this fraction of max",      this.vignetting_range,  3);
  			gd.addNumericField("Do not try to correct vignetting smaller than this fraction of max",      this.vignetting_range,  3);
  			gd.addNumericField("Kernel step in pixels (has 1 kernel margin on each side)",                this.kernel_step,            0);
  			gd.addNumericField("Kernel step in pixels (has 1 kernel margin on each side)",                this.kernel_step,            0);
  			gd.addNumericField("Nominal (rectilinear) disparity between side of square cameras (pix)",    this.disparity,  3);
  			gd.addNumericField("Nominal (rectilinear) disparity between side of square cameras (pix)",    this.disparity,  3);
  			gd.addCheckbox    ("Perfcorm coorrelation",                                                   this.correlate);
  			gd.addCheckbox    ("Perform correlation",                                                     this.correlate);
  			gd.addNumericField("itmask of pairs to combine in the composite (top, bottom, left,righth)",  this.corr_mask,            0);
  			gd.addNumericField("itmask of pairs to combine in the composite (top, bottom, left,righth)",  this.corr_mask,            0);
  			gd.addCheckbox    ("Combine correlation with mirrored around disparity direction",            this.corr_sym);
  			gd.addCheckbox    ("Combine correlation with mirrored around disparity direction",            this.corr_sym);
  			gd.addCheckbox    ("Keep all partial correlations (otherwise - only combined one)",           this.corr_keep);
  			gd.addCheckbox    ("Keep all partial correlations (otherwise - only combined one)",           this.corr_keep);
@@ -3387,6 +3393,8 @@ public class EyesisCorrectionParameters {
  			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.addNumericField("Add to eigenvalues of each participating plane and result to validate connections",this.plEigenFloor,  6);
  			gd.addNumericField("Add to eigenvalues of each participating plane and result to validate connections",this.plEigenFloor,  6);
  			gd.addNumericField("Consider plane to be a \"stick\" if second eigenvalue is below",               this.plEigenStick,  6);
  			gd.addNumericField("Not a plate if sin^2 between normals from disparity and world exceeds this",   this.plBadPlate,  6);
  			gd.addCheckbox    ("Combine 'other' plane with the current (unused)",                              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("Worst case worsening for thin planes",                                         this.plWorstWorsening2,  6);
  			gd.addNumericField("Worst case worsening for thin planes",                                         this.plWorstWorsening2,  6);
@@ -3792,6 +3800,8 @@ public class EyesisCorrectionParameters {
  			this.plMinStrength=         gd.getNextNumber();
  			this.plMinStrength=         gd.getNextNumber();
  			this.plMaxEigen=            gd.getNextNumber();
  			this.plMaxEigen=            gd.getNextNumber();
  			this.plEigenFloor=          gd.getNextNumber();
  			this.plEigenFloor=          gd.getNextNumber();
  			this.plEigenStick=          gd.getNextNumber();
  			this.plBadPlate=            gd.getNextNumber();
  			this.plDbgMerge=            gd.getNextBoolean();
  			this.plDbgMerge=            gd.getNextBoolean();
  			this.plWorstWorsening=      gd.getNextNumber();
  			this.plWorstWorsening=      gd.getNextNumber();
  			this.plWorstWorsening2=     gd.getNextNumber();
  			this.plWorstWorsening2=     gd.getNextNumber();
@@ -4484,7 +4494,7 @@ public class EyesisCorrectionParameters {
		public double projectionYaw=           0.0;
		public double projectionYaw=           0.0;
		public double projectionRoll=          0.0;
		public double projectionRoll=          0.0;
		
		
		public boolean matchPixelSize=    true; // disregard next value, calculate projectionPixelSize from teh equirectangular map
		public boolean matchPixelSize=    true; // disregard next value, calculate projectionPixelSize from the equirectangular map
		public double projectionPixelSize=0.00044036902;
		public double projectionPixelSize=0.00044036902;
		public int    projectionWidth=   2920;
		public int    projectionWidth=   2920;
		public int     projectionHeight= 2220;
		public int     projectionHeight= 2220;
+1 −1
Original line number Original line Diff line number Diff line
@@ -499,7 +499,7 @@ private Panel panel1,
			addButton("CLT process files",         panelClt1, color_process);
			addButton("CLT process files",         panelClt1, color_process);
			addButton("CLT process sets",          panelClt1, color_process);
			addButton("CLT process sets",          panelClt1, color_process);
			addButton("CLT process quads",         panelClt1, color_process);
			addButton("CLT process quads",         panelClt1, color_process);
			addButton("CLT process corr",          panelClt1, color_process);
			addButton("CLT process corr",          panelClt1, color_conf_process);
			addButton("CLT disparity scan",        panelClt1, color_conf_process);
			addButton("CLT disparity scan",        panelClt1, color_conf_process);
			addButton("CLT reset fine corr",       panelClt1, color_stop);
			addButton("CLT reset fine corr",       panelClt1, color_stop);
			addButton("CLT show fine corr",        panelClt1, color_configure);
			addButton("CLT show fine corr",        panelClt1, color_configure);
+256 −69

File changed.

Preview size limit exceeded, changes collapsed.

+1 −3
Original line number Original line Diff line number Diff line
@@ -5526,7 +5526,7 @@ public class QuadCLT {
				  clt_parameters.min_clstr_block,// number of tiles in a cluster to block (just non-background?)
				  clt_parameters.min_clstr_block,// number of tiles in a cluster to block (just non-background?)
				  disparity_index, // index of disparity value in disparity_map == 2 (0,2 or 4)
				  disparity_index, // index of disparity value in disparity_map == 2 (0,2 or 4)
				  clt_parameters.show_bgnd_nonbgnd,
				  clt_parameters.show_bgnd_nonbgnd,
				  (clt_parameters.debug_filters ? debugLevel : -1));
				  (clt_parameters.debug_filters ? (debugLevel) : -1));
		  boolean [] bgnd_strict = bgnd_tiles.clone(); // only these have non 0 alpha
		  boolean [] bgnd_strict = bgnd_tiles.clone(); // only these have non 0 alpha
		  tp.growTiles(
		  tp.growTiles(
				  clt_parameters.bgnd_grow,      // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
				  clt_parameters.bgnd_grow,      // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
@@ -5568,8 +5568,6 @@ public class QuadCLT {
						  texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX].clone();
						  texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX].clone();
						  texture_tiles_bgnd[tileY][tileX][alpha_index] = alpha_zero;
						  texture_tiles_bgnd[tileY][tileX][alpha_index] = alpha_zero;
					  }
					  }
					  
					  
				  }
				  }
			  }
			  }
		  }
		  }
+216 −18
Original line number Original line Diff line number Diff line
@@ -1122,7 +1122,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; 
		String [] titles = new String [num_pm + 3 * num_ml + 4 * num_pd];
		String [] titles = new String [num_pm + 3 * num_ml + 8 * num_pd];
		for (int np = 0; np < num_p; np++){
		for (int np = 0; np < num_p; np++){
			for (int ml = 0; ml < num_ml; ml++){
			for (int ml = 0; ml < num_ml; ml++){
				titles [np * num_ml + ml] = "p"+np+"_l"+ml;
				titles [np * num_ml + ml] = "p"+np+"_l"+ml;
@@ -1137,7 +1137,11 @@ public class SuperTiles{
			titles [num_pm + 3 * num_ml + 0 * num_pd + npd] = "pd_"+npd;
			titles [num_pm + 3 * num_ml + 0 * num_pd + npd] = "pd_"+npd;
			titles [num_pm + 3 * num_ml + 1 * num_pd + npd] = "pdm_"+npd;
			titles [num_pm + 3 * num_ml + 1 * num_pd + npd] = "pdm_"+npd;
			titles [num_pm + 3 * num_ml + 2 * num_pd + npd] = "pdd_"+npd;
			titles [num_pm + 3 * num_ml + 2 * num_pd + npd] = "pdd_"+npd;
			titles [num_pm + 3 * num_ml + 3 * num_pd + npd] = "pds_"+npd;
			titles [num_pm + 3 * num_ml + 3 * num_pd + npd] = "pwd_"+npd;
			titles [num_pm + 3 * num_ml + 4 * num_pd + npd] = "pds_"+npd;
			titles [num_pm + 3 * num_ml + 5 * num_pd + npd] = "pws_"+npd;
			titles [num_pm + 3 * num_ml + 6 * num_pd + npd] = "-pdd_"+npd;
			titles [num_pm + 3 * num_ml + 7 * num_pd + npd] = "-pwd_"+npd;
		}
		}


	// TilePlanes.PlaneData	
	// TilePlanes.PlaneData	
@@ -1157,7 +1161,7 @@ public class SuperTiles{
		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();
		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 + 8 * 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)){
				int nd = np * num_ml + ml; 
				int nd = np * num_ml + ml; 
@@ -1196,14 +1200,30 @@ public class SuperTiles{
			
			
		}
		}
		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(
					useWorld,
					null, // double [] window,
					true, // boolean   use_sel,
					true, // boolean   divide_by_area,
					1.5, // double   scale_projection,
					1); // int       debugLevel) */
			double [][] ellipsoids = planes[npd +LOWEST_PLANE(planes.length)].getDoublePlaneDisparityStrength(
			double [][] ellipsoids = planes[npd +LOWEST_PLANE(planes.length)].getDoublePlaneDisparityStrength(
					useWorld,
					useWorld,
					null, // double [] window,
					null, // double [] window,
					-1, // 
					true, // boolean   use_sel,
					true, // boolean   use_sel,
					true, // boolean   divide_by_area,
					true, // boolean   divide_by_area,
					1.5, // double   scale_projection,
					1.5, // double   scale_projection,
					0.0, // double    fraction_uni,
					1); // int       debugLevel)
			double [][] ellipsoidsW = planes[npd +LOWEST_PLANE(planes.length)].getDoublePlaneWorldDisparityStrength(
					null, // double [] window,
					-1, // 
					true, // boolean   use_sel,
					true, // boolean   divide_by_area,
					1.5, // double   scale_projection,
					0.0, // double    fraction_uni,
					1); // int       debugLevel)
					1); // int       debugLevel)
			
			data [num_pm + 3 * num_ml + 0 * num_pd + npd] = planes[npd +LOWEST_PLANE(planes.length)].getDoublePlaneDisparity(
			data [num_pm + 3 * num_ml + 0 * num_pd + npd] = planes[npd +LOWEST_PLANE(planes.length)].getDoublePlaneDisparity(
					useWorld,
					useWorld,
					false);
					false);
@@ -1219,13 +1239,151 @@ public class SuperTiles{
					}					
					}					
				}				
				}				
			}	
			}	
			if (ellipsoids != null) {
				data [num_pm + 3 * num_ml + 2 * num_pd + npd] = ellipsoids[0];
				data [num_pm + 3 * num_ml + 2 * num_pd + npd] = ellipsoids[0];
			data [num_pm + 3 * num_ml + 3 * num_pd + npd] = ellipsoids[1];
				data [num_pm + 3 * num_ml + 4 * num_pd + npd] = ellipsoids[1];
				data [num_pm + 3 * num_ml + 6 * num_pd + npd] = new double[ntiles];
				for (int i = 0; i < ntiles; i++) {
					for (int ml = 0; ml < num_ml; ml++) if ((disp_strength[ml]!=null) && (msel[ml] != null)){
						if (msel[ml][i] && (disp_strength[ml][1][i] > 0.0)){
							data [num_pm + 3 * num_ml + 6 * num_pd + npd][i] = disp_strength[ml][0][i] - ellipsoids[0][i]; 
						} else {
							data [num_pm + 3 * num_ml + 6 * num_pd + npd][i] = Double.NaN;
						}
						break;
					}
				}
			}
			if (ellipsoidsW != null) {
				data [num_pm + 3 * num_ml + 3 * num_pd + npd] = ellipsoidsW[0];
				data [num_pm + 3 * num_ml + 5 * num_pd + npd] = ellipsoidsW[1];
				data [num_pm + 3 * num_ml + 7 * num_pd + npd] = new double[ntiles];
				for (int i = 0; i < ntiles; i++) {
					for (int ml = 0; ml < num_ml; ml++) if ((disp_strength[ml]!=null) && (msel[ml] != null)){
						if (msel[ml][i] && (disp_strength[ml][1][i] > 0.0)){
							data [num_pm + 3 * num_ml + 7 * num_pd + npd][i] = disp_strength[ml][0][i] - ellipsoidsW[0][i]; 
						} else {
							data [num_pm + 3 * num_ml + 7 * num_pd + npd][i] = Double.NaN;
						}
						break;
					}
				}
			}
		}
		return data;
	}
	}
//		public boolean [] getMeasSelection(int nl){
	
	
	public String [] showSupertileWorldTitles(
			double [][][]  disp_strength,
			boolean [][][] selections,
			TilePlanes.PlaneData [] planes)
	{
		int num_p  = selections.length;
		int num_pd = (planes != null) ? (planes.length - LOWEST_PLANE(planes.length)) : 0; 
		String [] titles = new String [9 * num_pd];
		for (int npd = 0; npd < num_pd; npd++){
			titles [0 * num_pd + npd] = "tile_x_"+npd;
			titles [1 * num_pd + npd] = "tile_y_"+npd;
			titles [2 * num_pd + npd] = "tile_z_"+npd;
			titles [3 * num_pd + npd] = "plane_x_"+npd;
			titles [4 * num_pd + npd] = "plane_y_"+npd;
			titles [5 * num_pd + npd] = "plane_z_"+npd;
			titles [6 * num_pd + npd] = "diff_x_"+npd;
			titles [7 * num_pd + npd] = "diff_y_"+npd;
			titles [8 * num_pd + npd] = "diff_z_"+npd;
		}

	// TilePlanes.PlaneData	
		return titles;
	}
/*	
	public double [][] showSupertileWorld(
			double [][][]  disp_strength,
			boolean [][][] selections,
			TilePlanes.PlaneData [] planes
			)
	{
		int superTileSize = tileProcessor.getSuperTileSize();
		int num_ml = disp_strength.length;
		int num_p  = (selections == null) ? 0: selections.length;
		int num_pm = num_ml * num_p;
		int num_pd = (planes != null) ? (planes.length - LOWEST_PLANE(planes.length)) : 0;
		int ml = 0;
		for (ml = 0; ml < num_ml; ml++) if (disp_strength[ml]!=null){
			break;
		}
		double [][] data = new double [num_pd][];
		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(
					useWorld,
					null, // double [] window,
					-1, // 
					true, // boolean   use_sel,
					true, // boolean   divide_by_area,
					1.5, // double   scale_projection,
					0.0, // double    fraction_uni,
					1); // int       debugLevel)
			double [][] ellipsoidsW = planes[npd +LOWEST_PLANE(planes.length)].getDoublePlaneWorldDisparityStrength(
					null, // double [] window,
					-1, // 
					true, // boolean   use_sel,
					true, // boolean   divide_by_area,
					1.5, // double   scale_projection,
					0.0, // double    fraction_uni,
					1); // int       debugLevel)
			data [num_pm + 3 * num_ml + 0 * num_pd + npd] = planes[npd +LOWEST_PLANE(planes.length)].getDoublePlaneDisparity(
					useWorld,
					false);
			
			boolean [][] msel = planes[npd +LOWEST_PLANE(planes.length)].getMeasSelection();
			int ntiles = data [num_pm + 3 * num_ml + 0 * num_pd + npd].length; 
			data [num_pm + 3 * num_ml + 1 * num_pd + npd] = new double [ntiles];
			for (int i = 0; i < ntiles; i++) {
				data [num_pm + 3 * num_ml + 1 * num_pd + npd][i] = Double.NaN;
				for (int ml = 0; ml < num_ml; ml++) if ((disp_strength[ml]!=null) && (msel[ml] != null)){
					if (msel[ml][i] && (disp_strength[ml][1][i] > 0.0)){
						data [num_pm + 3 * num_ml + 1 * num_pd + npd][i] = data [num_pm + 3 * num_ml + 0 * num_pd + npd][i];
					}					
				}				
			}	
			if (ellipsoids != null) {
				data [num_pm + 3 * num_ml + 2 * num_pd + npd] = ellipsoids[0];
				data [num_pm + 3 * num_ml + 4 * num_pd + npd] = ellipsoids[1];
				data [num_pm + 3 * num_ml + 6 * num_pd + npd] = new double[ntiles];
				for (int i = 0; i < ntiles; i++) {
					for (int ml = 0; ml < num_ml; ml++) if ((disp_strength[ml]!=null) && (msel[ml] != null)){
						if (msel[ml][i] && (disp_strength[ml][1][i] > 0.0)){
							data [num_pm + 3 * num_ml + 6 * num_pd + npd][i] = disp_strength[ml][0][i] - ellipsoids[0][i]; 
						} else {
							data [num_pm + 3 * num_ml + 6 * num_pd + npd][i] = Double.NaN;
						}
						break;
					}
				}
			}
			if (ellipsoidsW != null) {
				data [num_pm + 3 * num_ml + 3 * num_pd + npd] = ellipsoidsW[0];
				data [num_pm + 3 * num_ml + 5 * num_pd + npd] = ellipsoidsW[1];
				data [num_pm + 3 * num_ml + 7 * num_pd + npd] = new double[ntiles];
				for (int i = 0; i < ntiles; i++) {
					for (int ml = 0; ml < num_ml; ml++) if ((disp_strength[ml]!=null) && (msel[ml] != null)){
						if (msel[ml][i] && (disp_strength[ml][1][i] > 0.0)){
							data [num_pm + 3 * num_ml + 7 * num_pd + npd][i] = disp_strength[ml][0][i] - ellipsoidsW[0][i]; 
						} else {
							data [num_pm + 3 * num_ml + 7 * num_pd + npd][i] = Double.NaN;
						}
						break;
					}
				}
			}
		}
		return data;
		return data;
	}
	}
*/	
	
	
	
	
	
	
	// calculate "tilted" disparity, so planes parallel to the same world plane would have the same disparity
	// calculate "tilted" disparity, so planes parallel to the same world plane would have the same disparity
	// also produces non-tilted, if world_plane_norm == null
	// also produces non-tilted, if world_plane_norm == null
@@ -2279,6 +2437,14 @@ public class SuperTiles{
							}
							}
							
							
							if ((st_planes != null) && (!st_planes.isEmpty())){
							if ((st_planes != null) && (!st_planes.isEmpty())){
								if (dl > 2) {
									for (TilePlanes.PlaneData plane:st_planes){
										plane.getWorldXYZ(0);
										System.out.println(plane.toString());
									}
									// Calculate planes and print results
								}
//						this_new_plane.getWorldXYZ(0);
								
								
								if (LOWEST_PLANE(2) > 0) st_planes.add(0, st_planes.get(0)); // insert dummy at pos 0;
								if (LOWEST_PLANE(2) > 0) st_planes.add(0, st_planes.get(0)); // insert dummy at pos 0;
								result_planes[nsTile] = st_planes.toArray(new TilePlanes.PlaneData[0] );
								result_planes[nsTile] = st_planes.toArray(new TilePlanes.PlaneData[0] );
@@ -5831,6 +5997,8 @@ public class SuperTiles{
											mod_planes[nsTile][neibs[dir]], // neighbor, previous value
											mod_planes[nsTile][neibs[dir]], // neighbor, previous value
											dl - 1); // debugLevel);
											dl - 1); // debugLevel);
									costs[dir] = lp.getFitQualities(
									costs[dir] = lp.getFitQualities(
											// there probably be no sticks here after merging
											false, // final boolean                   en_sticks, // treat planes with second eigenvalue below plEigenStick as "sticks"
											this_new_plane, // TilePlanes.PlaneData plane1, // should belong to the same supertile (or be converted for one)
											this_new_plane, // TilePlanes.PlaneData plane1, // should belong to the same supertile (or be converted for one)
											other_plane,   // TilePlanes.PlaneData plane2,
											other_plane,   // TilePlanes.PlaneData plane2,
											Double.NaN, // double               merged_ev,    // if NaN will calculate assuming the same supertile
											Double.NaN, // double               merged_ev,    // if NaN will calculate assuming the same supertile
@@ -5863,6 +6031,7 @@ public class SuperTiles{
								this_new_plane =this_new_plane.clone(); // not to change weight!
								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
								double true_num_merged = 0.0;
								for (int dir = 0; dir < neibs.length; dir++){
								for (int dir = 0; dir < neibs.length; dir++){
									if (neibs[dir] >= 0) {
									if (neibs[dir] >= 0) {
										int stx = stx0 + dirsYX[dir][1];
										int stx = stx0 + dirsYX[dir][1];
@@ -5885,11 +6054,16 @@ public class SuperTiles{
														dl - 1); // int       debugLevel)
														dl - 1); // int       debugLevel)
												
												
											} else {
											} else {
												this_new_plane.copyNeib(this_new_plane, other_plane); // keep neighbors of the original center plane
												this_new_plane.copyStar(this_new_plane, other_plane);
												this_new_plane = other_plane; // should increment num_merged
												this_new_plane = other_plane; // should increment num_merged
												this_new_plane.scaleWeight(weights[dir]);
												this_new_plane.scaleWeight(weights[dir]);
												this_new_plane.invalidateCalculated();
											}
											}
											if (this_new_plane != null){
											if (this_new_plane != null){
												num_merged += 1.0;
												num_merged += 1.0;
												true_num_merged += 1.0;

												// just for debug / calculate
												// just for debug / calculate
												this_new_plane.getWorldXYZ(0);
												this_new_plane.getWorldXYZ(0);
											}
											}
@@ -5908,6 +6082,8 @@ public class SuperTiles{
										double scale = Math.pow(num_merged, normPow);
										double scale = Math.pow(num_merged, normPow);
										this_new_plane.scaleWeight(1.0/scale);
										this_new_plane.scaleWeight(1.0/scale);
										num_merged /=scale;
										num_merged /=scale;
										true_num_merged /= scale;

									}
									}
									
									
									if (    (meas_pull > 0.0) &&
									if (    (meas_pull > 0.0) &&
@@ -5930,24 +6106,33 @@ public class SuperTiles{
													dl - 1);                           // int       debugLevel)
													dl - 1);                           // int       debugLevel)
											if (this_new_plane != null){
											if (this_new_plane != null){
												num_merged += meas_pull;	// num_merged was 1.0 and weight is averaged over all neighbors
												num_merged += meas_pull;	// num_merged was 1.0 and weight is averaged over all neighbors
												true_num_merged += 1.0;
											}
											}
										} else {
										} else {
											this_new_plane = measured_planes[nsTile0][np0].clone();
											this_new_plane = measured_planes[nsTile0][np0].clone();
											num_merged = 1.0;
											num_merged = 1.0;
											true_num_merged = 1.0;
										}
										}
										new_planes[nsTile0][np0] = this_new_plane;
										new_planes[nsTile0][np0] = this_new_plane;
										if (dl > 0) dbg_img[18] =  this_new_plane.getSinglePlaneDisparity(false);
										if (dl > 0) dbg_img[18] =  this_new_plane.getSinglePlaneDisparity(false);
									}
									}
									if ((num_merged > 0.0) && (this_new_plane != null)){
									if ((num_merged > 0.0) && (this_new_plane != null)){
										this_new_plane.scaleWeight(1.0/num_merged);
										this_new_plane.scaleWeight(1.0/num_merged);
										double true_num_merged = num_merged - meas_pull + 1;
//										double true_num_merged = num_merged - meas_pull + 1;
										this_new_plane.setNumPoints((int) (this_new_plane.getNumPoints()/true_num_merged));
										this_new_plane.setNumPoints((int) (this_new_plane.getNumPoints()/true_num_merged));
									}
									}
									// Revert if the result value is higher than imposed maximum
									// Revert if the result value is higher than imposed maximum
									if ((this_new_plane.getValue() > maxValue)  && (maxValue != 0)){ // TODO: Set more relaxed here?
									if ((this_new_plane.getValue() > maxValue)  && (maxValue != 0)){ // TODO: Set more relaxed here?
										if (dl > -1){
											System.out.println("planesSmoothStep nsTile0="+nsTile0+" smoothed plane is too thick, using previous one");
											dbg_img = new double [titles.length][];
										}
										this_new_plane = mod_planes[nsTile0][np0].clone();
										this_new_plane = mod_planes[nsTile0][np0].clone();
										new_planes[nsTile0][np0] = this_new_plane;
										new_planes[nsTile0][np0] = this_new_plane;
									}
									}
//									Use non-exclusive
									
									
									// just for debug / calculate 
									// just for debug / calculate 
									this_new_plane.getWorldXYZ(0);
									this_new_plane.getWorldXYZ(0);
									// calculate largest disparity difference between old and new plane
									// calculate largest disparity difference between old and new plane
@@ -6908,6 +7093,7 @@ public class SuperTiles{
			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
			final boolean weak_connected, // select connected planes even if they are weak/thick
			TilePlanes.PlaneData [][] planes)
			TilePlanes.PlaneData [][] planes)
	{
	{
		final int tilesX =        tileProcessor.getTilesX();
		final int tilesX =        tileProcessor.getTilesX();
@@ -6923,7 +7109,18 @@ public class SuperTiles{
				if (planes[nsTile] != null) {
				if (planes[nsTile] != null) {
					selection[nsTile] = new boolean [planes[nsTile].length];
					selection[nsTile] = new boolean [planes[nsTile].length];
					for (int np = 0; np < planes[nsTile].length; np++){
					for (int np = 0; np < planes[nsTile].length; np++){
						if ((planes[nsTile][np] != null) && (planes[nsTile][np].getWeight() >= minWeight)){
//						if ((planes[nsTile][np] != null) && (planes[nsTile][np].getWeight() >= minWeight)){
						if (planes[nsTile][np] != null){
							boolean has_conn = false;
							for (int dir = 0; dir < 8; dir++){
								if (planes[nsTile][np].getNeibBest(dir) >= 0){
									has_conn = true;
									break;
								}
							}
							if (weak_connected && has_conn) {
								selection[nsTile][np] = true;
							} else if  (planes[nsTile][np].getWeight() >= minWeight) {
								//&& (planes[nsTile][np].getValue() < maxEigen)){
								//&& (planes[nsTile][np].getValue() < maxEigen)){
								double eigVal = planes[nsTile][np].getValue();
								double eigVal = planes[nsTile][np].getValue();
								double disp = planes[nsTile][np].getZxy()[0];
								double disp = planes[nsTile][np].getZxy()[0];
@@ -6936,6 +7133,7 @@ public class SuperTiles{
					}
					}
				}
				}
			}
			}
		}
		return selection;
		return selection;
	}
	}


Loading