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

semi-working terrain elevation

parent 03ff002c
Loading
Loading
Loading
Loading
+26 −13
Original line number Diff line number Diff line
@@ -762,13 +762,12 @@ min_str_neib_fpn 0.35
	public boolean   terr_fit_alpha =         true;  // adjust vegetation alpha pixels
	public boolean   terr_fit_scenes =        true;  // adjust scene offsets (start from 0 always?)
	public boolean   terr_fit_elevations =    false; // adjust elevation pixels (not yet implemented)
//	public boolean [][]  terr_fits = {{true},{true},{true},{false},{true}};
//	public boolean [] terr_fit_disable = new boolean [VegetationLMA.TVAO_TYPES];
//	public boolean [][] terr_fits_disable = new boolean [VegetationLMA.TVAO_TYPES][1];
	public boolean [][] terr_fits_disable = {{false},{false},{false},{true,false,true},{false}};
	public boolean   terr_fit_terr_elev =     false; // adjust terrain elevation (common, maybe add per-pixel later)
	public boolean [][] terr_fits_disable = {{false},{false},{false},{true,false,true},{false},{false}};
	
	public double    terr_max_warp =          1.8;
	public int       terr_max_elevation =     22;    // maximal offset to consider when looking for vegetation influence
	public int       terr_max_elev_terr =      2;    // maximal offset to consider when looking for terrain of variable elevation 

	
	@Deprecated
@@ -2119,15 +2118,18 @@ min_str_neib_fpn 0.35
		gd.addCheckbox    ("Adjust terrain",       terr_fit_terr,      "Adjust terrain pixels.");
		gd.addCheckbox    ("Adjust vegetation",    terr_fit_veget,     "Adjust vegetation pixels.");
		gd.addCheckbox    ("Adjust alpha",         terr_fit_alpha,     "Adjust vegetation alpha pixels.");
		gd.addCheckbox    ("Adjust scene offsets", terr_fit_scenes,    "Adjust scene offsets (start from 0 always?).");
		gd.addCheckbox    ("Adjust elevation",     terr_fit_elevations,"Adjust elevation pixels.");
		gd.addCheckbox    ("Adjust terrain elevation",terr_fit_terr_elev,"Adjust terrain elevation common.");
		gd.addCheckbox    ("Adjust scene offsets", terr_fit_scenes,    "Adjust scene offsets (start from 0 always?).");
		
		
		for (int i = 0; i < terr_fits_disable.length; i++) {
			gd.addStringField ("Skip "+VegetationLMA.TVAO_NAMES[i], booleansToString(terr_fits_disable[i],2), 40,
					"Skip adjustment of "+VegetationLMA.TVAO_NAMES[i]+". Use comma/space separated list of true/false, 1/0 or +/-." );
		}
		gd.addNumericField("Maximal warp",         terr_max_warp, 5,7,"pix", 	"(1.8) Do not use scenes where distance between vegetation projection exceeds this.");
		gd.addNumericField("Min elevation/offset", terr_max_elevation, 0,3,"pix","Maximal offset to consider when looking for vegetation influence.");
		gd.addNumericField("Max elevation/offset", terr_max_elevation, 0,3,"pix","Maximal offset to consider when looking for vegetation influence.");
		gd.addNumericField("Max terrain elevation",terr_max_elev_terr, 0,3,"pix","Maximal terrain offset to consider when looking for variable-elevation terrain.");
		
		gd.addNumericField("(Min influenced scenes)",terr_min_scenes, 0,3,  "",   "Deprecated: Minimal number of scenes (inside woi) vegetation pixel must influence.");
		gd.addNumericField("Minimal samples/scene",terr_min_samples_scene, 0,3,"","Minimal samples per scene used for fitting (skip scene if less).");
@@ -2908,13 +2910,15 @@ min_str_neib_fpn 0.35
		terr_fit_terr =            gd.getNextBoolean();// boolean
		terr_fit_veget =           gd.getNextBoolean();// boolean
		terr_fit_alpha =           gd.getNextBoolean();// boolean
		terr_fit_scenes =          gd.getNextBoolean();// boolean
		terr_fit_elevations =      gd.getNextBoolean();// boolean
		terr_fit_terr_elev =       gd.getNextBoolean();// boolean
		terr_fit_scenes =          gd.getNextBoolean();// boolean
		for (int i = 0; i < terr_fits_disable.length; i++) {
			terr_fits_disable[i] = StringToBooleans(gd.getNextString());// booleans
		}
		terr_max_warp =            gd.getNextNumber();// double 
		terr_max_elevation = (int) gd.getNextNumber();// int
		terr_max_elev_terr = (int) gd.getNextNumber();// int
		
		terr_min_scenes =    (int) gd.getNextNumber();// int
		terr_min_samples_scene=(int) gd.getNextNumber();// int
