publicintterr_max_elevation=22;// maximal offset to consider when looking for vegetation influence
...
...
@@ -793,6 +797,7 @@ min_str_neib_fpn 0.35
publicdoubleterr_alpha_init_offs=0.01;// Initial alpha: opaque/transparent offset from 1.0/0.0
publicdoubleterr_alpha_loss=100.0;
publicdoubleterr_alpha_loss_lin=0.0;
publicdoubleterr_alpha_offset=0.1;
publicdoubleterr_alpha_min_veg=-1;// old version 0.5; // Minimal vegetation alpha. If (alpha-alpha_offset)/(1-2*alpha_offset) < alpha_min_veg, pull down to lpha_offset
...
...
@@ -806,11 +811,12 @@ min_str_neib_fpn 0.35
publicbooleanterr_en_holes=true;// enable small holes // maybe second pass after good fit with vegetation and search for correct offset?
publicdoubleterr_alpha_mm_hole=0.1;// NaN to disable. Local "almost minimum" (lower than this fraction between min and max neighbor) is not subject to alpha_lpf
publicdoubleterr_terr_lpf=0.1;// pull terrain to average of 4 neighbors
publicdoubleterr_veget_lpf=0.2;// pull vegetation to average of 4 neighbors
publicdoubleterr_elev_lpf=0.1;// pull elevation to average of 4 neighbors
publicdoubleterr_terr_pull0=0.05;// pull terrain to initial (pre-adjustment) values
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 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 loss linear",terr_alpha_loss_lin,5,7,"","Alpha linear growing loss for when out of [0,1] range and below minimal vegetation alpha.");
gd.addNumericField("Alpha offset",terr_alpha_offset,5,7,"","Start alpha losses above 0.0 and below 1.0 by this value.");
gd.addNumericField("Minimal vegetation alpha",terr_alpha_min_veg,5,7,"","Minimal vegetation alpha. If (alpha-alpha_offset)/(1-2*alpha_offset) < alpha_min_veg, pull down to lpha_offset.");
...
...
@@ -2119,6 +2138,7 @@ min_str_neib_fpn 0.35
gd.addNumericField("Vegetation diffusion",terr_veget_lpf,5,7,"","LPF for vegetation pixels (diffusion to 4 neighbors).");
gd.addNumericField("Elevation diffusion",terr_elev_lpf,5,7,"","LPF for elevation pixels (diffusion to 4 neighbors).");
gd.addNumericField("Terrain pull",terr_terr_pull0,5,7,"","Terrain pixels pull to initial (pre-adjustment) values.");
gd.addNumericField("Terrain pull up",terr_terr_pull_up,5,7,"","Terrain pixels pull to initial (pre-adjustment) values when it is colder than initial.");
double[][]params_arr=restoreParametersFile(//FIXME: Not finished for real import !
path,// String path,
false,// 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
}
privatestaticdouble[][][]getScalesXY(
finaldouble[][][]scales_mag_dir){
...
...
@@ -521,7 +501,8 @@ public class VegetationLMA {
finalbooleanfit_elevations,
finalboolean[]fits_disable,
finaldoublereg_weights,// fraction of the total weight used for regularization
finaldoublealpha_loss,// quadratic loss when alpha reaches -1.0 or 2.0
finaldoublealpha_loss,// alpha quadratic growing loss for when out of [0,1] range
finaldoublealpha_loss_lin,// alpha linear growing loss for when out of [0,1] range and below minimal vegetation alpha
finaldoublealpha_offset,// quadratic loss when alpha reaches -1.0 or 2.0
finaldoublealpha_min_veg,// 0.5; // if (alpha-alpha_offset)/(1-2*alpha_offset) < alpha_min_veg, pull down to lpha_offset
finaldoublealpha_lpf,// pull vegetation alpha to average of 4 neighbors
...
...
@@ -536,6 +517,7 @@ public class VegetationLMA {
finaldoubleveget_lpf,// pull vegetation to average of 4 neighbors (very small - maybe not needed)
finaldoubleelevation_lpf,
finaldoubleterr_pull0,// pull terrain to initial (pre-adjustment) values
finaldoubleterr_pull_up,// Terrain pixels pull to initial (pre-adjustment) values when it is colder than initial.
finaldoubleveget_pull0,// pull vegetation to initial (pre-adjustment) values
finaldoubleelev_pull0,// pull elevation to initial (pre-adjustment) values
finalbooleanelev_alpha_en,// false; // Enable loss for low vegetation with high opacity
...
...
@@ -548,7 +530,9 @@ public class VegetationLMA {
finaldoubleum_sigma,// just use in debug image names
finaldoubleum_weight,
Stringparameters_read_path,
finalintdebugLevel){
finalintdebugLevel,
finalbooleandebug_save_improved,// Save debug image after successful LMA step.");
finalbooleandebug_save_worsened){// Save debug image after unsuccessful LMA step.");
this.woi=woi;
this.hifreq_weight=hifreq_weight;// 22.5 0 - do not use high-freq. Relative weight of laplacian components
this.terrain_correction=terrain_correction;
...
...
@@ -561,8 +545,9 @@ public class VegetationLMA {
this.fits_disable=fits_disable.clone();
this.reg_weights=reg_weights;// fraction of the total weight used for regularization
doublealpha_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
doublealpha_loss=clt_parameters.imp.terr_alpha_loss;//100.0; // alpha quadratic growing loss for when out of [0,1] range
doublealpha_loss_lin=clt_parameters.imp.terr_alpha_loss_lin;// alpha linear growing loss for when out of [0,1] range and below minimal vegetation alpha
doublealpha_offset=clt_parameters.imp.terr_alpha_offset;// 0.0; // 0.02; // 0.03; // if >0, start losses above 0.0 and below 1.0;
doublealpha_min_veg=clt_parameters.imp.terr_alpha_min_veg;// 0.5 // Minimal vegetation alpha. If (alpha-alpha_offset)/(1-2*alpha_offset) < alpha_min_veg, pull down to lpha_offset
...
...
@@ -1441,7 +1499,8 @@ public class VegetationModel {
doubleterr_lpf=clt_parameters.imp.terr_terr_lpf;// 0.1; // 0.15; /// 0.2; /// 0.1; // pull terrain to average of 4 neighbors (very small)
doubleveget_lpf=clt_parameters.imp.terr_veget_lpf;// 0.2; //0.15; /// 0.2; //// 0.01; /// 0.1; // pull vegetation to average of 4 neighbors (very small - maybe not needed)
doubleterr_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
doubleterr_pull0=clt_parameters.imp.terr_terr_pull0;// 0.1; //0.03; ////// 0.05; ///// 0.1; //// 0.01; /// 0.2; /// 0.1; //pull terrain to zero (makes sense with UM
doubleterr_pull_up=clt_parameters.imp.terr_terr_pull_up;// 0.2; //Terrain pixels pull to initial (pre-adjustment) values when it is colder than initial.
doubleveget_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
alpha_scale_avg,// final double alpha_scale_avg, // = 1.2; // scale average alpha (around 0.5) when pulling to it
...
...
@@ -2022,6 +2101,7 @@ public class VegetationModel {
veget_lpf,// final double veget_lpf, // pull vegetation to average of 4 neighbors (very small - maybe not needed)
elevation_lpf,// final double elevation_lpf,
terr_pull0,// final double terr_pull0, // pull terrain to initial (pre-adjustment) values
terr_pull_up,// final double terr_pull_up, // Terrain pixels pull to initial (pre-adjustment) values when it is colder than initial.
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
...
...
@@ -2034,7 +2114,10 @@ public class VegetationModel {
um_sigma,// final double um_sigma, // just use in debug image names
(um_en?um_weight:0.0),// final double um_weight,
par_path,// final String parameters_read_path,
debugLevel);// final int debugLevel);
debugLevel,// final int debugLevel);
debug_save_improved,// final boolean debug_save_improved, // Save debug image after successful LMA step.");
debug_save_worsened);// final boolean debug_save_worsened) // Save debug image after unsuccessful LMA step.");
if(num_samples<=0){
System.out.println("Insufficient data in this segment, skipping it.");
continue;
...
...
@@ -2053,8 +2136,8 @@ public class VegetationModel {
continue;
}
}
if(par_restore){
intnum_iter=num_iters[step_restore];
if(par_restore){// always use last number of iterations - not anymore
par_path=parameters_dir;
if(!par_path.endsWith(Prefs.getFileSeparator())){
par_path+=Prefs.getFileSeparator();
...
...
@@ -2065,15 +2148,23 @@ public class VegetationModel {
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
if(recalc_weights){
if(thisOrLast(step_restore,recalc_weights)){
System.out.println("---- Recalculating weights from transparency after loading parameters");