Commit 42bc2c68 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

adding tile assignment to surfaces costs

parent 076baece
Loading
Loading
Loading
Loading
+61 −0
Original line number Original line Diff line number Diff line
@@ -69,6 +69,67 @@ public class CLTPass3d{
		{
		{
			return this.tileProcessor;
			return this.tileProcessor;
		}
		}
		
		public double [][][][] getTextureTiles()
		{
			return 	texture_tiles;
		}
		
		public double [][] getTileRBGA(
				int num_layers)
		{
			if (texture_tiles == null) return null;
			int tilesY = texture_tiles.length;
			int tilesX = 0;
			int nl = 0;
			for (int ty = 0; ty < tilesY; ty++){
				if (texture_tiles[ty] != null){
					tilesX = texture_tiles[ty].length;
					for (int tx = 0; tx < tilesX; tx++){
						if (texture_tiles[ty][tx] != null){
							nl = texture_tiles[ty][tx].length;
							break;
						}
					}
					if (nl > 0) break;
				}
				if (nl > 0) break;
			}
			if (num_layers > nl) num_layers = nl;
			int numTiles = tilesX * tilesY;
			double [] scales = new double [num_layers];
			for (int n = 0; n < num_layers; n++){
				if       (n < 3)  scales[n] = 1.0/255.0; // R,B,G
				else if  (n == 3) scales[n] = 1.0; //alpha
				else if  (n < 8)  scales[n] = 1.0; // ports 0..3
				else              scales[n] = 1.0/255.0; // RBG rms, in 1/255 units, but small 
			}
			double [][] tileTones = new double [num_layers][numTiles];
			for (int ty = 0; ty < tilesY; ty++ ) if (texture_tiles[ty] != null){
				for (int tx = 0; tx < tilesX; tx++ ) if (texture_tiles[ty][tx] != null) {
					int indx = ty * tilesX + tx;
					for (int n = 0; n < num_layers; n++) if (texture_tiles[ty][tx][n] != null){
						double s = 0.0;
						for (int i = 0; i < texture_tiles[ty][tx][n].length; i++){
							s += texture_tiles[ty][tx][n][i];
						}
						s /= (texture_tiles[ty][tx][n].length/4); // overlapping tiles
						s *= scales[n];
						tileTones[n][indx] = s;
					}
				}
			}
			return tileTones;
		}
		
		public String getTextureName()
		{
			if (texture != null) {
				return texture;
			} else {
				return "null-texture-name";
			}
		}
		public  void            updateSelection(){ // add updating border tiles?
		public  void            updateSelection(){ // add updating border tiles?
			int tilesX = tileProcessor.getTilesX();
			int tilesX = tileProcessor.getTilesX();
			int tilesY = tileProcessor.getTilesY();
			int tilesY = tileProcessor.getTilesY();
+83 −4
Original line number Original line Diff line number Diff line
@@ -2350,6 +2350,20 @@ public class EyesisCorrectionParameters {
		public int        tsConsensMode        = 7;      // Which assignments to match +1 - combo, +2 grown single, +4 plane seeds 
		public int        tsConsensMode        = 7;      // Which assignments to match +1 - combo, +2 grown single, +4 plane seeds 
		public int        tsConsensAgree       = 1;      // Minimal number of assignments to agree
		public int        tsConsensAgree       = 1;      // Minimal number of assignments to agree
		
		
		// Tile assignment parameters
  		public double     taCostEmpty          = 1.0;    // Cost of a tile that is not assigned
  		public double     taCostNoLink         = 1.0;    // Cost of a tile not having any neighbor in particular direction
  		public double     taCostSwitch         = 1.0;    // Cost of a tile switching to a neighbor that does not have a link
  		public double     taCostColor          = 1.0;    // Cost of a tile switching to a disconnected neighbor divided by a color mismatch
  		public double     taCostDiff           = 1.0;    // Cost of a weighted normalized tile disparity error
  		public double     taCostDiffBest       = 1.0;    // Cost of a weighted normalized tile disparity error above best surface
  		public double     taCostDiff9          = 1.0;    // Cost of a weighted normalized tile disparity error for tile and 8 neighbors (DC)
  		public double     taCostWeakFgnd       = 1.0;    // Cost of a weak foreground edge
  		public double     taCostFlaps          = 1.0;    // Cost of using supertile "flaps" (not in the center 8x8 tiles area)
  		public double     taCostMismatch       = 1.0;    // Cost of a measurement layer not having same layer in the same location or near
  		
  		
		
		
		
  		public boolean    replaceWeakOutlayers =   true; // false; 
  		public boolean    replaceWeakOutlayers =   true; // false; 
  		
  		
@@ -2777,6 +2791,17 @@ public class EyesisCorrectionParameters {
			properties.setProperty(prefix+"tsConsensMode",    this.tsConsensMode +"");
			properties.setProperty(prefix+"tsConsensMode",    this.tsConsensMode +"");
			properties.setProperty(prefix+"tsConsensAgree",   this.tsConsensAgree +"");
			properties.setProperty(prefix+"tsConsensAgree",   this.tsConsensAgree +"");


			properties.setProperty(prefix+"taCostEmpty",      this.taCostEmpty +"");
			properties.setProperty(prefix+"taCostNoLink",     this.taCostNoLink +"");
			properties.setProperty(prefix+"taCostSwitch",     this.taCostSwitch +"");
			properties.setProperty(prefix+"taCostColor",      this.taCostColor +"");
			properties.setProperty(prefix+"taCostDiff",       this.taCostDiff +"");
			properties.setProperty(prefix+"taCostDiffBest",   this.taCostDiffBest +"");
			properties.setProperty(prefix+"taCostDiff9",      this.taCostDiff9 +"");
			properties.setProperty(prefix+"taCostWeakFgnd",   this.taCostWeakFgnd +"");
			properties.setProperty(prefix+"taCostFlaps",      this.taCostFlaps +"");
			properties.setProperty(prefix+"taCostMismatch",   this.taCostMismatch +"");
			
			properties.setProperty(prefix+"dbg_migrate",            this.dbg_migrate+"");
			properties.setProperty(prefix+"dbg_migrate",            this.dbg_migrate+"");
  			
  			
			properties.setProperty(prefix+"show_ortho_combine",     this.show_ortho_combine+"");
			properties.setProperty(prefix+"show_ortho_combine",     this.show_ortho_combine+"");
@@ -3176,9 +3201,9 @@ public class EyesisCorrectionParameters {
  			if (properties.getProperty(prefix+"tsMaxSurStrength")!=null)  this.tsMaxSurStrength=Double.parseDouble(properties.getProperty(prefix+"tsMaxSurStrength"));
  			if (properties.getProperty(prefix+"tsMaxSurStrength")!=null)  this.tsMaxSurStrength=Double.parseDouble(properties.getProperty(prefix+"tsMaxSurStrength"));
  			if (properties.getProperty(prefix+"tsCountDis")!=null)        this.tsCountDis=Boolean.parseBoolean(properties.getProperty(prefix+"tsCountDis"));
  			if (properties.getProperty(prefix+"tsCountDis")!=null)        this.tsCountDis=Boolean.parseBoolean(properties.getProperty(prefix+"tsCountDis"));
  			
  			
  			if (properties.getProperty(prefix+"tsEnPlaneSeed")!=null)     this.tsEnOnly=Boolean.parseBoolean(properties.getProperty(prefix+"tsEnPlaneSeed"));
  			if (properties.getProperty(prefix+"tsEnPlaneSeed")!=null)     this.tsEnPlaneSeed=Boolean.parseBoolean(properties.getProperty(prefix+"tsEnPlaneSeed"));
  			if (properties.getProperty(prefix+"tsEnOnly")!=null)          this.tsEnOnly=Boolean.parseBoolean(properties.getProperty(prefix+"tsEnOnly"));
  			if (properties.getProperty(prefix+"tsEnOnly")!=null)          this.tsEnOnly=Boolean.parseBoolean(properties.getProperty(prefix+"tsEnOnly"));
  			if (properties.getProperty(prefix+"tsEnGrow")!=null)          this.tsEnOnly=Boolean.parseBoolean(properties.getProperty(prefix+"tsEnGrow"));
  			if (properties.getProperty(prefix+"tsEnGrow")!=null)          this.tsEnGrow=Boolean.parseBoolean(properties.getProperty(prefix+"tsEnGrow"));
  			if (properties.getProperty(prefix+"tsGrowStrength")!=null)    this.tsGrowStrength=Double.parseDouble(properties.getProperty(prefix+"tsGrowStrength"));
  			if (properties.getProperty(prefix+"tsGrowStrength")!=null)    this.tsGrowStrength=Double.parseDouble(properties.getProperty(prefix+"tsGrowStrength"));
  			if (properties.getProperty(prefix+"tsGrowStrong")!=null)      this.tsGrowStrong=Boolean.parseBoolean(properties.getProperty(prefix+"tsGrowStrong"));
  			if (properties.getProperty(prefix+"tsGrowStrong")!=null)      this.tsGrowStrong=Boolean.parseBoolean(properties.getProperty(prefix+"tsGrowStrong"));
  			if (properties.getProperty(prefix+"tsContStrength")!=null)    this.tsGrowStrength=Double.parseDouble(properties.getProperty(prefix+"tsContStrength"));
  			if (properties.getProperty(prefix+"tsContStrength")!=null)    this.tsGrowStrength=Double.parseDouble(properties.getProperty(prefix+"tsContStrength"));
@@ -3197,6 +3222,17 @@ public class EyesisCorrectionParameters {
  			if (properties.getProperty(prefix+"tsConsensMode")!=null)     this.tsConsensMode=Integer.parseInt(properties.getProperty(prefix+"tsConsensMode"));
  			if (properties.getProperty(prefix+"tsConsensMode")!=null)     this.tsConsensMode=Integer.parseInt(properties.getProperty(prefix+"tsConsensMode"));
  			if (properties.getProperty(prefix+"tsConsensAgree")!=null)    this.tsConsensAgree=Integer.parseInt(properties.getProperty(prefix+"tsConsensAgree"));
  			if (properties.getProperty(prefix+"tsConsensAgree")!=null)    this.tsConsensAgree=Integer.parseInt(properties.getProperty(prefix+"tsConsensAgree"));
  			
  			
  			if (properties.getProperty(prefix+"taCostEmpty")!=null)       this.taCostEmpty=Double.parseDouble(properties.getProperty(prefix+"taCostEmpty"));
  			if (properties.getProperty(prefix+"taCostNoLink")!=null)      this.taCostNoLink=Double.parseDouble(properties.getProperty(prefix+"taCostNoLink"));
  			if (properties.getProperty(prefix+"taCostSwitch")!=null)      this.taCostSwitch=Double.parseDouble(properties.getProperty(prefix+"taCostSwitch"));
  			if (properties.getProperty(prefix+"taCostColor")!=null)       this.taCostColor=Double.parseDouble(properties.getProperty(prefix+"taCostColor"));
  			if (properties.getProperty(prefix+"taCostDiff")!=null)        this.taCostDiff=Double.parseDouble(properties.getProperty(prefix+"taCostDiff"));
  			if (properties.getProperty(prefix+"taCostDiffBest")!=null)    this.taCostDiffBest=Double.parseDouble(properties.getProperty(prefix+"taCostDiffBest"));
  			if (properties.getProperty(prefix+"taCostDiff9")!=null)       this.taCostDiff9=Double.parseDouble(properties.getProperty(prefix+"taCostDiff9"));
  			if (properties.getProperty(prefix+"taCostWeakFgnd")!=null)    this.taCostWeakFgnd=Double.parseDouble(properties.getProperty(prefix+"taCostWeakFgnd"));
  			if (properties.getProperty(prefix+"taCostFlaps")!=null)       this.taCostFlaps=Double.parseDouble(properties.getProperty(prefix+"taCostFlaps"));
  			if (properties.getProperty(prefix+"taCostMismatch")!=null)    this.taCostMismatch=Double.parseDouble(properties.getProperty(prefix+"taCostMismatch"));

  			if (properties.getProperty(prefix+"dbg_migrate")!=null)       this.dbg_migrate=Boolean.parseBoolean(properties.getProperty(prefix+"dbg_migrate"));
  			if (properties.getProperty(prefix+"dbg_migrate")!=null)       this.dbg_migrate=Boolean.parseBoolean(properties.getProperty(prefix+"dbg_migrate"));


  			if (properties.getProperty(prefix+"show_ortho_combine")!=null)     this.show_ortho_combine=Boolean.parseBoolean(properties.getProperty(prefix+"show_ortho_combine"));
  			if (properties.getProperty(prefix+"show_ortho_combine")!=null)     this.show_ortho_combine=Boolean.parseBoolean(properties.getProperty(prefix+"show_ortho_combine"));
@@ -3648,6 +3684,18 @@ public class EyesisCorrectionParameters {
  			gd.addNumericField("Which assignments to match +1 - combo, +2 grown single, +4 plane seeds",          this.tsConsensMode,  0);
  			gd.addNumericField("Which assignments to match +1 - combo, +2 grown single, +4 plane seeds",          this.tsConsensMode,  0);
  			gd.addNumericField("Minimal number of assignments to agree",                                          this.tsConsensAgree,  0);
  			gd.addNumericField("Minimal number of assignments to agree",                                          this.tsConsensAgree,  0);


  			gd.addMessage     ("--- Tile assignment parameters ---");
  			gd.addNumericField("Cost of a tile that is not assigned",                                             this.taCostEmpty,  6);
  			gd.addNumericField("Cost of a tile not having any neighbor in particular direction",                  this.taCostNoLink,  6);
  			gd.addNumericField("Cost of a tile switching to a neighbor that does not have a link",                this.taCostSwitch,  6);
  			gd.addNumericField("Cost of a tile switching to a disconnected neighbor divided by a color",          this.taCostColor,  6);
  			gd.addNumericField("Cost of a weighted normalized tile disparity error",                              this.taCostDiff,  6);
  			gd.addNumericField("Cost of a weighted normalized tile disparity error above best surface",           this.taCostDiffBest,  6);
  			gd.addNumericField("Cost of a weighted normalized tile disparity error for tile and 8 neighbors (DC)",this.taCostDiff9,  6);
  			gd.addNumericField("Cost of a weak foreground edge",                                                  this.taCostWeakFgnd,  6);
  			gd.addNumericField("Cost of using supertile \"flaps\" (not in the center 8x8 tiles area)",            this.taCostFlaps,  6);
  			gd.addNumericField("Cost of a measurement layer not having same layer in the same location or near",  this.taCostMismatch,  6);

  			gd.addCheckbox    ("Test new mode after migration",                                                this.dbg_migrate);
  			gd.addCheckbox    ("Test new mode after migration",                                                this.dbg_migrate);


  			gd.addMessage     ("--- Other debug images ---");
  			gd.addMessage     ("--- Other debug images ---");
@@ -4076,6 +4124,17 @@ public class EyesisCorrectionParameters {
  			this.tsConsensMode =  (int) gd.getNextNumber();
  			this.tsConsensMode =  (int) gd.getNextNumber();
  			this.tsConsensAgree = (int) gd.getNextNumber();
  			this.tsConsensAgree = (int) gd.getNextNumber();


  			this.taCostEmpty=           gd.getNextNumber();
  			this.taCostNoLink=          gd.getNextNumber();
  			this.taCostSwitch=          gd.getNextNumber();
  			this.taCostColor=           gd.getNextNumber();
  			this.taCostDiff=            gd.getNextNumber();
  			this.taCostDiffBest=        gd.getNextNumber();
  			this.taCostDiff9=           gd.getNextNumber();
  			this.taCostWeakFgnd=        gd.getNextNumber();
  			this.taCostFlaps=           gd.getNextNumber();
  			this.taCostMismatch=        gd.getNextNumber();

  			this.dbg_migrate=           gd.getNextBoolean();
  			this.dbg_migrate=           gd.getNextBoolean();


  			this.show_ortho_combine=    gd.getNextBoolean();
  			this.show_ortho_combine=    gd.getNextBoolean();
@@ -4139,6 +4198,17 @@ public class EyesisCorrectionParameters {
  			gd.addNumericField("Which assignments to match +1 - combo, +2 grown single, +4 plane seeds",          this.tsConsensMode,  0);
  			gd.addNumericField("Which assignments to match +1 - combo, +2 grown single, +4 plane seeds",          this.tsConsensMode,  0);
  			gd.addNumericField("Minimal number of assignments to agree",                                          this.tsConsensAgree,  0);
  			gd.addNumericField("Minimal number of assignments to agree",                                          this.tsConsensAgree,  0);
  			
  			
   			gd.addMessage     ("--- Tile assignment parameters ---");
  			gd.addNumericField("Cost of a tile that is not assigned",                                             this.taCostEmpty,  6);
  			gd.addNumericField("Cost of a tile not having any neighbor in particular direction",                  this.taCostNoLink,  6);
  			gd.addNumericField("Cost of a tile switching to a neighbor that does not have a link",                this.taCostSwitch,  6);
  			gd.addNumericField("Cost of a tile switching to a disconnected neighbor divided by a color",          this.taCostColor,  6);
  			gd.addNumericField("Cost of a weighted normalized tile disparity error",                              this.taCostDiff,  6);
  			gd.addNumericField("Cost of a weighted normalized tile disparity error above best surface",           this.taCostDiffBest,  6);
  			gd.addNumericField("Cost of a weighted normalized tile disparity error for tile and 8 neighbors (DC)",this.taCostDiff9,  6);
  			gd.addNumericField("Cost of a weak foreground edge",                                                  this.taCostWeakFgnd,  6);
  			gd.addNumericField("Cost of using supertile \"flaps\" (not in the center 8x8 tiles area)",            this.taCostFlaps,  6);
  			gd.addNumericField("Cost of a measurement layer not having same layer in the same location or near",  this.taCostMismatch,  6);
  			
  			
  			WindowTools.addScrollBars(gd);
  			WindowTools.addScrollBars(gd);
  			gd.showDialog();
  			gd.showDialog();
@@ -4185,9 +4255,18 @@ public class EyesisCorrectionParameters {
  			this.tsConsensMode =  (int) gd.getNextNumber();
  			this.tsConsensMode =  (int) gd.getNextNumber();
  			this.tsConsensAgree = (int) gd.getNextNumber();
  			this.tsConsensAgree = (int) gd.getNextNumber();


   			this.taCostEmpty=           gd.getNextNumber();
  			this.taCostNoLink=          gd.getNextNumber();
  			this.taCostSwitch=          gd.getNextNumber();
  			this.taCostColor=           gd.getNextNumber();
  			this.taCostDiff=            gd.getNextNumber();
  			this.taCostDiffBest=        gd.getNextNumber();
  			this.taCostDiff9=           gd.getNextNumber();
  			this.taCostWeakFgnd=        gd.getNextNumber();
  			this.taCostFlaps=           gd.getNextNumber();
  			this.taCostMismatch=        gd.getNextNumber();
  			return true;
  			return true;
  		}
  		}
  		
    }
    }


    public static class DCTParameters {
    public static class DCTParameters {
+1 −1
Original line number Original line Diff line number Diff line
@@ -3196,7 +3196,7 @@ public class QuadCLT {
		  double [][][][]     clt_corr_combo =   null;
		  double [][][][]     clt_corr_combo =   null;
		  double [][][][][]   clt_corr_partial = null; // [tp.tilesY][tp.tilesX][pair][color][(2*transform_size-1)*(2*transform_size-1)]
		  double [][][][][]   clt_corr_partial = null; // [tp.tilesY][tp.tilesX][pair][color][(2*transform_size-1)*(2*transform_size-1)]
		  double [][]         clt_mismatch =     null; // [3*4][tp.tilesY * tp.tilesX] // transpose unapplied
		  double [][]         clt_mismatch =     null; // [3*4][tp.tilesY * tp.tilesX] // transpose unapplied
		  double [][][][]     texture_tiles =    null; // [tp.tilesY][tp.tilesX]["RGBA".length()][]; // tiles will be 16x16, 2 visualizaion mode full 16 or overlapped
		  double [][][][]     texture_tiles =    null; // [tp.tilesY][tp.tilesX]["RGBA".length()][]; // tiles will be 16x16, 2 visualization mode full 16 or overlapped
		  // undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
		  // undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
		  final int tilesX = tp.getTilesX();
		  final int tilesX = tp.getTilesX();
		  final int tilesY = tp.getTilesY();
		  final int tilesY = tp.getTilesY();
+854 −0

File added.

Preview size limit exceeded, changes collapsed.

+17 −3
Original line number Original line Diff line number Diff line
@@ -44,6 +44,10 @@ public class TileNeibs{
		return (dir + dirs / 2) % dirs;
		return (dir + dirs / 2) % dirs;
	}
	}
	
	
	int getLength(){
		return sizeX * sizeY;
	}
	
	/**
	/**
	 * Get x,y pair from index
	 * Get x,y pair from index
	 * @param indx element index
	 * @param indx element index
@@ -64,9 +68,15 @@ public class TileNeibs{
	 */
	 */
	
	
	int getIndex(int x, int y){
	int getIndex(int x, int y){
		if ((x < 0) || (y < 0) || (x >= sizeX) || (y >= sizeY)) return -1;
		return y * sizeX + x;
		return y * sizeX + x;
	}
	}


	int getIndex(int [] xy){
		if ((xy[0] < 0) || (xy[1] < 0) || (xy[0] >= sizeX) || (xy[1] >= sizeY)) return -1;
		return xy[1] * sizeX + xy[0];
	}

	/**
	/**
	 * Get 2d element index after step N, NE, ... NW. Returns -1 if leaving array   
	 * Get 2d element index after step N, NE, ... NW. Returns -1 if leaving array   
	 * @param indx start index
	 * @param indx start index
@@ -78,7 +88,11 @@ public class TileNeibs{
		int y = indx / sizeX;
		int y = indx / sizeX;
		int x = indx % sizeX;
		int x = indx % sizeX;
		if (dir < 0) return indx;
		if (dir < 0) return indx;
		switch (dir % dirs){
		if (dir > 8) {
			System.out.println("getNeibIndex(): indx="+indx+", dir="+dir);
		}
//		switch (dir % dirs){
		switch (dir){
		case 0: return (y == 0) ?                                    -1 : (indx - sizeX); 
		case 0: return (y == 0) ?                                    -1 : (indx - sizeX); 
		case 1: return ((y == 0)           || ( x == (sizeX - 1))) ? -1 : (indx - sizeX + 1); 
		case 1: return ((y == 0)           || ( x == (sizeX - 1))) ? -1 : (indx - sizeX + 1); 
		case 2: return (                      ( x == (sizeX - 1))) ? -1 : (indx        + 1); 
		case 2: return (                      ( x == (sizeX - 1))) ? -1 : (indx        + 1); 
Loading