@@ -3653,14 +3657,17 @@ min_str_neib_fpn 0.35
		properties.setProperty(prefix+"terr_fit_terr",               terr_fit_terr+"");           // boolean
		properties.setProperty(prefix+"terr_fit_veget",              terr_fit_veget+"");          // boolean
		properties.setProperty(prefix+"terr_fit_alpha",              terr_fit_alpha+"");          // boolean
		properties.setProperty(prefix+"terr_fit_scenes",             terr_fit_scenes+"");         // boolean
		properties.setProperty(prefix+"terr_fit_elevations",         terr_fit_elevations+"");     // boolean
		properties.setProperty(prefix+"terr_fit_terr_elev",          terr_fit_terr_elev+"");      // boolean
		properties.setProperty(prefix+"terr_fit_scenes",             terr_fit_scenes+"");         // boolean
		
		for (int i = 0; i < terr_fits_disable.length; i++) {
			String prop_name = prefix+"terr_fits_disable_"+VegetationLMA.TVAO_NAMES[i];
			properties.setProperty(prop_name,                        booleansToString(terr_fits_disable[i],2));     // boolean
		}
		properties.setProperty(prefix+"terr_max_warp",               terr_max_warp+"");           // double 
		properties.setProperty(prefix+"terr_max_elevation",          terr_max_elevation+"");      // int
		properties.setProperty(prefix+"terr_max_elev_terr",          terr_max_elev_terr+"");      // int
		properties.setProperty(prefix+"terr_min_scenes",             terr_min_scenes+"");         // int
		properties.setProperty(prefix+"terr_min_samples_scene",      terr_min_samples_scene+"");  // int
		properties.setProperty(prefix+"terr_min_total_scenes",       terr_min_total_scenes+"");   // int
@@ -4416,8 +4423,9 @@ min_str_neib_fpn 0.35
		if (properties.getProperty(prefix+"terr_fit_terr")!=           null) terr_fit_terr=Boolean.parseBoolean(properties.getProperty(prefix+"terr_fit_terr"));
		if (properties.getProperty(prefix+"terr_fit_veget")!=          null) terr_fit_veget=Boolean.parseBoolean(properties.getProperty(prefix+"terr_fit_veget"));
		if (properties.getProperty(prefix+"terr_fit_alpha")!=          null) terr_fit_alpha=Boolean.parseBoolean(properties.getProperty(prefix+"terr_fit_alpha"));
		if (properties.getProperty(prefix+"terr_fit_scenes")!=         null) terr_fit_scenes=Boolean.parseBoolean(properties.getProperty(prefix+"terr_fit_scenes"));
		if (properties.getProperty(prefix+"terr_fit_elevations")!=     null) terr_fit_elevations=Boolean.parseBoolean(properties.getProperty(prefix+"terr_fit_elevations"));
		if (properties.getProperty(prefix+"terr_fit_terr_elev")!=      null) terr_fit_terr_elev=Boolean.parseBoolean(properties.getProperty(prefix+"terr_fit_terr_elev"));
		if (properties.getProperty(prefix+"terr_fit_scenes")!=         null) terr_fit_scenes=Boolean.parseBoolean(properties.getProperty(prefix+"terr_fit_scenes"));
		for (int i = 0; i < terr_fits_disable.length; i++) {
			String prop_name_old = prefix+"terr_fit_disable_"+VegetationLMA.TVAO_NAMES[i];
			if (properties.getProperty(prop_name_old)!=null) terr_fits_disable[i]= StringToBooleans(properties.getProperty(prop_name_old));// booleans
@@ -4426,6 +4434,7 @@ min_str_neib_fpn 0.35
		}
		if (properties.getProperty(prefix+"terr_max_warp")!=           null) terr_max_warp=Double.parseDouble(properties.getProperty(prefix+"terr_max_warp"));
		if (properties.getProperty(prefix+"terr_max_elevation")!=      null) terr_max_elevation=Integer.parseInt(properties.getProperty(prefix+"terr_max_elevation"));
		if (properties.getProperty(prefix+"terr_max_elev_terr")!=      null) terr_max_elev_terr=Integer.parseInt(properties.getProperty(prefix+"terr_max_elev_terr"));
		if (properties.getProperty(prefix+"terr_min_scenes")!=         null) terr_min_scenes=Integer.parseInt(properties.getProperty(prefix+"terr_min_scenes"));
		if (properties.getProperty(prefix+"terr_min_samples_scene")!=  null) terr_min_samples_scene=Integer.parseInt(properties.getProperty(prefix+"terr_min_samples_scene"));
		if (properties.getProperty(prefix+"terr_min_total_scenes")!=   null) terr_min_total_scenes=Integer.parseInt(properties.getProperty(prefix+"terr_min_total_scenes"));
