Commit 7c77ddba authored by Andrey Filippov's avatar Andrey Filippov

modifying parameters input

parent 214f7e87
......@@ -729,6 +729,7 @@ min_str_neib_fpn 0.35
public String terr_model_path = "/media/elphel/SSD3-4GB/lwir16-proc/berdich3/models/models_1697875868-1697879449-b/1697877487_245877/v35";
public String terr_model_state = "1697877487_245877-TERR-VEG-STATE";
public String terr_segments_dir = "sections";
public String terr_segments_suffix = "-new";
public String terr_par_dir = ""; // directory path to intermediate parameters
public String terr_par_file = ""; // file name of the intermediate parameters
public boolean terr_par_restore = false; // restore parameters from file
......@@ -815,6 +816,7 @@ min_str_neib_fpn 0.35
public double terr_elev_lpf = 50.0; // pull elevation to average of 4 neighbors
public double terr_terr_pull0 = 0.1; // pull terrain to initial (pre-adjustment) values
public double terr_terr_pull_up= 0.25; // pull terrain to initial when it is colder
public double terr_terr_pull_avg= 0.1; // Pull terrain to the initial offset by the average offset of all terrain pixels
public double terr_veget_pull0 = 5.0; // pull vegetation initial (pre-adjustment) values
public double terr_elev_pull0 = 1.0; // pull elevation to initial (pre-adjustment) values
public boolean terr_elev_alpha_en = false;// Enable loss for low vegetation with high opacity
......@@ -2054,6 +2056,7 @@ min_str_neib_fpn 0.35
gd.addStringField ("Model path", terr_model_path, 120, "Model directory path with version.");
gd.addStringField ("Model state file", terr_model_state, 50, "Model vegetation source data (w/o extension).");
gd.addStringField ("Segments subdir", terr_segments_dir, 50,"Model vegetation source data (w/o extension).");
gd.addStringField ("Segments suffix", terr_segments_suffix, 50,"suffix to select from multiple versions (w/o \".par-tiff\".");
gd.addStringField ("Restore directory", terr_par_dir, 120, "Directory to resore initial parameters from.");
gd.addStringField ("Restore file", terr_par_file, 120, "Filename to resore initial parameters from.");
......@@ -2138,7 +2141,8 @@ 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.");
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 (<0 - sqme as above).");
gd.addNumericField("Terrain pull to average",terr_terr_pull_avg, 5,7,"","Pull terrain to the initial offset by the average offset of all terrain pixels.");
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.");
......@@ -2824,7 +2828,7 @@ min_str_neib_fpn 0.35
terr_model_path = gd.getNextString();
terr_model_state = gd.getNextString();
terr_segments_dir = gd.getNextString();
terr_segments_suffix = gd.getNextString();
terr_par_dir = gd.getNextString();
terr_par_file = gd.getNextString();
terr_par_restore = gd.getNextBoolean(); // boolean
......@@ -2898,6 +2902,7 @@ min_str_neib_fpn 0.35
terr_elev_lpf = gd.getNextNumber();// double
terr_terr_pull0 = gd.getNextNumber();// double
terr_terr_pull_up = gd.getNextNumber();// double
terr_terr_pull_avg = gd.getNextNumber();// double
terr_veget_pull0 = gd.getNextNumber();// double
terr_elev_pull0 = gd.getNextNumber();// double
terr_elev_alpha_en = gd.getNextBoolean();// boolean
......@@ -3541,6 +3546,7 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"terr_model_path", terr_model_path+""); // String
properties.setProperty(prefix+"terr_model_state", terr_model_state+""); // String
properties.setProperty(prefix+"terr_segments_dir", terr_segments_dir+""); // String
properties.setProperty(prefix+"terr_segments_suffix", terr_segments_suffix+""); // String
properties.setProperty(prefix+"terr_par_dir", terr_par_dir+""); // String
properties.setProperty(prefix+"terr_par_file", terr_par_file+""); // String
......@@ -3616,6 +3622,7 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"terr_elev_lpf", terr_elev_lpf+""); // double
properties.setProperty(prefix+"terr_terr_pull0", terr_terr_pull0+""); // double
properties.setProperty(prefix+"terr_terr_pull_up", terr_terr_pull_up+""); // double
properties.setProperty(prefix+"terr_terr_pull_avg", terr_terr_pull_avg+""); // 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
......@@ -4282,6 +4289,7 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"terr_model_path")!= null) terr_model_path=(String) properties.getProperty(prefix+"terr_model_path");
if (properties.getProperty(prefix+"terr_model_state")!= null) terr_model_state=(String) properties.getProperty(prefix+"terr_model_state");
if (properties.getProperty(prefix+"terr_segments_dir")!= null) terr_segments_dir=(String) properties.getProperty(prefix+"terr_segments_dir");
if (properties.getProperty(prefix+"terr_segments_suffix")!= null) terr_segments_suffix=(String) properties.getProperty(prefix+"terr_segments_suffix");
if (properties.getProperty(prefix+"terr_par_dir")!= null) terr_par_dir=(String) properties.getProperty(prefix+"terr_par_dir");
if (properties.getProperty(prefix+"terr_par_file")!= null) terr_par_file=(String) properties.getProperty(prefix+"terr_par_file");
......@@ -4355,6 +4363,7 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"terr_elev_lpf")!= null) terr_elev_lpf=Double.parseDouble(properties.getProperty(prefix+"terr_elev_lpf"));
if (properties.getProperty(prefix+"terr_terr_pull0")!= null) terr_terr_pull0=Double.parseDouble(properties.getProperty(prefix+"terr_terr_pull0"));
if (properties.getProperty(prefix+"terr_terr_pull_up")!= null) terr_terr_pull_up=Double.parseDouble(properties.getProperty(prefix+"terr_terr_pull_up"));
if (properties.getProperty(prefix+"terr_terr_pull_avg")!= null) terr_terr_pull_avg=Double.parseDouble(properties.getProperty(prefix+"terr_terr_pull_avg"));
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"));
......@@ -4993,6 +5002,7 @@ min_str_neib_fpn 0.35
imp.terr_model_path = this. terr_model_path;
imp.terr_model_state = this. terr_model_state;
imp.terr_segments_dir = this. terr_segments_dir;
imp.terr_segments_suffix = this.terr_segments_suffix;
imp.terr_par_dir = this. terr_par_dir;
imp.terr_par_file = this. terr_par_file;
......@@ -5064,6 +5074,7 @@ min_str_neib_fpn 0.35
imp.terr_elev_lpf = this.terr_elev_lpf;
imp.terr_terr_pull0 = this.terr_terr_pull0;
imp.terr_terr_pull_up = this.terr_terr_pull_up;
imp.terr_terr_pull_avg = this.terr_terr_pull_avg;
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;
......
......@@ -95,6 +95,8 @@ public class VegetationModel {
public double [][] tva;
int step_restore;
public boolean tile_woi;
public final SyncCommand SYNC_COMMAND;
public boolean isFailed() {
......@@ -1434,7 +1436,7 @@ public class VegetationModel {
boolean run_combine = combine_segments; // true; // if true, run combining instead of LMA
String segments_sub = clt_parameters.imp.terr_segments_dir; //
String segments_suffix = clt_parameters.imp.terr_segments_suffix;
String parameters_dir = clt_parameters.imp.terr_par_dir; //
String parameters_file = clt_parameters.imp.terr_par_file; //
boolean par_restore = clt_parameters.imp.terr_par_restore; // true;
......@@ -1454,7 +1456,8 @@ public class VegetationModel {
boolean tile_woi = clt_parameters.imp.terr_tile_woi; // scan woi_enclosing, false - run a single woi_last
// boolean
tile_woi = clt_parameters.imp.terr_tile_woi; // scan woi_enclosing, false - run a single woi_last
Rectangle woi_enclosing = clt_parameters.imp.terr_woi_enclos; // new Rectangle(0, 0, 200, 160); // will be tiled, using width/height from woi_step;
Rectangle woi_step = clt_parameters.imp.terr_woi_step; // new Rectangle(10,10,20,20);
Rectangle woi_last = clt_parameters.imp.terr_woi_last; // new Rectangle(160,310,20,20); // 170
......@@ -1500,7 +1503,8 @@ public class VegetationModel {
double veget_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)
double elevation_lpf = clt_parameters.imp.terr_elev_lpf;
double terr_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
double terr_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.
double terr_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.
double terr_pull_avg = clt_parameters.imp.terr_terr_pull_avg; // 0.1; // Pull terrain to the initial offset by the average offset of all terrain pixels
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
......@@ -2027,7 +2031,8 @@ public class VegetationModel {
if (run_combine) {
VegetationSegment [] segments = vegetationLMA.readAllSegments(
segments_dir); // String dir_path)
segments_dir, // String dir_path)
segments_suffix); // String suffix);
vegetationLMA.combineSegments(
segments,
border_width, // int width);
......@@ -2043,6 +2048,7 @@ public class VegetationModel {
}
Rectangle woi = woi_last_done;
while (true) {
step_restore= par_restore? clt_parameters.imp.terr_step_restore : 0;
woi = nextTileWoi(
woi_enclosing, // Rectangle enclosing,
woi_step, // Rectangle step,
......@@ -2060,15 +2066,7 @@ public class VegetationModel {
} else {
System.out.println("===== Will process a single WOI ("+woi.x+", "+woi.y+", "+woi.width+", "+woi.height+").");
}
/*
boolean [][] fits_disables = new boolean [num_iters.length][];
for (int i = 0; i <fits_disables.length; i++) {
fits_disables[i] = fit_disable.clone();
}
if (!par_restore && (fits_disables.length > 1)) {
fits_disables[0][VegetationLMA.TVAO_ELEVATION] = true; // disable elevation adjustment for the first run
}
*/
int num_samples = vegetationLMA.prepareLMA(
false, // final boolean keep_parameters,
woi, // final Rectangle woi,
......@@ -2094,7 +2092,7 @@ public class VegetationModel {
alpha_scale_avg, // final double alpha_scale_avg, // = 1.2; // scale average alpha (around 0.5) when pulling to it
alpha_push, // final double alpha_push, // 5.0; // push from alpha==0.5
alpha_push_neutral, // double alpha_push_neutral = 0.8; // alpha point from which push (closer to opaque)
alpha_push_center,// final double alpha_push_center,// 1.5; // weight of center alpha pixel relative to each of the 4 ortho ones
alpha_push_center, // final double alpha_push_center,// 1.5; // weight of center alpha pixel relative to each of the 4 ortho ones
alpha_en_holes, // final boolean alpha_en_holes, // Search for small semi-transparent holes, disable diffusion of local alpha minimums
alpha_mm_hole, // double 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
terr_lpf, // final double terr_lpf, // pull terrain to average of 4 neighbors (very small)
......@@ -2102,6 +2100,7 @@ public class VegetationModel {
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.
terr_pull_avg, // final double terr_pull_avg, // pull terrain to the initial offset by the average offset of all terrain pixels
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
......@@ -2136,7 +2135,7 @@ public class VegetationModel {
continue;
}
}
int num_iter = num_iters[step_restore];
int num_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())) {
......@@ -2147,10 +2146,11 @@ 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");
String dbg_title= (debugLevel > -2) ?("transparency_"+step_restore): null;
String dbg_title= (!tile_woi && (debugLevel > -2)) ?("transparency_"+step_restore): null;
vegetationLMA.applyTransparency(
null, // final double [] vector,
transparency_opaque, // final double transparency_opaque,
......@@ -2234,7 +2234,7 @@ public class VegetationModel {
vegetationLMA.fits_disable[VegetationLMA.TVAO_ELEVATION] =thisOrLast(step_restore,fits_disable)[VegetationLMA.TVAO_ELEVATION];
if (thisOrLast(step_restore,recalc_weights)) {
System.out.println ("---- Recalculating weights from transparency");
String dbg_title= (debugLevel > -2) ? ("transparency_"+step_restore) : null;
String dbg_title= (!tile_woi && (debugLevel > -2)) ? ("transparency_"+step_restore) : null;
vegetationLMA.applyTransparency(
null, // final double [] vector,
transparency_opaque, // final double transparency_opaque,
......
......@@ -7,13 +7,20 @@ public class VegetationSegment {
public Rectangle woi;
public double [] scene_offsets;
public double [][] tva;
public double terrain_offset;
public String path;
public VegetationSegment(
String path,
Rectangle woi_veg,
Rectangle woi,
double terrain_offset,
double [] scene_offsets, // has NaNs
double [][] tva) {
this.path = path;
this.woi = woi;
this.woi_veg = woi_veg;
this.scene_offsets = scene_offsets;
this.tva = tva;
this.terrain_offset = terrain_offset;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment