Commit 26c0232c authored by Andrey Filippov's avatar Andrey Filippov
Browse files

adding extra elevation radius scaling (*1.2)

parent 52ace80b
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -795,6 +795,9 @@ min_str_neib_fpn 0.35
	public double    terr_difference =        100.0;     // vegetation is 100 warmer (target)
	public double    terr_pull_cold =          0.001;    // pull vegetations to warm, terrain to cold
	public double    terr_elevation_radius =   1.5;      // Radius of elevation/vegetation influence
	public double    terr_terr_elev_radius =   1.5;      // Terrain elevation radius
	public double    terr_elev_radius_extra =  1.2;      // scale both radii when setupElevationLMA(), and setupTerrainElevationPixLMA() (not setupTerrainElevationLMA()) 
	
	public double    terr_alpha_contrast =     1.0; // initial alpha contrast (>=1.0)
	public double    terr_alpha_dflt =         0.5; // now unused
	
@@ -2168,6 +2171,8 @@ min_str_neib_fpn 0.35
		
		gd.addNumericField("Pull terrain cold",    terr_pull_cold, 5,7,"", 	"Pull vegetations to warm, terrain to cold.");
		gd.addNumericField("Elevation radius",     terr_elevation_radius, 5,7,"pix","Radius of elevation/vegetation influence.");
		gd.addNumericField("Terrain elevation radius",terr_terr_elev_radius, 5,7,"pix","Radius of terrain elevation influence.");
		gd.addNumericField("Radius extra",         terr_elev_radius_extra, 5,7,"pix","Increase both radii when recalculating for variable elevation.");
		
		gd.addNumericField("Alpha initial contrast",terr_alpha_contrast, 5,7,"","Initial alpha contrast (>= 1.0).");
		gd.addNumericField("Defalt alpha",         terr_alpha_dflt, 5,7,"", 	"Default vegetation alpha.");
@@ -2971,6 +2976,9 @@ min_str_neib_fpn 0.35
		terr_difference =          gd.getNextNumber();// double
		terr_pull_cold =           gd.getNextNumber();// double 
		terr_elevation_radius =    gd.getNextNumber();// double 
		terr_terr_elev_radius =    gd.getNextNumber();// double 
		terr_elev_radius_extra =   gd.getNextNumber();// double 
		
		terr_alpha_contrast =      gd.getNextNumber();// double 
		terr_alpha_dflt =          gd.getNextNumber();// double
		
@@ -3740,6 +3748,10 @@ min_str_neib_fpn 0.35
				
		properties.setProperty(prefix+"terr_pull_cold",              terr_pull_cold+"");          // double
		properties.setProperty(prefix+"terr_elevation_radius",       terr_elevation_radius+"");   // double
		properties.setProperty(prefix+"terr_terr_elev_radius",       terr_terr_elev_radius+"");   // double
		properties.setProperty(prefix+"terr_elev_radius_extra",      terr_elev_radius_extra+"");  // double
		
		
		properties.setProperty(prefix+"terr_alpha_contrast",         terr_alpha_contrast+"");     // double 
		properties.setProperty(prefix+"terr_alpha_dflt",             terr_alpha_dflt+"");         // double
		
@@ -4526,6 +4538,9 @@ min_str_neib_fpn 0.35
		if (properties.getProperty(prefix+"terr_difference")!=         null) terr_difference=Double.parseDouble(properties.getProperty(prefix+"terr_difference"));
		if (properties.getProperty(prefix+"terr_pull_cold")!=          null) terr_pull_cold=Double.parseDouble(properties.getProperty(prefix+"terr_pull_cold"));
		if (properties.getProperty(prefix+"terr_elevation_radius")!=   null) terr_elevation_radius=Double.parseDouble(properties.getProperty(prefix+"terr_elevation_radius"));
		if (properties.getProperty(prefix+"terr_terr_elev_radius")!=   null) terr_terr_elev_radius=Double.parseDouble(properties.getProperty(prefix+"terr_terr_elev_radius"));
		if (properties.getProperty(prefix+"terr_elev_radius_extra")!=  null) terr_elev_radius_extra=Double.parseDouble(properties.getProperty(prefix+"terr_elev_radius_extra"));
		
		if (properties.getProperty(prefix+"terr_alpha_contrast")!=     null) terr_alpha_contrast=Double.parseDouble(properties.getProperty(prefix+"terr_alpha_contrast"));
		if (properties.getProperty(prefix+"terr_alpha_dflt")!=         null) terr_alpha_dflt=Double.parseDouble(properties.getProperty(prefix+"terr_alpha_dflt"));
		
