Commit b7758748 authored by Andrey Filippov's avatar Andrey Filippov

Intermediate state, mostly working

parent 47963228
......@@ -764,7 +764,8 @@ min_str_neib_fpn 0.35
public boolean terr_fit_elevations = false; // adjust elevation pixels (not yet implemented)
public boolean terr_fit_terr_elev = false; // adjust terrain elevation (common, maybe add per-pixel later)
public boolean terr_fit_terr_elev_pix = false; // adjust terrain elevation (common, maybe add per-pixel later)
public boolean [][] terr_fits_disable = {{false},{false},{false},{true,false,true},{false},{false},{false}};
public boolean [][] terr_fits_disable = {{false},{false},{false},{true,false,true},{false},{false},{false}};
public boolean [][] terr_only_fits_disable = {{false},{false},{false},{true,false,true},{false},{false},{false}};
public double terr_max_warp = 1.8;
public int terr_max_elevation = 22; // maximal offset to consider when looking for vegetation influence
......@@ -891,6 +892,7 @@ min_str_neib_fpn 0.35
// combine parameters
public boolean terr_crop = true; // Crop output image to the bounds of all segments
public boolean terr_keep_partial = true; // Keep partial images (false - only accumulated)
public int terr_border_width = 6;
public boolean terr_render_open = true; // render open areas (no vegetation offset)
public boolean terr_render_no_alpha = true; // render where no opacity is available
......@@ -2142,6 +2144,12 @@ min_str_neib_fpn 0.35
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 +/-." );
}
for (int i = 0; i < terr_only_fits_disable.length; i++) {
gd.addStringField ("Skip "+VegetationLMA.TVAO_NAMES[i]+" in terrain-only", booleansToString(terr_only_fits_disable[i],2), 40,
"Skip adjustment of "+VegetationLMA.TVAO_NAMES[i]+" in terrain-only mode. 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("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.");
......@@ -2259,6 +2267,7 @@ min_str_neib_fpn 0.35
gd.addMessage ("Combining LMA results segments");
gd.addCheckbox ("Crop result image", terr_crop, "Crop output image to the bounds of all segments.");
gd.addCheckbox ("Keep partial", terr_keep_partial, "Keep partial (per source window) images.");
gd.addNumericField("Overlap width", terr_border_width, 0,3,"","Width of the inter-tile oiverlap border.");
gd.addCheckbox ("Render open", terr_render_open, "");
gd.addCheckbox ("Render no alpha", terr_render_no_alpha, "");
......@@ -2943,6 +2952,9 @@ min_str_neib_fpn 0.35
for (int i = 0; i < terr_fits_disable.length; i++) {
terr_fits_disable[i] = StringToBooleans(gd.getNextString());// booleans
}
for (int i = 0; i < terr_only_fits_disable.length; i++) {
terr_only_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
......@@ -3045,6 +3057,7 @@ min_str_neib_fpn 0.35
terr_recalc_average = gd.getNextBoolean();// boolean
terr_crop = gd.getNextBoolean();// boolean
terr_keep_partial = gd.getNextBoolean();// boolean
terr_border_width = (int) gd.getNextNumber(); // int
terr_render_open = gd.getNextBoolean();// boolean
terr_render_no_alpha = gd.getNextBoolean();// boolean
......@@ -3703,6 +3716,13 @@ min_str_neib_fpn 0.35
String prop_name = prefix+"terr_fits_disable_"+VegetationLMA.TVAO_NAMES[i];
properties.setProperty(prop_name, booleansToString(terr_fits_disable[i],2)); // boolean
}
for (int i = 0; i < terr_only_fits_disable.length; i++) {
String prop_name = prefix+"terr_only_fits_disable_"+VegetationLMA.TVAO_NAMES[i];
properties.setProperty(prop_name, booleansToString(terr_only_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
......@@ -3807,6 +3827,7 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"terr_recalc_average", terr_recalc_average+""); // boolean
properties.setProperty(prefix+"terr_crop", terr_crop+""); // boolean
properties.setProperty(prefix+"terr_keep_partial", terr_keep_partial+""); // boolean
properties.setProperty(prefix+"terr_border_width", terr_border_width+""); // int
properties.setProperty(prefix+"terr_render_open", terr_render_open+""); // boolean
properties.setProperty(prefix+"terr_render_no_alpha", terr_render_no_alpha+""); // boolean
......@@ -4483,6 +4504,12 @@ min_str_neib_fpn 0.35
String prop_name = prefix+"terr_fits_disable_"+VegetationLMA.TVAO_NAMES[i];
if (properties.getProperty(prop_name)!=null) terr_fits_disable[i]= StringToBooleans(properties.getProperty(prop_name));// booleans
}
for (int i = 0; i < terr_only_fits_disable.length; i++) {
String prop_name = prefix+"terr_only_fits_disable_"+VegetationLMA.TVAO_NAMES[i];
if (properties.getProperty(prop_name)!=null) terr_only_fits_disable[i]= StringToBooleans(properties.getProperty(prop_name));// booleans
}
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"));
......@@ -4588,6 +4615,7 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"terr_recalc_average")!= null) terr_recalc_average=Boolean.parseBoolean(properties.getProperty(prefix+"terr_recalc_average"));
if (properties.getProperty(prefix+"terr_crop")!= null) terr_crop=Boolean.parseBoolean(properties.getProperty(prefix+"terr_crop"));
if (properties.getProperty(prefix+"terr_keep_partial")!= null) terr_keep_partial=Boolean.parseBoolean(properties.getProperty(prefix+"terr_keep_partial"));
if (properties.getProperty(prefix+"terr_border_width")!= null) terr_border_width=Integer.parseInt(properties.getProperty(prefix+"terr_border_width"));
if (properties.getProperty(prefix+"terr_render_open")!= null) terr_render_open=Boolean.parseBoolean(properties.getProperty(prefix+"terr_render_open"));
if (properties.getProperty(prefix+"terr_render_no_alpha")!= null) terr_render_no_alpha=Boolean.parseBoolean(properties.getProperty(prefix+"terr_render_no_alpha"));
......@@ -5228,7 +5256,10 @@ min_str_neib_fpn 0.35
imp.terr_fit_terr_elev_pix = this.terr_fit_terr_elev_pix;
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_fits_disable[i] = this.terr_fits_disable[i].clone();
}
for (int i = 0; i < terr_only_fits_disable.length; i++) {
imp.terr_only_fits_disable[i] = this.terr_only_fits_disable[i].clone();
}
imp.terr_max_warp = this.terr_max_warp;
imp.terr_max_elevation = this.terr_max_elevation;
......@@ -5329,6 +5360,7 @@ min_str_neib_fpn 0.35
imp.terr_recalc_average = this.terr_recalc_average;
imp.terr_crop = this.terr_crop;
imp.terr_keep_partial = this.terr_keep_partial;
imp.terr_border_width = this.terr_border_width;
imp.terr_render_open = this.terr_render_open;
imp.terr_render_no_alpha = this.terr_render_no_alpha;
......
......@@ -6514,7 +6514,7 @@ public class VegetationLMA {
for (int n = 0; n < par_files.length; n++) {
if (debugLevel > -3) {
System.out.println("====== readAllSegments(): n="+n+ ", "+par_files[n].getPath());
System.out.println("====== readAllSegments(): n="+n+ "(of "+(par_files.length)+"), "+par_files[n].getPath());
}
if (n==dbg_n) {
System.out.println("readAllSegments(): n="+n);
......
......@@ -1579,12 +1579,16 @@ public class VegetationModel {
boolean fit_terr_elev = clt_parameters.imp.terr_fit_terr_elev; // false; // adjust terrain elevation (common, maybe add per-pixel later)
boolean fit_terr_elev_pix = clt_parameters.imp.terr_fit_terr_elev_pix; // 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][];
for (int i = 0; i < fits_disable.length; i++) {
fits_disable[i] = clt_parameters.imp.terr_fits_disable[i].clone();
}
boolean [][] terr_only_fits_disable = new boolean[clt_parameters.imp.terr_only_fits_disable.length][];
for (int i = 0; i < terr_only_fits_disable.length; i++) {
terr_only_fits_disable[i] = clt_parameters.imp.terr_only_fits_disable[i].clone();
}
double reg_weights = clt_parameters.imp.terr_reg_weights; // 0.25; // fraction of the total weight used for regularization
double lambda = clt_parameters.imp.terr_lambda; // 5.0; // 0.1;
double lambda_scale_good = clt_parameters.imp.terr_lambda_scale_good; // 0.5;
......@@ -1645,6 +1649,7 @@ public class VegetationModel {
String segments_dir = getSegmentsDir(segments_sub);
boolean read_pars = false; // true; /// false; /// true; // false; // true;
boolean crop_combo = clt_parameters.imp.terr_crop; // Crop output image to the bounds of all segments
boolean keep_partial = clt_parameters.imp.terr_keep_partial; // Crop output image to the bounds of all segments
// 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";
......@@ -2066,6 +2071,7 @@ public class VegetationModel {
vegetationLMA, // VegetationLMA vegetationLMA,
segments,
crop_combo, // boolean crop_combo,
keep_partial, // boolean keep_partial,
border_width, // int width);
um_sigma, // final double um_sigma,
um_weight, //final double um_weight,
......@@ -2080,7 +2086,20 @@ public class VegetationModel {
return;
}
Rectangle woi = woi_last_done;
// save parameters to be restored after terrain-only mode
int last_series_save = last_series;
int[] num_iters_save = num_iters;
boolean [][] fits_disable_save = fits_disable;
while (true) {
// Restore for the next tile after terrain-only mode
last_series = last_series_save;
num_iters = num_iters_save;
fits_disable = fits_disable_save;
if (debugLevel>-2) {
Runtime runtime = Runtime.getRuntime();
runtime.gc();
......
......@@ -69,6 +69,7 @@ public class VegetationSegment {
VegetationLMA vegetationLMA,
VegetationSegment [] segments,
boolean crop_combo,
boolean keep_partial,
int width,
final double um_sigma,
final double um_weight,
......@@ -183,6 +184,7 @@ public class VegetationSegment {
VegetationModel vegetationModel = vegetationLMA.getModel();
String ref_scene = vegetationModel.reference_scene;
String pre_title = ref_scene+"-preview_segments-"+out_woi.x+"-"+out_woi.y+"-"+out_woi.width+"-"+out_woi.height;
if (keep_partial) {
ShowDoubleFloatArrays.showArraysHyperstack(
preview_data, // double[][][] pixels,
out_woi.width, // int width,
......@@ -190,6 +192,19 @@ public class VegetationSegment {
titles, // String [] titles, // all slices*frames titles or just slice titles or null
top_titles, // String [] frame_titles, // frame titles or null
true); // boolean show)
} else {
double [][] accum_only = new double [preview_data.length][];
for (int t = 0; t < preview_data.length; t++) {
accum_only[t] = preview_data[t][accum_indx];
}
ShowDoubleFloatArrays.showArrays(
accum_only,
out_woi.width,
out_woi.height,
true,
pre_title+"-ACCUM",
top_titles);
}
double [] terrain_reference = crop(
vegetationModel.terrain_scenes_render[vegetationModel.reference_index],
......
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