@@ -5153,13 +5162,15 @@ min_str_neib_fpn 0.35
		imp.terr_fit_terr =                      this.terr_fit_terr;                           
		imp.terr_fit_veget =                     this.terr_fit_veget;                           
		imp.terr_fit_alpha =                     this.terr_fit_alpha;                           
		imp.terr_fit_scenes =                    this.terr_fit_scenes;                           
		imp.terr_fit_elevations =                this.terr_fit_elevations;
		imp.terr_fit_terr_elev =                 this.terr_fit_terr_elev;
		imp.terr_fit_scenes =                    this.terr_fit_scenes;                           
		for (int i = 0; i < terr_fits_disable.length; i++) {
			imp.terr_fits_disable[i] =                   this.terr_fits_disable[i].clone();
		}
		imp.terr_max_warp =                      this.terr_max_warp;
		imp.terr_max_elevation =                 this.terr_max_elevation;
		imp.terr_max_elev_terr =                 this.terr_max_elev_terr;
		imp.terr_min_scenes =                    this.terr_min_scenes;
		imp.terr_min_samples_scene =             this.terr_min_samples_scene;
		imp.terr_min_total_scenes =              this.terr_min_total_scenes;
@@ -5363,7 +5374,9 @@ min_str_neib_fpn 0.35
		}
	}

	public static String booleansToString (boolean [] data, int mode) { // 0 : true/false, 1: 0/1, 2: +/-
	public static String booleansToString (boolean [] data, int mode) { // 0 : true/false, 1: 0/1, 2: +/-, negative - skip separators (", ")
		boolean use_sep = mode >= 0;
		mode = Math.abs(mode);
		String s = "";
		for (int i = 0; i < data.length; i++) {
			switch (mode) {
@@ -5372,7 +5385,7 @@ min_str_neib_fpn 0.35
			case 2: s += data[i] ? "+":"-"; break;
			default: s += data[i];// true/false
			}
			if (i < (data.length - 1)) {
			if (use_sep && (i < (data.length - 1))) {
				s+= ", ";
			}
		}
+1226 −465

File changed.

Preview size limit exceeded, changes collapsed.

+13 −4
Original line number Diff line number Diff line
@@ -1488,7 +1488,8 @@ public class VegetationModel {
		boolean   skip_existing_woi = clt_parameters.imp.terr_skip_exist;          // skip existing woi/parameters, already saved.
		boolean   continue_woi =      clt_parameters.imp.terr_continue;            // false;
		double    max_warp =          clt_parameters.imp.terr_max_warp; // 1.8 - do not use scenes where distance between vegetation projection exceeds this
		int       max_offset =        clt_parameters.imp.terr_max_elevation;       // maximal "elevation" to consider 
		int       max_elevation =     clt_parameters.imp.terr_max_elevation;       // maximal "elevation" to consider 
		int       max_elev_terr =     clt_parameters.imp.terr_max_elev_terr;       // maximal "elevation" to consider 
		
//		int       min_scenes =        clt_parameters.imp.terr_min_scenes;          // 1;
//		int       min_samples_scene = clt_parameters.imp.terr_min_samples_scene;   //10;
@@ -1570,6 +1571,7 @@ public class VegetationModel {
		boolean   fit_alpha =         clt_parameters.imp.terr_fit_alpha;      // true;  // adjust vegetation alpha pixels
		boolean   fit_scenes =        clt_parameters.imp.terr_fit_scenes;     // true;  // adjust scene offsets (start from 0 always?)
		boolean   fit_elevations =    clt_parameters.imp.terr_fit_elevations; // false; // adjust elevation pixels (not yet implemented)
		boolean   fit_terr_elev =     clt_parameters.imp.terr_fit_terr_elev;  // false; // adjust terrain elevation (common, maybe add per-pixel later)
		
//		boolean [] fit_disable =      clt_parameters.imp.terr_fit_disable.clone();
		boolean [][] fits_disable = new boolean[clt_parameters.imp.terr_fits_disable.length][];
@@ -2084,8 +2086,10 @@ public class VegetationModel {
					false,             // final boolean            keep_parameters,
					woi,               // final Rectangle   woi,
					null, // final Rectangle          woi_veg_in, // used when loading from file (may be different)
					null, // final Rectangle          woi_terr_in, // used when loading from file (may be different)
					max_warp,          //			final double             max_warp, // 1.8 - do not use scenes where distance between vegetation projection exceeds this
					max_offset,        // final int                max_offset,               // maximal "elevation" to consider 					
					max_elevation,     // final int                max_offset,               // maximal "elevation" to consider
					max_elev_terr,     // final int                max_elev_terr,               // maximal terrain "elevation" to consider
					elevation_radius,  // final double             elevation_radius, // Radius of elevation/vegetation influence.
					null, // final boolean []         valid_scene_pix,         
					hifreq_weight,     //final double             hifreq_weight,  // 22.5 0 - do not use high-freq. Relative weight of laplacian components
@@ -2095,6 +2099,7 @@ public class VegetationModel {
					fit_alpha,         // final boolean            adjust_alpha,
					fit_scenes,        // final boolean            adjust_scenes,
					fit_elevations,    // final boolean            adjust_elevations,
					fit_terr_elev,     // final boolean            fit_terr_elev,					
					thisOrLast(step_restore, fits_disable), // fits_disables[0], // final boolean []         fit_disable,  
					reg_weights,       // final double             reg_weights,        // fraction of the total weight used for regularization
					alpha_loss,        // final double             alpha_loss,         // alpha quadratic growing loss for when out of [0,1] range
@@ -2189,7 +2194,7 @@ public class VegetationModel {
				vegetationLMA.restoreParametersFile( //FIXME: Not finished for real import ! 
						par_path, // String        path,
						true,     // boolean       keep_settings,
						null,     // Rectangle [] file_wois);      //  if not null, should be Rectangle[2] {woi_veg,woi} - will return woi data and not input parameters to this instance
///						null,     // Rectangle [] file_wois);      //  if not null, should be Rectangle[2] {woi_veg,woi} - will return woi data and not input parameters to this instance
						null);    // double [] other_pars)
				if (thisOrLast(step_restore,recalc_weights)) {
					System.out.println ("---- Recalculating weights from transparency after loading parameters");
@@ -2230,6 +2235,7 @@ public class VegetationModel {
				vegetationLMA.showYfX(
						null, // double [] vector,
						"reconstructed_model-x"+woi.x+"-y"+woi.y+"-w"+woi.width+"-h"+woi.height); // String title)
				/*
				vegetationLMA.showResults(
						"terr_split-x"+woi.x+"-y"+woi.y+"-w"+woi.width+"-h"+woi.height,                        // String      title,
						vegetationLMA.getParametersVector(), // double []   vector,
@@ -2237,6 +2243,8 @@ public class VegetationModel {
						min_max_terrain, // double      min_max_terrain, //0.1
						min_terrain,                         //double      min_terrain, //0.001
						min_vegetation);                     // double      min_vegetation) { // 0.5
						*/
								
			}
			/// next_run = true;
			vegetationLMA.debug_index = 0;
@@ -2270,6 +2278,7 @@ public class VegetationModel {
	  		for (; step_restore <= last_series; step_restore++) {
//	  			vegetationLMA.fits_disable[VegetationLMA.TVAO_ELEVATION] = fits_disable[step_restore][VegetationLMA.TVAO_ELEVATION];
	  			vegetationLMA.fits_disable[VegetationLMA.TVAO_ELEVATION] =thisOrLast(step_restore,fits_disable)[VegetationLMA.TVAO_ELEVATION];
	  			vegetationLMA.fits_disable[VegetationLMA.TVAO_TERR_ELEV] =thisOrLast(step_restore,fits_disable)[VegetationLMA.TVAO_TERR_ELEV];
				if (thisOrLast(step_restore,recalc_weights)) {
					System.out.println ("---- Recalculating weights from transparency");
					String dbg_title= (!tile_woi && (debugLevel > -2)) ? ("transparency_"+step_restore) : null;