Commit 883c0212 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

intermediate, before changing alpha pull

parent 1893ac24
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -5802,11 +5802,11 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
		} else if (label.equals("Process Merged")) {
			OrangeTest.processMerged();			
		} else if (label.equals("Vegetation LMA")) {
			VegetationModel.processVegetationLMA(
			VegetationModel.processVegetation(
					CLT_PARAMETERS, //CLTParameters    clt_parameters,
					false); //boolean combine_segments);			
		} else if (label.equals("Combine LMA Segments")) {
			VegetationModel.processVegetationLMA(
			VegetationModel.processVegetation(
					CLT_PARAMETERS, //CLTParameters    clt_parameters,
					true); //boolean combine_segments);			
		}
+66 −4
Original line number Diff line number Diff line
@@ -786,6 +786,12 @@ min_str_neib_fpn 0.35
	public double    terr_elevation_radius =   1.5; // Radius of elevation/vegetation influence 
	public double    terr_alpha_contrast =     1.0; // initial alpha contrast (>=1.0)
	public double    terr_alpha_dflt =         0.5; // now unused
	
    public double    terr_alpha_sigma =        8.0;  // Initial alpha: Gaussian blur sigma to find local average for vegetation temperature. 
	public double    terr_alpha_init_min =     0.7;  // Initial alpha: fraction for transparent 
	public double    terr_alpha_init_max =     0.95; // Initial alpha: fraction for opaque 
	public double    terr_alpha_init_offs =    0.01; // Initial alpha: opaque/transparent offset from 1.0/0.0 
    
	public double    terr_alpha_loss =       100.0;
	public double    terr_alpha_offset =       0.0;
	public double    terr_alpha_lpf =          2.5;  // pull to average of 4 neighbors
@@ -802,6 +808,10 @@ min_str_neib_fpn 0.35
	public double    terr_terr_pull0 =         0.05; // pull terrain to initial (pre-adjustment) values
	public double    terr_veget_pull0 =        0.05; // pull vegetation initial (pre-adjustment) values
	public double    terr_elev_pull0 =         0.1;  // pull elevation to initial (pre-adjustment) values
	public boolean   terr_elev_alpha_en =      false;// Enable loss for low vegetation with high opacity
	public double    terr_elev_alpha =         1.0;  // multiply alpha by under-low elevation for loss
	public double    terr_elev_alpha_pwr =     2.0;  // raise alpha to this power (when alpha > 0)
	public double    terr_low_veget =          2.0;  // (pix) Elevation considered low (lower loss for high alpha)
	public double    terr_scenes_pull0 =       1.0;  // pull average scene offset to zero

	// LMA parameters        
@@ -2083,6 +2093,12 @@ min_str_neib_fpn 0.35
		
		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.");
		
		gd.addNumericField("Initial alpha sigma",  terr_alpha_sigma, 5,7,"", 	"Initial alpha: Gaussian blur sigma to find local average for vegetation temperature..");
		gd.addNumericField("Initial alpha min frac",terr_alpha_init_min,5,7,"", "Initial alpha: fraction for transparent.");
		gd.addNumericField("Initial alpha max frac",terr_alpha_init_max,5,7,"", "Initial alpha: fraction for opaque.");
		gd.addNumericField("Initial alpha offset", terr_alpha_init_offs, 5,7,"","Initial alpha: opaque/transparent offset from 1.0/0.0.");
		
		gd.addNumericField("Alpha loss",           terr_alpha_loss, 5,7,"", 	"Alpha quadratic growing loss for when out of [0,1] range");
		
		gd.addNumericField("Alpha offset",         terr_alpha_offset, 5,7,"",   "Start alpha losses above 0.0 and below 1.0 by this value.");
@@ -2100,6 +2116,12 @@ min_str_neib_fpn 0.35
		gd.addNumericField("Terrain pull",         terr_terr_pull0, 5,7,"",		"Terrain pixels pull to initial (pre-adjustment) values.");
		gd.addNumericField("Vegetation pull",      terr_veget_pull0, 5,7,"",	"Vegetation pixels pull initial (pre-adjustment) values.");
		gd.addNumericField("Elevation pull",       terr_elev_pull0, 5,7,"",  	"Elevation pixels pull to initial (pre-adjustment) values.");
		
		gd.addCheckbox    ("Enable low vegetation",terr_elev_alpha_en,          "Enable loss for low vegetation with high opacity.");
		gd.addNumericField("Low vegetation loss",  terr_elev_alpha, 5,7,"",  	"Multiply alpha by under-low elevation for loss.");
		gd.addNumericField("Low vegetation power", terr_elev_alpha_pwr, 5,7,"", "Raise alpha to this power for low vegetation loss.");
		gd.addNumericField("Low elevation",        terr_low_veget, 5,7,"pix",  	"Elevation considered low (lower loss for high alpha.");
		
		gd.addNumericField("Pull scene offset",    terr_scenes_pull0, 5,7,"",	"Pull average scene offset to zero.");
	
		gd.addMessage     ("LMA parameters");
@@ -2817,6 +2839,12 @@ min_str_neib_fpn 0.35
		terr_elevation_radius =    gd.getNextNumber();// double 
		terr_alpha_contrast =      gd.getNextNumber();// double 
		terr_alpha_dflt =          gd.getNextNumber();// double
		
        terr_alpha_sigma =         gd.getNextNumber();// double
        terr_alpha_init_min =      gd.getNextNumber();// double
        terr_alpha_init_max =      gd.getNextNumber();// double
        terr_alpha_init_offs =     gd.getNextNumber();// double
		
		terr_alpha_loss =          gd.getNextNumber();// double 
		terr_alpha_offset =        gd.getNextNumber();// double 
		terr_alpha_lpf =           gd.getNextNumber();// double 
@@ -2834,6 +2862,10 @@ min_str_neib_fpn 0.35
		terr_terr_pull0 =          gd.getNextNumber();// double 
		terr_veget_pull0 =         gd.getNextNumber();// double
		terr_elev_pull0 =          gd.getNextNumber();// double
		terr_elev_alpha_en =       gd.getNextBoolean();// boolean
		terr_elev_alpha =          gd.getNextNumber();// double
		terr_elev_alpha_pwr =      gd.getNextNumber();// double
		terr_low_veget =           gd.getNextNumber();// double
		terr_scenes_pull0 =        gd.getNextNumber();// double
		terr_boost_parallax =      gd.getNextNumber();// double 
		terr_max_parallax =        gd.getNextNumber();// double 
@@ -3517,6 +3549,12 @@ min_str_neib_fpn 0.35
		properties.setProperty(prefix+"terr_elevation_radius",       terr_elevation_radius+"");   // double
		properties.setProperty(prefix+"terr_alpha_contrast",         terr_alpha_contrast+"");     // double 
		properties.setProperty(prefix+"terr_alpha_dflt",             terr_alpha_dflt+"");         // double
		
		properties.setProperty(prefix+"terr_alpha_sigma",            terr_alpha_sigma+"");        // double
		properties.setProperty(prefix+"terr_alpha_init_min",         terr_alpha_init_min+"");     // double
		properties.setProperty(prefix+"terr_alpha_init_max",         terr_alpha_init_max+"");     // double
		properties.setProperty(prefix+"terr_alpha_init_offs",        terr_alpha_init_offs+"");    // double
		
		properties.setProperty(prefix+"terr_alpha_loss",             terr_alpha_loss+"");         // double 
		properties.setProperty(prefix+"terr_alpha_offset",           terr_alpha_offset+"");       // double 
		properties.setProperty(prefix+"terr_alpha_lpf",              terr_alpha_lpf+"");          // double 
@@ -3532,6 +3570,10 @@ min_str_neib_fpn 0.35
		properties.setProperty(prefix+"terr_terr_pull0",             terr_terr_pull0+"");         // double 
		properties.setProperty(prefix+"terr_veget_pull0",            terr_veget_pull0+"");        // double
		properties.setProperty(prefix+"terr_elev_pull0",             terr_elev_pull0+"");         // double
		properties.setProperty(prefix+"terr_elev_alpha_en",          terr_elev_alpha_en+"");      // boolean
		properties.setProperty(prefix+"terr_elev_alpha",             terr_elev_alpha+"");         // double
		properties.setProperty(prefix+"terr_elev_alpha_pwr",         terr_elev_alpha_pwr+"");     // double
		properties.setProperty(prefix+"terr_low_veget",              terr_low_veget+"");          // double
		properties.setProperty(prefix+"terr_scenes_pull0",           terr_scenes_pull0+"");       // double

		properties.setProperty(prefix+"terr_boost_parallax",         terr_boost_parallax+"");     // double 
@@ -4234,6 +4276,12 @@ min_str_neib_fpn 0.35
		if (properties.getProperty(prefix+"terr_elevation_radius")!=   null) terr_elevation_radius=Double.parseDouble(properties.getProperty(prefix+"terr_elevation_radius"));
		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"));
		
		if (properties.getProperty(prefix+"terr_alpha_sigma")!=        null) terr_alpha_sigma=Double.parseDouble(properties.getProperty(prefix+"terr_alpha_sigma"));
		if (properties.getProperty(prefix+"terr_alpha_init_min")!=     null) terr_alpha_init_min=Double.parseDouble(properties.getProperty(prefix+"terr_alpha_init_min")); 
		if (properties.getProperty(prefix+"terr_alpha_init_max")!=     null) terr_alpha_init_max=Double.parseDouble(properties.getProperty(prefix+"terr_alpha_init_max")); 
		if (properties.getProperty(prefix+"terr_alpha_init_offs")!=    null) terr_alpha_init_offs=Double.parseDouble(properties.getProperty(prefix+"terr_alpha_init_offs")); 
		
		if (properties.getProperty(prefix+"terr_alpha_loss")!=         null) terr_alpha_loss=Double.parseDouble(properties.getProperty(prefix+"terr_alpha_loss"));
		if (properties.getProperty(prefix+"terr_alpha_offset")!=       null) terr_alpha_offset=Double.parseDouble(properties.getProperty(prefix+"terr_alpha_offset"));
		if (properties.getProperty(prefix+"terr_alpha_lpf")!=          null) terr_alpha_lpf=Double.parseDouble(properties.getProperty(prefix+"terr_alpha_lpf"));
@@ -4250,6 +4298,10 @@ min_str_neib_fpn 0.35
		if (properties.getProperty(prefix+"terr_terr_pull0")!=         null) terr_terr_pull0=Double.parseDouble(properties.getProperty(prefix+"terr_terr_pull0"));
		if (properties.getProperty(prefix+"terr_veget_pull0")!=        null) terr_veget_pull0=Double.parseDouble(properties.getProperty(prefix+"terr_veget_pull0"));
		if (properties.getProperty(prefix+"terr_elev_pull0")!=         null) terr_elev_pull0=Double.parseDouble(properties.getProperty(prefix+"terr_elev_pull0"));
		if (properties.getProperty(prefix+"terr_elev_alpha_en")!=      null) terr_elev_alpha_en=Boolean.parseBoolean(properties.getProperty(prefix+"terr_elev_alpha_en"));
		if (properties.getProperty(prefix+"terr_elev_alpha")!=         null) terr_elev_alpha=Double.parseDouble(properties.getProperty(prefix+"terr_elev_alpha"));
		if (properties.getProperty(prefix+"terr_elev_alpha_pwr")!=     null) terr_elev_alpha_pwr=Double.parseDouble(properties.getProperty(prefix+"terr_elev_alpha_pwr"));
		if (properties.getProperty(prefix+"terr_low_veget")!=          null) terr_low_veget=Double.parseDouble(properties.getProperty(prefix+"terr_low_veget"));
		if (properties.getProperty(prefix+"terr_scenes_pull0")!=       null) terr_scenes_pull0=Double.parseDouble(properties.getProperty(prefix+"terr_scenes_pull0"));

		if (properties.getProperty(prefix+"terr_boost_parallax")!=     null) terr_boost_parallax=Double.parseDouble(properties.getProperty(prefix+"terr_boost_parallax"));
@@ -4917,6 +4969,12 @@ min_str_neib_fpn 0.35
		imp.terr_elevation_radius =              this.terr_elevation_radius;
		imp.terr_alpha_contrast =                this.terr_alpha_contrast; 
		imp.terr_alpha_dflt =                    this.terr_alpha_dflt;
		
		imp.terr_alpha_sigma =                   this.terr_alpha_sigma;
		imp.terr_alpha_init_min =                this.terr_alpha_init_min;
		imp.terr_alpha_init_max =                this.terr_alpha_init_max;
		imp.terr_alpha_init_offs =               this.terr_alpha_init_offs;
		
		imp.terr_alpha_loss =                    this.terr_alpha_loss;                           
		imp.terr_alpha_offset =                  this.terr_alpha_offset;                           
		imp.terr_alpha_lpf =                     this.terr_alpha_lpf;                           
@@ -4933,6 +4991,10 @@ min_str_neib_fpn 0.35
		imp.terr_terr_pull0 =                    this.terr_terr_pull0;                           
		imp.terr_veget_pull0 =                   this.terr_veget_pull0; 
		imp.terr_elev_pull0 =                    this.terr_elev_pull0;
		imp.terr_elev_alpha_en =                 this.terr_elev_alpha_en;
		imp.terr_elev_alpha =                    this.terr_elev_alpha;
		imp.terr_elev_alpha_pwr =                this.terr_elev_alpha_pwr;
		imp.terr_low_veget =                     this.terr_low_veget;
		imp.terr_scenes_pull0 =                  this.terr_scenes_pull0;

		imp.terr_boost_parallax =                this.terr_boost_parallax;                           
+192 −26

File changed.

Preview size limit exceeded, changes collapsed.

+31 −36
Original line number Diff line number Diff line
@@ -1277,7 +1277,7 @@ public class VegetationModel {
	
	
	
	public static void processVegetationLMA(
	public static void processVegetation(
			CLTParameters    clt_parameters,
			boolean combine_segments) 
	{
@@ -1296,7 +1296,7 @@ public class VegetationModel {
		VegetationModel vegetationModel = new VegetationModel(
				model_directory, // String dir,
				model_state_file); // String title)
		vegetationModel.testVegetationLMA(
		vegetationModel.processVegetationLMA(
				combine_segments, // boolean combine_segments,
				clt_parameters, // CLTParameters      clt_parameters,
				-1); // int                debugLevel) {
@@ -1369,7 +1369,7 @@ public class VegetationModel {
		}
	}
	
	public void testVegetationLMA(
	public void processVegetationLMA(
			boolean            combine_segments,
			CLTParameters      clt_parameters,
			int                debugLevel) {
@@ -1418,7 +1418,13 @@ 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    alpha_initial_contrast = clt_parameters.imp.terr_alpha_contrast; // initial alpha contrast (>=1.0)
//		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.
		double    alpha_init_min=     clt_parameters.imp.terr_alpha_init_min;      // 0.7;  // Initial alpha: fraction for transparent 
		double    alpha_init_max=     clt_parameters.imp.terr_alpha_init_max;      // 0.9;  // Initial alpha: fraction for opaque 
        double    alpha_init_offs=    clt_parameters.imp.terr_alpha_init_offs;     // 0.01; // Initial alpha: opaque/transparent offset from 1.0/0.0 
        
		double    default_alpha =     clt_parameters.imp.terr_alpha_dflt;          //  0.5; //  0.8;
		double    alpha_loss =        clt_parameters.imp.terr_alpha_loss;          //100.0; // 10.0; /// 100.0; // 10.0;  // 10000.0; // 1000.0; // 100.; // 10.0;         // quadratic loss when alpha reaches -1.0 or 2.0 
		double    alpha_offset =      clt_parameters.imp.terr_alpha_offset;        //  0.0; // 0.02; // 0.03;    // if >0,  start losses above 0.0 and below 1.0;
@@ -1436,6 +1442,10 @@ public class VegetationModel {
		double    terr_pull0 =        clt_parameters.imp.terr_terr_pull0;          // 0.05; //0.03; ////// 0.05; ///// 0.1; //// 0.01; /// 0.2; /// 0.1;    //pull terrain to zero (makes sense with UM
		double    veget_pull0 =       clt_parameters.imp.terr_veget_pull0;         // 0.05; //0.1; // 0.03; ////// 0.05; ///// 0.1; //// 0.01; /// 0.1;    // pull vegetation to zero (makes sense with UM
		double    elev_pull0 =        clt_parameters.imp.terr_elev_pull0; 
	    boolean   elev_alpha_en=      clt_parameters.imp.terr_elev_alpha_en; // false;// Enable loss for low vegetation with high opacity
	    double    elev_alpha =        clt_parameters.imp.terr_elev_alpha;    // 1.0;  // multiply alpha by under-low elevation for loss
	    double    elev_alpha_pwr =    clt_parameters.imp.terr_elev_alpha_pwr;    // 1.0;  // multiply alpha by under-low elevation for loss
	    double    low_veget =         clt_parameters.imp.terr_low_veget;     // 2.0;  // (pix) Elevation considered low (lower loss for high alpha)
		double    scenes_pull0 =      clt_parameters.imp.terr_scenes_pull0;        // 1.0
		
		// LMA parameters        
@@ -1488,29 +1498,11 @@ public class VegetationModel {
		double    transparency_frac =     clt_parameters.imp.terr_recalc_frac ;         // 1.0;  // increase weight for far pixels (double if scale differece == this)  
		double    transparency_dist =     clt_parameters.imp.terr_recalc_dist ;         // 0.05; // weight of opaque tiles  
		boolean   recalc_average =        clt_parameters.imp.terr_recalc_average ;      //false; // apply transparency to average mismatch
		
//clt_parameters.imp.; // 		
		
		
		boolean restore_mode =   false;
		boolean save_par_files = true; // false;
//		boolean diff_mode = true;
		
//		String segments_dir = "/media/elphel/SSD3-4GB/lwir16-proc/berdich3/debug/vegetation/segments_new/";
		String segments_dir = getSegmentsDir(segments_sub);
		
//		boolean   next_run =      false;
		boolean   read_pars =     false; // true; /// false; /// true; //   false; // true;
		
		
		

		

		// combine  parameters
		
		
		
		// debug feature to read to continue - needs to be cleaned up/replaced
		String  parameters_path = "/media/elphel/SSD3-4GB/lwir16-proc/berdich3/debug/vegetation/essential/parameters_vector_data_x143-y317-w35-h35-al100.0-alo0.0-alp10.0-alin-tl0.2-vl0.01-tp0.01-vp0.01-bp5.0-um1.0_0.8.tiff";

@@ -1552,7 +1544,6 @@ public class VegetationModel {
						titles_laplacian,                     // String []    titles, // all slices*frames titles or just slice titles or null
						new String[] {"source","laplacian"},                     // String []    frame_titles, // frame titles or null
						true);                            // boolean      show)

			}
		}

@@ -1933,21 +1924,21 @@ public class VegetationModel {
			

		} // if ((elevations == null) || (scale_dirs == null)){
		
		
		// directions should not be averaged over scenes as the flight direction may change
		
//		if (debugLevel < 1000) {
//			return; // 
//		}
		
		
//		initial_transparent = initial_split;
//		initial_opaque =      1.0 - initial_split;
		
		/*
		VegetationLMA vegetationLMA = new VegetationLMA (
				this,
				alpha_initial_contrast); // double alpha_initial_contrast)
				alpha_initial_contrast, // double alpha_initial_contrast)
				debugLevel); // int debugLevel) 
		*/
		VegetationLMA vegetationLMA = new VegetationLMA (
				this,
				alpha_init_offs,  // 0.01; // double    alpha_offs,
				alpha_init_min,   // 0.7;  // double    alpha_min,
				alpha_init_max,   // 0.9;  // double    alpha_max,
				alpha_sigma, // 8.0;  // double    alpha_sigma,
				debugLevel); // int debugLevel) 
		
		
		if (debugLevel > -2) {
			double [][] dbg_img = {
					vegetationLMA.tvao[VegetationLMA.TVAO_TERRAIN],
@@ -2030,6 +2021,10 @@ public class VegetationModel {
					terr_pull0,     // final double             terr_pull0,     // pull terrain to initial (pre-adjustment) values
					veget_pull0,    // final double             veget_pull0,    // pull vegetation to initial (pre-adjustment) values
					elev_pull0,     // final double             elev_pull0,     // pull elevation to initial (pre-adjustment) values
					elev_alpha_en,  // final boolean            elev_alpha_en,  // false; // Enable loss for low vegetation with high opacity
					elev_alpha,     // final double             elev_alpha,     // 1.0;   // multiply alpha by under-low elevation for loss
					elev_alpha_pwr, // final double             elev_alpha_pwr, // 2.0;  // raise alpha to this power (when alpha > 0)
					low_veget,      // final double             low_veget,      // 2.0;   // (pix) Elevation considered low (lower loss for high alpha)
					scenes_pull0,   // final double             scenes_pull0,
					boost_parallax,// final double             boost_parallax,     // increase weight of scene with maximal parallax relative to the reference scene
					max_parallax,   //final double             max_parallax,  // do not consider maximal parallax above this (consider it a glitch)