Commit 9cfff83b authored by Andrey Filippov's avatar Andrey Filippov
Browse files

added/tested adding final links after planes smooth

parent 9b725244
Loading
Loading
Loading
Loading
+32 −5
Original line number Original line Diff line number Diff line
@@ -2202,6 +2202,12 @@ public class EyesisCorrectionParameters {
  	    public boolean    plConflSngl          =  true;  // Only merge conflicting planes if this is the only conflicting pair in the supertile
  	    public boolean    plConflSngl          =  true;  // Only merge conflicting planes if this is the only conflicting pair in the supertile
  	    public boolean    plConflSnglPair      =  true;  // Only merge conflicting planes only if there are just two planes in the supertile
  	    public boolean    plConflSnglPair      =  true;  // Only merge conflicting planes only if there are just two planes in the supertile
  	    
  	    
  	    public double     plThickWorld         =   0.2;  // Maximal real-world thickness of merged overlapping planes (meters) 
  	    public double     plThickWorldConfl    =   0.4;  // Maximal real-world merged thickness for conflicting planes 
  	    public double     plRelaxComplete      =   1.5;  // Relax cost requirements when adding exclusive links to complete squares and triangles 
  	    public double     plRelaxComplete2     =   2.0;  // Relax cost requirements during the second pass 
  	    
  	    
  		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
@@ -2256,6 +2262,7 @@ public class EyesisCorrectionParameters {
  		public boolean    plMutualOnly         =   true; // keep only mutual links, remove weakest if conflict
  		public boolean    plMutualOnly         =   true; // keep only mutual links, remove weakest if conflict
  		public boolean    plFillSquares        =   true; // Add diagonals to full squares
  		public boolean    plFillSquares        =   true; // Add diagonals to full squares
  		public boolean    plCutCorners         =   true; // Add ortho to 45-degree corners
  		public boolean    plCutCorners         =   true; // Add ortho to 45-degree corners
  		public boolean    plHypotenuse         =   true; // Add hypotenuse connection if both legs exist


  		public double     plPull               =  5.0; // .3;   // Relative weight of original (measured) plane compared to average neighbor pull
  		public double     plPull               =  5.0; // .3;   // Relative weight of original (measured) plane compared to average neighbor pull
  		                                                // when combing with neighbors
  		                                                // when combing with neighbors
@@ -2626,6 +2633,10 @@ public class EyesisCorrectionParameters {
			properties.setProperty(prefix+"plConflRelax",     this.plConflRelax +"");
			properties.setProperty(prefix+"plConflRelax",     this.plConflRelax +"");
			properties.setProperty(prefix+"plConflSngl",      this.plConflSngl+"");
			properties.setProperty(prefix+"plConflSngl",      this.plConflSngl+"");
			properties.setProperty(prefix+"plConflSnglPair",  this.plConflSnglPair+"");
			properties.setProperty(prefix+"plConflSnglPair",  this.plConflSnglPair+"");
			properties.setProperty(prefix+"plThickWorld",     this.plThickWorld +"");
			properties.setProperty(prefix+"plThickWorldConfl",this.plThickWorldConfl +"");
			properties.setProperty(prefix+"plRelaxComplete",  this.plRelaxComplete +"");
			properties.setProperty(prefix+"plRelaxComplete2", this.plRelaxComplete2 +"");


			properties.setProperty(prefix+"plMaxZRatio",      this.plMaxZRatio +"");
			properties.setProperty(prefix+"plMaxZRatio",      this.plMaxZRatio +"");
			properties.setProperty(prefix+"plMaxDisp",        this.plMaxDisp +"");
			properties.setProperty(prefix+"plMaxDisp",        this.plMaxDisp +"");
@@ -2676,6 +2687,7 @@ public class EyesisCorrectionParameters {
			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+"plHypotenuse",     this.plHypotenuse+"");
			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+"");
@@ -3026,6 +3038,10 @@ public class EyesisCorrectionParameters {
  			if (properties.getProperty(prefix+"plConflRelax")!=null)      this.plConflRelax=Double.parseDouble(properties.getProperty(prefix+"plConflRelax"));
  			if (properties.getProperty(prefix+"plConflRelax")!=null)      this.plConflRelax=Double.parseDouble(properties.getProperty(prefix+"plConflRelax"));
  			if (properties.getProperty(prefix+"plConflSngl")!=null)       this.plConflSngl=Boolean.parseBoolean(properties.getProperty(prefix+"plConflSngl"));
  			if (properties.getProperty(prefix+"plConflSngl")!=null)       this.plConflSngl=Boolean.parseBoolean(properties.getProperty(prefix+"plConflSngl"));
  			if (properties.getProperty(prefix+"plConflSnglPair")!=null)   this.plConflSnglPair=Boolean.parseBoolean(properties.getProperty(prefix+"plConflSnglPair"));
  			if (properties.getProperty(prefix+"plConflSnglPair")!=null)   this.plConflSnglPair=Boolean.parseBoolean(properties.getProperty(prefix+"plConflSnglPair"));
  			if (properties.getProperty(prefix+"plThickWorld")!=null)      this.plThickWorld=Double.parseDouble(properties.getProperty(prefix+"plThickWorld"));
  			if (properties.getProperty(prefix+"plThickWorldConfl")!=null) this.plThickWorldConfl=Double.parseDouble(properties.getProperty(prefix+"plThickWorldConfl"));
  			if (properties.getProperty(prefix+"plRelaxComplete")!=null)   this.plRelaxComplete=Double.parseDouble(properties.getProperty(prefix+"plRelaxComplete"));
  			if (properties.getProperty(prefix+"plRelaxComplete2")!=null)  this.plRelaxComplete2=Double.parseDouble(properties.getProperty(prefix+"plRelaxComplete2"));
  			
  			
  			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"));
@@ -3076,6 +3092,7 @@ public class EyesisCorrectionParameters {
  			if (properties.getProperty(prefix+"plMutualOnly")!=null)      this.plMutualOnly=Boolean.parseBoolean(properties.getProperty(prefix+"plMutualOnly"));
  			if (properties.getProperty(prefix+"plMutualOnly")!=null)      this.plMutualOnly=Boolean.parseBoolean(properties.getProperty(prefix+"plMutualOnly"));
  			if (properties.getProperty(prefix+"plFillSquares")!=null)     this.plFillSquares=Boolean.parseBoolean(properties.getProperty(prefix+"plFillSquares"));
  			if (properties.getProperty(prefix+"plFillSquares")!=null)     this.plFillSquares=Boolean.parseBoolean(properties.getProperty(prefix+"plFillSquares"));
  			if (properties.getProperty(prefix+"plCutCorners")!=null)      this.plCutCorners=Boolean.parseBoolean(properties.getProperty(prefix+"plCutCorners"));
  			if (properties.getProperty(prefix+"plCutCorners")!=null)      this.plCutCorners=Boolean.parseBoolean(properties.getProperty(prefix+"plCutCorners"));
  			if (properties.getProperty(prefix+"plHypotenuse")!=null)      this.plHypotenuse=Boolean.parseBoolean(properties.getProperty(prefix+"plHypotenuse"));


  			if (properties.getProperty(prefix+"plPull")!=null)            this.plPull=Double.parseDouble(properties.getProperty(prefix+"plPull"));
  			if (properties.getProperty(prefix+"plPull")!=null)            this.plPull=Double.parseDouble(properties.getProperty(prefix+"plPull"));
  			if (properties.getProperty(prefix+"plNormPow")!=null)         this.plNormPow=Double.parseDouble(properties.getProperty(prefix+"plNormPow"));
  			if (properties.getProperty(prefix+"plNormPow")!=null)         this.plNormPow=Double.parseDouble(properties.getProperty(prefix+"plNormPow"));
@@ -3455,6 +3472,10 @@ public class EyesisCorrectionParameters {
  			gd.addNumericField("Scale parameters to relax planes fit for merging conflicting planes",                 this.plConflRelax,  6);
  			gd.addNumericField("Scale parameters to relax planes fit for merging conflicting planes",                 this.plConflRelax,  6);
  			gd.addCheckbox    ("Only merge conflicting planes if this is the only conflicting pair in the supertile", this.plConflSngl);
  			gd.addCheckbox    ("Only merge conflicting planes if this is the only conflicting pair in the supertile", this.plConflSngl);
  			gd.addCheckbox    ("Only merge conflicting planes only if there are just two planes in the supertile",    this.plConflSnglPair);
  			gd.addCheckbox    ("Only merge conflicting planes only if there are just two planes in the supertile",    this.plConflSnglPair);
  			gd.addNumericField("Maximal real-world thickness of merged overlapping planes (meters)",                  this.plThickWorld,  6);
  			gd.addNumericField("Maximal real-world merged thickness for conflicting planes",                          this.plThickWorldConfl,  6);
  			gd.addNumericField("Relax cost requirements when adding exclusive links to complete squares and triangles",this.plRelaxComplete,  6);
  			gd.addNumericField("Relax cost requirements more during the second pass",                                 this.plRelaxComplete2,  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);
@@ -3509,6 +3530,7 @@ public class EyesisCorrectionParameters {


  			gd.addCheckbox    ("Add diagonals to full squares",                                                this.plFillSquares);
  			gd.addCheckbox    ("Add diagonals to full squares",                                                this.plFillSquares);
  			gd.addCheckbox    ("Add ortho to 45-degree corners",                                               this.plCutCorners);
  			gd.addCheckbox    ("Add ortho to 45-degree corners",                                               this.plCutCorners);
  			gd.addCheckbox    ("Add hypotenuse connection if both legs exist",                                 this.plHypotenuse);


  			gd.addNumericField("Relative (to average neighbor) weight of the measured plane when combing with neighbors",     this.plPull,  6);
  			gd.addNumericField("Relative (to average neighbor) weight of the measured plane when combing with neighbors",     this.plPull,  6);
  			gd.addNumericField("0.0: 8 neighbors pull 8 times as 1, 1.0 - same as 1",                          this.plNormPow,  6);
  			gd.addNumericField("0.0: 8 neighbors pull 8 times as 1, 1.0 - same as 1",                          this.plNormPow,  6);
@@ -3871,6 +3893,10 @@ public class EyesisCorrectionParameters {
  			this.plConflRelax=          gd.getNextNumber();
  			this.plConflRelax=          gd.getNextNumber();
  			this.plConflSngl=           gd.getNextBoolean();
  			this.plConflSngl=           gd.getNextBoolean();
  			this.plConflSnglPair=       gd.getNextBoolean();
  			this.plConflSnglPair=       gd.getNextBoolean();
  			this.plThickWorld=          gd.getNextNumber();
  			this.plThickWorldConfl=     gd.getNextNumber();
  			this.plRelaxComplete=       gd.getNextNumber();
  			this.plRelaxComplete2=      gd.getNextNumber();


  			this.plMaxZRatio=           gd.getNextNumber();
  			this.plMaxZRatio=           gd.getNextNumber();
  			this.plMaxDisp=             gd.getNextNumber();
  			this.plMaxDisp=             gd.getNextNumber();
@@ -3922,6 +3948,7 @@ public class EyesisCorrectionParameters {


  			this.plFillSquares=         gd.getNextBoolean();
  			this.plFillSquares=         gd.getNextBoolean();
  			this.plCutCorners=          gd.getNextBoolean();
  			this.plCutCorners=          gd.getNextBoolean();
  			this.plHypotenuse=          gd.getNextBoolean();


  			this.plPull=                gd.getNextNumber();
  			this.plPull=                gd.getNextNumber();
  			this.plNormPow=             gd.getNextNumber();
  			this.plNormPow=             gd.getNextNumber();
+589 −12

File changed.

Preview size limit exceeded, changes collapsed.

+70 −19
Original line number Original line Diff line number Diff line
@@ -5508,11 +5508,16 @@ public class QuadCLT {
			  int        debugLevel
			  int        debugLevel
			  )
			  )
	  {
	  {
		  final boolean new_mode = false;
		  
		  
		  
		  final int tilesX = tp.getTilesX();
		  final int tilesX = tp.getTilesX();
		  final int tilesY = tp.getTilesY();
		  final int tilesY = tp.getTilesY();
		  showDoubleFloatArrays sdfa_instance = null;
		  showDoubleFloatArrays sdfa_instance = null;
		  
		  
		  if (clt_parameters.debug_filters && (debugLevel > -1)) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
		  if (clt_parameters.debug_filters && (debugLevel > -1))
			  sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
		  
		  
		  CLTPass3d bgnd_data = tp.clt_3d_passes.get(0); 
		  CLTPass3d bgnd_data = tp.clt_3d_passes.get(0); 
		  double [][][][] texture_tiles = bgnd_data.texture_tiles;
		  double [][][][] texture_tiles = bgnd_data.texture_tiles;
@@ -5527,6 +5532,26 @@ public class QuadCLT {
				  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_tiles_new =   tp.getBackgroundMask_new( // which tiles do belong to the background
				  clt_parameters.bgnd_range,     // disparity range to be considered background
				  clt_parameters.bgnd_sure,      // minimal strength to be considered definitely background
				  clt_parameters.bgnd_maybe,     // maximal strength to ignore as non-background
				  clt_parameters.sure_smth,      // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
				  clt_parameters.min_clstr_seed, // number of tiles in a cluster to seed (just 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)
				  clt_parameters.show_bgnd_nonbgnd,
				  (clt_parameters.debug_filters ? (debugLevel) : -1));
		  boolean [] bgnd_dbg =    bgnd_tiles.clone(); // only these have non 0 alpha
// TODO: fix mess - after modifying getBackgroundMask() to getBackgroundMask_new (before road with tractor was identified as a background because of a double
// tile glitch, the background was wrong. So temporarily both old/new are used and combined (new is grown twice)
// still does not work - using old variant for now
		  
// background selections (slightly) influences the plane mertging / connections		  
		  
		  for (int i = 0; i < bgnd_tiles.length; i++){
//			  bgnd_tiles[i] &= bgnd_tiles_new[i];
		  }
		  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
@@ -5538,25 +5563,50 @@ public class QuadCLT {
				  bgnd_tiles,
				  bgnd_tiles,
				  null); // prohibit
				  null); // prohibit
		  
		  
		  bgnd_data.selected = bgnd_tiles_grown; // selected for background w/o extra transparent layer
// hacking - grow bgnd texture even more, without changing selection		  
		  boolean [] bgnd_tiles_grown2 = bgnd_tiles_grown.clone(); // only these have non 0 alpha


		  bgnd_data.selected = bgnd_tiles_grown; // selected for background w/o extra transparent layer
		  tp.growTiles(
				  2,      // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
				  bgnd_tiles_grown2,
				  null); // prohibit
		  if (sdfa_instance!=null){
		  if (sdfa_instance!=null){
			  double [][] dbg_img = new double[3][tilesY * tilesX];
			  double [][] dbg_img = new double[5][tilesY * tilesX];
			  String [] titles = {"strict","grown","more_grown"};
			  String [] titles = {"old","new","strict","grown","more_grown"};
			  for (int i = 0; i<dbg_img[0].length;i++){
			  for (int i = 0; i<dbg_img[0].length;i++){
				  dbg_img[0][i] = bgnd_strict[i]?1:0;
				  //
				  dbg_img[1][i] =  bgnd_tiles_grown[i]?1:0;
				  dbg_img[0][i] =  bgnd_dbg[i]?1:0;
				  dbg_img[2][i] =  bgnd_tiles[i]?1:0;
				  dbg_img[1][i] =  bgnd_tiles_new[i]?1:0;
				  dbg_img[2][i] =  bgnd_strict[i]?1:0;
				  dbg_img[3][i] =  bgnd_tiles_grown[i]?1:0;
				  dbg_img[4][i] =  bgnd_tiles[i]?1:0;
			  }
			  }
			sdfa_instance.showArrays(dbg_img,  tilesX, tilesY, true, "strict_grown",titles);
			sdfa_instance.showArrays(dbg_img,  tilesX, tilesY, true, "strict_grown",titles);
		  }
		  }
		  
		  
		  
		  
		  double [][][][] texture_tiles_bgnd = new double[tilesY][tilesX][][];
		  double [][][][] texture_tiles_bgnd = new double[tilesY][tilesX][][];
		  double [] alpha_zero = new double [4*clt_parameters.transform_size*clt_parameters.transform_size];
		  double [] alpha_zero = new double [4*clt_parameters.transform_size*clt_parameters.transform_size];
		  int alpha_index = 3;
		  int alpha_index = 3;
		  for (int i = 0; i < alpha_zero.length; i++) alpha_zero[i]=0.0;
		  for (int i = 0; i < alpha_zero.length; i++) alpha_zero[i]=0.0;
		  if (new_mode) {
			  for (int tileY = 0; tileY < tilesY; tileY++){
				  for (int tileX = 0; tileX < tilesX; tileX++){
					  texture_tiles_bgnd[tileY][tileX]= null;
					  if ((texture_tiles[tileY][tileX] != null) &&
							  //						  bgnd_tiles[tileY * tilesX + tileX]) {
							  bgnd_tiles_grown2[tileY * tilesX + tileX]) {
						  //					  if (bgnd_tiles_grown[tileY * tilesX + tileX]) {
						  if (bgnd_tiles[tileY * tilesX + tileX]) {
							  texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX];
						  }else{
							  texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX].clone();
							  texture_tiles_bgnd[tileY][tileX][alpha_index] = alpha_zero;
						  }
					  }
				  }
			  }
		  } else {
			  for (int tileY = 0; tileY < tilesY; tileY++){
			  for (int tileY = 0; tileY < tilesY; tileY++){
				  for (int tileX = 0; tileX < tilesX; tileX++){
				  for (int tileX = 0; tileX < tilesX; tileX++){
					  texture_tiles_bgnd[tileY][tileX]= null;
					  texture_tiles_bgnd[tileY][tileX]= null;
@@ -5571,6 +5621,7 @@ public class QuadCLT {
					  }
					  }
				  }
				  }
			  }
			  }
		  }
		  
		  
		  ImageDtt image_dtt = new ImageDtt();
		  ImageDtt image_dtt = new ImageDtt();
		  double [][] texture_overlap = image_dtt.combineRGBATiles(
		  double [][] texture_overlap = image_dtt.combineRGBATiles(
+0 −355

File changed.

Preview size limit exceeded, changes collapsed.

+339 −694

File changed.

Preview size limit exceeded, changes collapsed.