@@ -5276,6 +5291,10 @@ min_str_neib_fpn 0.35
		imp.terr_difference =                    this.terr_difference;		
		imp.terr_pull_cold =                     this.terr_pull_cold; 
		imp.terr_elevation_radius =              this.terr_elevation_radius;
		imp.terr_terr_elev_radius =              this.terr_terr_elev_radius;
		imp.terr_elev_radius_extra =             this.terr_elev_radius_extra;
		
		
		imp.terr_alpha_contrast =                this.terr_alpha_contrast; 
		imp.terr_alpha_dflt =                    this.terr_alpha_dflt;
		
+19 −24
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ public class VegetationLMA {
	
	// elevation-dependent parameters, calculated once if elevations are not adjusted or each time if they are
	private double []         elev_radius;       // for the future - make variable-size influence of the vegetation to mitigate far influenced pixels
	private double            elev_radius_extra =  1.2;      // scale both radii when setupElevationLMA(), setupTerrainElevationLMA(), and setupTerrainElevationPixLMA() 
	private int [][][]        elev_woi4;         // [scene][woi_veg][~4] indices (in woi) of 4 (or more/less) neighbors of projections (negatives)
	private double [][][]     elev_weights4;     // [scene][woi_veg][~4] weights of influence for 4 neighbors
	private double [][]       elev_sum_weights;  // [scene][woi] sum weights from up to 4 elevation pixels (even more with overlap)
@@ -859,6 +860,8 @@ public class VegetationLMA {
			final int                max_elev_terr,               // maximal terrain "elevation" to consider
			final double             max_elev_terr_chg, // 0.5 maximal terrain elevation change from last successfully used 
			final double             elevation_radius, //Radius of elevation/vegetation influence.
			final double             terr_elev_radius, //  = 1.5; 
			final double             elev_radius_extra, //  =  1.2;      // scale both radii when setupElevationLMA(), setupTerrainElevationLMA(), and setupTerrainElevationPixLMA() 
			final boolean [][]       valid_scene_pix_in, // may have nulls or be shorter (do not update "overlaid")     
			final double             hifreq_weight,  // 22.5 0 - do not use high-freq. Relative weight of laplacian components
			final double             terrain_correction,
@@ -997,6 +1000,8 @@ public class VegetationLMA {
		if ((debug_path != null) && (debug_path.length() > 0)) {
			this.debug_path = debug_path;
		}
		this.terr_elev_radius =   terr_elev_radius;
		this.elev_radius_extra =  elev_radius_extra;
		this.debug_save_improved = debug_save_improved;
		this.debug_save_worsened = debug_save_worsened;
		this.elev_sum_weights = null;  // calculate elevations on next getFxDErivsrun
@@ -2142,8 +2147,8 @@ public class VegetationLMA {
			debug_title += "fit"+IntersceneMatchParameters.booleansToString(fits, -2); //+/-, no separators
			debug_title += "skp"+IntersceneMatchParameters.booleansToString(fits_disable, -2); //+/-, no separators
			debug_title += "hf"+hifreq_weight+"tc"+terrain_correction;
			debug_title += "al"+alpha_loss+"all"+alpha_loss_lin+"alo"+alpha_offset+"al0o"+alpha_0offset+"amv"+alpha_min_veg+"amt"+alpha_max_terrain+"app"+alpha_pull_pwr;
			debug_title += "alp"+alpha_lpf+"als"+alpha_scale_avg+(alpha_piece_linear?"alin":"acos");
			debug_title += "al"+alpha_loss+"all"+alpha_loss_lin+"ao"+alpha_offset+"ao"+alpha_0offset+"av"+alpha_min_veg+"at"+alpha_max_terrain+"ap"+alpha_pull_pwr;
			debug_title += "ap"+alpha_lpf+"as"+alpha_scale_avg+(alpha_piece_linear?"ln":"cs");
			debug_title += "ap"+alpha_push+"apn"+alpha_push_neutral+"apc"+alpha_push_center+(alpha_en_holes?("amm"+alpha_mm_hole):"");
			debug_title += "tl"+terr_lpf+"vl"+veget_lpf+"el"+elevation_lpf+"tp"+terr_pull0+"tu"+terr_pull_up;
			debug_title += "ta"+terr_pull_avg+"vp"+veget_pull0+"vpl"+veget_pull_low_alpha+"ep"+elevation_pull0;
@@ -2151,6 +2156,7 @@ public class VegetationLMA {
				debug_title += "ea"+elev_alpha+"ep"+elev_alpha_pwr+"lv"+low_veget;
			}
			debug_title += "sp"+scenes_pull0+"sp0"+ scenes_pull0+"bp"+boost_parallax;
			debug_title += "er"+elevation_radius+"tr"+ terr_elev_radius+"rx"+elev_radius_extra;
			debug_title += from_file?"-file":"-new";
		}
		return debug_title;
@@ -2511,7 +2517,7 @@ public class VegetationLMA {
							}

							double [] scales =  scales_xy[nScene][fnpix];
							double radius = elev_radius[fnpix]; // *1.1;
							double radius = elev_radius[fnpix] * elev_radius_extra; // *1.2;
							double px = x + scales[0] * elevation;      // ELEV-SIGN
							double py = y + scales[1] * elevation;      // ELEV-SIGN
							double px0 = px - radius, py0 = py - radius;
@@ -3369,7 +3375,7 @@ public class VegetationLMA {
		if (use_terr_elev_pix) { // (getIndxTerrElevPix() >=0) && !fits_disable[TVAO_TERR_ELEV_PIX]) {
			setupTerrainElevationPixLMA(
					vector,           // final double [] vector,
					terr_elev_radius, // final double    radius,
					terr_elev_radius * elev_radius_extra, // final double    radius,
					(jt != null),     // final boolean     calc_derivatives,
					debug_level);     // final int debugLevel)
			terr_elev_woi4 = null; // do not try common terrain elevation
@@ -3378,35 +3384,17 @@ public class VegetationLMA {
			if (use_terr_elev) { //(getIndxTerrElev() >=0) && !fits_disable[TVAO_TERR_ELEV]) {
				setupTerrainElevationLMA(
						vector,           // final double [] vector,
						terr_elev_radius, // final double    radius,
						terr_elev_radius, // final double    radius, no * elev_radius_extra (it was not increased)
						(jt != null),     // final boolean     calc_derivatives,
						debug_level);     // final int debugLevel) {
			} else {
				terr_elev_woi4 = null;
			}
		}
		/*
		// FIXME: probably wrong - as soon as per-pixel are different, has to always use them
		if (use_terr_elev) { //(getIndxTerrElev() >=0) && !fits_disable[TVAO_TERR_ELEV]) {
			setupTerrainElevationLMA(
					vector,           // final double [] vector,
					terr_elev_radius, // final double    radius,
					(jt != null),     // final boolean     calc_derivatives,
					debug_level);     // final int debugLevel) {
		} else if (use_terr_elev_pix) { // (getIndxTerrElevPix() >=0) && !fits_disable[TVAO_TERR_ELEV_PIX]) {
			setupTerrainElevationPixLMA(
					vector,           // final double [] vector,
					terr_elev_radius, // final double    radius,
					(jt != null),     // final boolean     calc_derivatives,
					debug_level);     // final int debugLevel) {
		}
*/
	///	final boolean offset_terrain = !Double.isNaN(terr_elev_last) && (terr_elev_last != 0); // if 0, use terrain pixels directly
		
		final int woi_length =      woi.width      * woi.height;
		final int woi_veg_length =  (woi_veg == null) ? 0 : (woi_veg.width  * woi_veg.height);
		final int woi_terr_length = woi_terr.width * woi_terr.height;
//		final int num_pixels =      full.width     * full.height;
		
		final boolean need_derivs =           (jt != null);
		final boolean elevation_parameters =  (num_pars[TVAO_ELEVATION]    > 0); // 0 when woi_veg==null
@@ -3415,7 +3403,6 @@ public class VegetationLMA {
		final boolean terrain_parameters =    (num_pars[TVAO_TERRAIN]      > 0);
		final boolean scenes_parameters =     (num_pars[TVAO_SCENE_OFFSET] > 0);
		final AtomicInteger anum_elev_err = new AtomicInteger(0);
//		final boolean use_hf =    samples_pointers[SAMPLES_Y_HF][1]>0;
		// using 0.5*(1-cos(alpha/2pi) instead of alpha. alpha < 0 -> 0, alpha > 1 -> 1. Depends on other terms for stability 
		double [] fX = new double [weights.length]; // num_pairs + vector.length];
		if (need_derivs) {
@@ -5679,6 +5666,8 @@ public class VegetationLMA {
		imp.setProperty("MAX_ELEV_TERR",             ""+max_elev_terr);
		imp.setProperty("MAX_ELEV_TERR_CHN",         ""+max_elev_terr_chg);
		imp.setProperty("ELEVATION_RADIUS",          ""+elevation_radius);
		imp.setProperty("TERR_ELEV_RADIUS",          ""+terr_elev_radius);
		imp.setProperty("ELEV_RADIUS_EXTRA",         ""+elev_radius_extra);
		
		imp.setProperty("NUM_PARS_TERRAIN",          ""+num_pars[TVAO_TERRAIN]);
		imp.setProperty("NUM_PARS_VEGETATION",       ""+num_pars[TVAO_VEGETATION]);
@@ -5880,6 +5869,10 @@ public class VegetationLMA {
			max_elev_terr =             getProperty(imp_pars,"MAX_ELEV_TERR",         max_elev_terr);
			max_elev_terr_chg =         getProperty(imp_pars,"MAX_ELEV_TERR_CHG",     max_elev_terr_chg);
			elevation_radius =          getProperty(imp_pars,"ELEVATION_RADIUS",      elevation_radius);
			terr_elev_radius =          getProperty(imp_pars,"TERR_ELEV_RADIUS",      terr_elev_radius);
			elev_radius_extra =         getProperty(imp_pars,"ELEV_RADIUS_EXTRA",     elev_radius_extra);
			
			
			terrain_offset =            getProperty(imp_pars,"TERRAIN_OFFSET",        terrain_offset);
			terr_elev_last_success =    getProperty(imp_pars,"TERR_ELEV_LAST_SUCCESS",terr_elev_last_success);
			//				if (imp_pars.getProperty("TERRAIN_OFFSET") != null) terrain_offset = Double.parseDouble((String)   imp_pars.getProperty("TERRAIN_OFFSET"));
@@ -6131,6 +6124,8 @@ public class VegetationLMA {
					getProperty(imp_pars,"MAX_ELEV_TERR",        max_elev_terr),          // final int                max_elev_terr,               // maximal terrain "elevation" to consider
					getProperty(imp_pars,"MAX_ELEV_TERR_CHG",    max_elev_terr_chg),      // final double             max_elev_terr_chg, // 0.5 maximal terrain elevation change from last successfully used
					getProperty(imp_pars,"ELEVATION_RADIUS",     elevation_radius),       // final double             elevation_radius,  // Radius of elevation/vegetation influence.
					getProperty(imp_pars,"TERR_ELEV_RADIUS",     terr_elev_radius),       // final double             terr_elev_radius, //  = 1.5; 
					getProperty(imp_pars,"ELEV_RADIUS_EXTRA",    elev_radius_extra),      // final double             elev_radius_extra, //  =  1.2;      // scale both radii when setupElevationLMA(), setupTerrainElevationLMA(), and setupTerrainElevationPixLMA() 
					valid_scene_pix, // final boolean []         valid_scene_pix, valid_scene_pix_in, // may have nulls or be shorter (do not update "overlaid")         
					getProperty(imp_pars, "HIGHFREQ_WEIGHT",     hifreq_weight),          // final double             hifreq_weight,  // 22.5 0 - do not use high-freq. Relative weight of laplacian components
					getProperty(imp_pars, "TERRAIN_CORRECTION",  terrain_correction),     // final double             terrain_correction,
+5 −0
Original line number Diff line number Diff line
@@ -1504,6 +1504,9 @@ public class VegetationModel {
//		double    terr_difference =   clt_parameters.imp.terr_difference;          // Pull vegetation to be this warmer
//		double    terr_pull_cold =    clt_parameters.imp.terr_pull_cold;           // pull vegetations to warm, terrain to cold
		double    elevation_radius =  clt_parameters.imp.terr_elevation_radius;    // Radius of elevation/vegetation influence 
		double    terr_elev_radius =  clt_parameters.imp.terr_terr_elev_radius;    // Terrain elevation radius 
		double    elev_radius_extra = clt_parameters.imp.terr_elev_radius_extra;   // scale both radii when setupElevationLMA(), setupTerrainElevationLMA(), and setupTerrainElevationPixLMA()  
		
//		double    alpha_initial_contrast = clt_parameters.imp.terr_alpha_contrast; // initial alpha contrast (>=1.0)

		double    alpha_sigma =       clt_parameters.imp.terr_alpha_sigma;         // 8.0;  // Initial alpha: Gaussian blur sigma to find local average for vegetation temperature.
@@ -2133,6 +2136,8 @@ public class VegetationModel {
					max_elev_terr,     // final int                max_elev_terr,               // maximal terrain "elevation" to consider
					max_elev_terr_chg, // final double             max_elev_terr_chg,// 0.5 maximal terrain elevation change from last successfully used
					elevation_radius,  // final double             elevation_radius, // Radius of elevation/vegetation influence.
					terr_elev_radius,  // final double             terr_elev_radius, //  = 1.5; 
					elev_radius_extra, // final double             elev_radius_extra, //  =  1.2;      // scale both radii when setupElevationLMA(), setupTerrainElevationLMA(), and setupTerrainElevationPixLMA() 
					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
					terrain_correction,// final double             terrain_correction,