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;
......
......@@ -7,7 +7,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.concurrent.atomic.AtomicBoolean;
......@@ -186,7 +185,8 @@ public class VegetationLMA {
// when unsharp mask is applied , pulling to 0 (when alpha is 0 (for vegetation) or 1.0 (for terrain) makes sense
private double terr_pull0 = 0; // (+) now - pull to filled terrain - terrain_average
private double terr_pull_up = 0; // Terrain pixels pull to initial (pre-adjustment) values when it is colder than initial
private double terr_pull_up = 0; // (+) Terrain pixels pull to initial (pre-adjustment) values when it is colder than initial
private double terr_pull_avg = 0; // (+) pull terrain to the initial offset by the average offset of all terrain pixels
private double veget_pull0 = 0; // (+) now - pull to vegetation_pull (extended vegetation)
public double elevation_pull0 = 0; // (*) now - pull to initial elevation
......@@ -231,6 +231,7 @@ public class VegetationLMA {
private double [] initial_rms = null; // {rms, rms_pure}, first-calcualted rms
private double [] last_ymfx = null;
private double [][] last_jt = null;
public double terrain_offset = Double.NaN; // average offset from the initial
public VegetationLMA (
int width,
......@@ -518,6 +519,7 @@ public class VegetationLMA {
final double elevation_lpf,
final double terr_pull0, // pull terrain to initial (pre-adjustment) values
final double terr_pull_up, // Terrain pixels pull to initial (pre-adjustment) values when it is colder than initial.
final double terr_pull_avg, // pull terrain to the initial offset by the average offset of all terrain pixels
final double veget_pull0, // pull vegetation to initial (pre-adjustment) values
final double elev_pull0, // pull elevation to initial (pre-adjustment) values
final boolean elev_alpha_en, // false; // Enable loss for low vegetation with high opacity
......@@ -561,6 +563,7 @@ public class VegetationLMA {
this.elevation_lpf = elevation_lpf;
this.terr_pull0 = terr_pull0;
this.terr_pull_up= (terr_pull_up > 0) ? terr_pull_up : terr_pull0;
this.terr_pull_avg = terr_pull_avg;
this.veget_pull0 = veget_pull0;
this.elevation_pull0 = elev_pull0;
this.elev_alpha_en = elev_alpha_en;
......@@ -583,7 +586,7 @@ public class VegetationLMA {
scales_xy, // final double [][][] scales_xy,
full.width); // final int width)
if (debugLevel > -2) {
if (!vegetationModel.tile_woi && (debugLevel > -2)) {
// not enough memory to allocate 468000MB (640x327580x585) stack
// vegetationModel.reference_scene
showWarps(
......@@ -638,7 +641,7 @@ public class VegetationLMA {
if (debugLevel > -2) { // 3) {
if (!vegetationModel.tile_woi && (debugLevel > -2)) { // 3) {
int first_scene = num_scenes;
int last_scene = -1;
for (int i = 0; i < num_scenes; i++) if (valid_scenes[i]){
......@@ -1166,6 +1169,7 @@ public class VegetationLMA {
boolean show_all = debug_level > 4;
debugImageSaveShow(
parameters_vector, // double [] vector
last_rms, // double [] rms,
save_dir, // String save_dir, // save if not null
debug_title, // String title, // not null
save_all, // boolean save_all,
......@@ -1344,6 +1348,7 @@ public class VegetationLMA {
boolean show_all = debug_level > 4;
debugImageSaveShow(
new_vector, // double [] vector
rms, // double [] rms,
save_dir, // String save_dir, // save if not null
debug_title, // String title, // not null
save_all, // boolean save_all,
......@@ -1404,7 +1409,7 @@ public class VegetationLMA {
debug_title += "-hf"+hifreq_weight+"-tc"+terrain_correction;
debug_title += "-al"+alpha_loss+"-alo"+alpha_offset+"-amv"+alpha_min_veg+"-alp"+alpha_lpf+"-als"+alpha_scale_avg+(alpha_piece_linear?"-alin":"-acos");
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+"-vp"+veget_pull0+"-ep"+elevation_pull0;
debug_title += "-tl"+terr_lpf+"-vl"+veget_lpf+"-el"+elevation_lpf+"-tp"+terr_pull0+"-tu"+terr_pull_up+"-ta"+terr_pull_avg+"-vp"+veget_pull0+"-ep"+elevation_pull0;
if (elev_alpha_en) {
debug_title += "-ea"+elev_alpha+"-ep"+elev_alpha_pwr+"-lv"+low_veget;
}
......@@ -1416,6 +1421,7 @@ public class VegetationLMA {
public void debugImageSaveShow(
double [] vector,
double [] rms,
String save_dir, // save if not null
String title, // not null
boolean save_all,
......@@ -1448,9 +1454,9 @@ public class VegetationLMA {
debug_iters[debug_index] = debug_iter;
debug_series[debug_index] = (vegetationModel != null) ? vegetationModel.step_restore : -1;
debug_rms[debug_index] = last_rms.clone();
debug_rms[debug_index] = rms.clone();
debug_improvements[debug_index] = debug_improved;
title += "-"+debug_iter+ "_"+debug_index+String.format("_rms%8.5f_rms-pure%8.5f", last_rms[0],last_rms[1]);
title += "-"+debug_iter+ "_"+debug_index+String.format("_rms%8.5f_rms-pure%8.5f", rms[0],rms[1]);
if (!debug_improved) {
title+="-WORSE";
}
......@@ -3102,7 +3108,39 @@ public class VegetationLMA {
} // if (alpha_lpf >= 0) {
if (samples_pointers[SAMPLES_TERRAIN_PULL][1]>0) { // fits[TVAO_TERRAIN] && (terr_lpf >= 0)) {
// final int ind_y_terr = samples_pointers[SAMPLES_TERRAIN_PULL][0]; // ind_next;
final double [] offsets_sum_threaded = new double [threads.length];
final AtomicInteger anum=new AtomicInteger(0);
double offsets_sum = 0;
if (terr_pull_avg > 0) { // TODO: need to join all terrain samples
// calculate average offset between current and initial terrain pixels
ai.set(0);
ati.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
int nthread = ati.getAndIncrement();
for (int n = ai.getAndIncrement(); n < num_pars[TVAO_TERRAIN]; n = ai.getAndIncrement()) {
int np = n + samples_pointers[SAMPLES_TERRAIN_PULL][2];
int nx = n + samples_pointers[SAMPLES_TERRAIN_PULL][0];
int findx = par_rindex[np][1];
double terr_pull = terrain_average[findx]; // maybe use tvao[TVAO_TERRAIN][findx] ?
if (Double.isNaN(terr_pull)) {
terr_pull= 0; // should not happen
}
offsets_sum_threaded[nthread] += vector[np] - terr_pull;
anum.getAndIncrement();
}
}
};
}
ImageDtt.startAndJoin(threads);
for (double d :offsets_sum_threaded) {
offsets_sum += d;
}
}
final int num = anum.get();
// final double offset_avg;
terrain_offset = (num > 0)? (offsets_sum/num) : 0;
ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
......@@ -3110,20 +3148,33 @@ public class VegetationLMA {
for (int n = ai.getAndIncrement(); n < num_pars[TVAO_TERRAIN]; n = ai.getAndIncrement()) {
int np = n + samples_pointers[SAMPLES_TERRAIN_PULL][2];
int nx = n + samples_pointers[SAMPLES_TERRAIN_PULL][0];
double d = 0;
boolean pull_up = false;
if ((terr_pull0 > 0) || (terr_pull_up > 0)) {
int findx = par_rindex[np][1];
double terr_pull = terrain_average[findx]; // maybe use tvao[TVAO_TERRAIN][findx] ?
if (Double.isNaN(terr_pull)) {
terr_pull= 0; // should not happen
}
if ((terr_pull0 > 0) || (terr_pull_up > 0)) {
double diff = vector[np] - terr_pull;
pull_up = vector[np] < terr_pull;
fX[nx] += (pull_up ? terr_pull_up : terr_pull0) * (vector[np] - terr_pull);
fX[nx] += (pull_up ? terr_pull_up : terr_pull0) * diff;
}
if (jt != null) {
jt[np][nx] += pull_up ? terr_pull_up : terr_pull0; // terr_pull0;
}
if (terr_pull_avg >0) { // TODO: maybe apply sign of difference here?
double diff = vector[np] - (terr_pull + terrain_offset);
fX[nx] += terr_pull_avg * diff;
if (jt != null) {
jt[np][nx] += terr_pull_avg; // terr_pull0;
// now apply to all (others and this) derivative form offset_avg
double dd = terr_pull_avg / num;
for (int n_other = 0; n_other < num_pars[TVAO_TERRAIN]; n_other++) {
int np_other = n_other + samples_pointers[SAMPLES_TERRAIN_PULL][2];
jt[np_other][nx] -= dd; // terr_pull0;
}
}
}
}
}
};
......@@ -3538,6 +3589,26 @@ public class VegetationLMA {
param_pivot = listsToPivot(
param_lists); // final int [][] par_lists)
if ((samples_pointers[SAMPLES_TERRAIN_PULL][1]>0) && (terr_pull_avg > 0)) {
// make all terrain pixels to depend on each other
ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int n = ai.getAndIncrement(); n < num_pars[TVAO_TERRAIN]; n = ai.getAndIncrement()) {
int np = n + samples_pointers[SAMPLES_TERRAIN_PULL][2];
for (int n_other = n+1; n_other < num_pars[TVAO_TERRAIN]; n_other++) {
int np_other = n_other + samples_pointers[SAMPLES_TERRAIN_PULL][2];
param_pivot[np][np_other] = true;
param_pivot[np_other][np] = true;
}
}
}
};
}
ImageDtt.startAndJoin(threads);
}
if (debug_level>4) showPivot(param_pivot, "pivot-all");
}
return fX;
......@@ -4145,6 +4216,8 @@ public class VegetationLMA {
imp.setProperty("LPF_FIXED_ELEVATION", ""+lpf_fixed[TVAO_ELEVATION]);
imp.setProperty("LPF_FIXED_SCENE_OFFSET", ""+lpf_fixed[TVAO_SCENE_OFFSET]);
imp.setProperty("TERR_PULL0", ""+terr_pull0);
imp.setProperty("TERR_PULL_UP", ""+terr_pull_up);
imp.setProperty("TERR_PULL_AVG", ""+terr_pull_avg);
imp.setProperty("VEGET_PULL0", ""+veget_pull0);
imp.setProperty("ELEVATION_PULL0", ""+elevation_pull0);
imp.setProperty("ELEV_ALPHA_EN", ""+elev_alpha_en);
......@@ -4165,6 +4238,7 @@ public class VegetationLMA {
imp.setProperty("IND_PARS_ALPHA", ""+ind_pars[TVAO_ALPHA]);
imp.setProperty("IND_PARS_ELEVATION", ""+ind_pars[TVAO_ELEVATION]);
imp.setProperty("IND_PARS_SCENES", ""+ind_pars[TVAO_SCENE_OFFSET]);
imp.setProperty("TERRAIN_OFFSET", ""+terrain_offset);
// samples_pointers
for (int nsp = 0; nsp < SAMPLES_SIZE; nsp++) {
......@@ -4195,7 +4269,8 @@ public class VegetationLMA {
public double [][] restoreParametersFile( //FIXME: Not finished for real import !
String path,
boolean keep_settings,
Rectangle [] file_wois){ // if not null, should be Rectangle[2] {woi_veg,woi} - will return woi data and not input parameters to this instance
Rectangle [] file_wois, // if not null, should be Rectangle[2] {woi_veg,woi} - will return woi data and not input parameters to this instance
double [] other_pars){
ImagePlus imp_pars = new ImagePlus (path);
if (imp_pars.getWidth()==0) {
throw new IllegalArgumentException("Could not read "+path);
......@@ -4276,6 +4351,9 @@ public class VegetationLMA {
}
}
data[TVAO_SCENE_OFFSET] = scene_offsets;
if ((other_pars != null) && (other_pars.length >0)){
if (imp_pars.getProperty("TERRAIN_OFFSET") != null) other_pars[0] = Double.parseDouble((String) imp_pars.getProperty("TERRAIN_OFFSET"));
}
} else {
this.woi_veg = woi_veg;
this.woi = woi;
......@@ -4312,6 +4390,8 @@ public class VegetationLMA {
lpf_fixed[TVAO_ELEVATION] = Boolean.parseBoolean((String) imp_pars.getProperty("LPF_FIXED_ELEVATION"));
lpf_fixed[TVAO_SCENE_OFFSET]=Boolean.parseBoolean((String)imp_pars.getProperty("LPF_FIXED_SCENE_OFFSET"));
terr_pull0 = Double.parseDouble((String) imp_pars.getProperty("TERR_PULL0"));
terr_pull_up = Double.parseDouble((String) imp_pars.getProperty("TERR_PULL_UP"));
terr_pull_avg = Double.parseDouble((String) imp_pars.getProperty("TERR_PULL_AVG"));
veget_pull0 = Double.parseDouble((String) imp_pars.getProperty("VEGET_PULL0"));
elevation_pull0 = Double.parseDouble((String) imp_pars.getProperty("ELEVATION_PULL0"));
if (imp_pars.getProperty("ELEV_ALPHA_EN") != null) elev_alpha_en = Boolean.parseBoolean((String) imp_pars.getProperty("ELEV_ALPHA_EN"));
......@@ -4321,6 +4401,7 @@ public class VegetationLMA {
scenes_pull0 = Double.parseDouble((String) imp_pars.getProperty("SCENES_PULL0"));
scale_scenes_pull = Double.parseDouble((String) imp_pars.getProperty("SCALE_SCENES_PULL"));
boost_parallax = Double.parseDouble((String) imp_pars.getProperty("BOOST_PARALLAX"));
if (imp_pars.getProperty("TERRAIN_OFFSET") != null) terrain_offset = Double.parseDouble((String) imp_pars.getProperty("TERRAIN_OFFSET"));
}
num_pars[TVAO_TERRAIN] = Integer.parseInt((String) imp_pars.getProperty("NUM_PARS_TERRAIN"));
num_pars[TVAO_VEGETATION] = Integer.parseInt((String) imp_pars.getProperty("NUM_PARS_VEGETATION"));
......@@ -4878,7 +4959,8 @@ public class VegetationLMA {
public VegetationSegment [] readAllSegments(
String dir_path) {
String dir_path,
String suffix) {
FileFilter parFileFilter = new FileFilter()
{
......@@ -4886,7 +4968,7 @@ public class VegetationLMA {
public boolean accept(File file) {
//if the file extension is .log return true, else false
if (file.isFile() && file.getName().endsWith(PAR_EXT)) {
if (file.isFile() && file.getName().endsWith(suffix+PAR_EXT)) {
return true;
}
return false;
......@@ -4895,21 +4977,24 @@ public class VegetationLMA {
File dir = new File(dir_path);
File [] par_files = dir.listFiles(parFileFilter);
VegetationSegment [] segments = new VegetationSegment [par_files.length];
double [] other_pars = new double [1];
for (int n = 0; n < par_files.length; n++) {
Rectangle [] wois = new Rectangle[2];
double [][] tvao = restoreParametersFile( // already trimmed to actual lengths FIXME: Not finished for real import !
par_files[n].getPath(), // String path,
false, // boolean keep_settings,
wois); // Rectangle file_woi)
wois, // Rectangle file_woi)
other_pars); //double [] other_pars)
Rectangle woi_veg = wois[0];
Rectangle woi = wois[1];
segments[n] = new VegetationSegment(
par_files[n].getPath(), // String path,
woi_veg, // Rectangle woi_veg,
woi, // Rectangle woi,
tvao[TVAO_SCENE_OFFSET], // datadouble [] scene_offsets,
new double [][] {tvao[0],tvao[1],tvao[2]}); // double [][] tva) {} {}
other_pars[0], // terrain_offset,
tvao[TVAO_SCENE_OFFSET], // double [] scene_offsets,
new double [][] {tvao[0],tvao[1],tvao[2],tvao[2]}); // double [][] tva) {} {}
}
// sort in line-scan order
Arrays.sort(segments, new Comparator<VegetationSegment>() {
......@@ -4919,10 +5004,6 @@ public class VegetationLMA {
((rhs.woi_veg.x > lhs.woi_veg.x) ? -1 : (rhs.woi_veg.x < lhs.woi_veg.x) ? 1 : 0); // increasing
}
});
return segments;
}
......
......@@ -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