Commit 5fb0ddfb authored by Andrey Filippov's avatar Andrey Filippov

More debugging

parent b7758748
...@@ -129,6 +129,7 @@ import com.elphel.imagej.tileprocessor.SymmVector; ...@@ -129,6 +129,7 @@ import com.elphel.imagej.tileprocessor.SymmVector;
import com.elphel.imagej.tileprocessor.TwoQuadCLT; import com.elphel.imagej.tileprocessor.TwoQuadCLT;
import com.elphel.imagej.tileprocessor.lwoc.LwirWorld; import com.elphel.imagej.tileprocessor.lwoc.LwirWorld;
import com.elphel.imagej.vegetation.VegetationModel; import com.elphel.imagej.vegetation.VegetationModel;
import com.elphel.imagej.vegetation.VegetationSegment;
import ij.CompositeImage; import ij.CompositeImage;
import ij.IJ; import ij.IJ;
...@@ -863,6 +864,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -863,6 +864,7 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
addButton("Process Merged", panelOrange, color_process); addButton("Process Merged", panelOrange, color_process);
addButton("Vegetation LMA", panelOrange, color_process); addButton("Vegetation LMA", panelOrange, color_process);
addButton("Combine LMA Segments", panelOrange, color_process); addButton("Combine LMA Segments", panelOrange, color_process);
addButton("Generate LWIR target", panelOrange, color_process);
plugInFrame.add(panelOrange); plugInFrame.add(panelOrange);
} }
plugInFrame.pack(); plugInFrame.pack();
...@@ -5805,6 +5807,8 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -5805,6 +5807,8 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
SYNC_COMMAND, // // SyncCommand SYNC_COMMAND, SYNC_COMMAND, // // SyncCommand SYNC_COMMAND,
CLT_PARAMETERS, //CLTParameters clt_parameters, CLT_PARAMETERS, //CLTParameters clt_parameters,
true); //boolean combine_segments); true); //boolean combine_segments);
} else if (label.equals("Generate LWIR target")) {
VegetationSegment.generateSineTarget();
} }
// //
} }
......
...@@ -871,8 +871,8 @@ min_str_neib_fpn 0.35 ...@@ -871,8 +871,8 @@ min_str_neib_fpn 0.35
public double terr_rms_diff = 1e-8; // 0.0001; virtually forever public double terr_rms_diff = 1e-8; // 0.0001; virtually forever
public int terr_last_series = -1; // Last LMA adjustment series (<0 - to the terr_num_iters.length -1) public int terr_last_series = -1; // Last LMA adjustment series (<0 - to the terr_num_iters.length -1)
public int [] terr_num_iters = {30}; //sequence on numbers of iterations public int [] terr_num_iters = {30}; //sequence on numbers of iterations
public boolean terr_only_special = true; // special sequences for terrain-only tiles /// public boolean terr_only_special = true; // special sequences for terrain-only tiles
public boolean terr_only_pix = true; // force per-pixel terrain elevation in terrain-only mode, overwrite fits_disable[TVAO_TERR_ELEV_PIX] /// public boolean terr_only_pix = true; // force per-pixel terrain elevation in terrain-only mode, overwrite fits_disable[TVAO_TERR_ELEV_PIX]
public int terr_only_series = -1; // similar to terr_last_series but for terrain-only mode (<0 - length of terr_only_num_iters) public int terr_only_series = -1; // similar to terr_last_series but for terrain-only mode (<0 - length of terr_only_num_iters)
public int [] terr_only_num_iters = {25}; // number of iterations public int [] terr_only_num_iters = {25}; // number of iterations
...@@ -2246,8 +2246,8 @@ min_str_neib_fpn 0.35 ...@@ -2246,8 +2246,8 @@ min_str_neib_fpn 0.35
gd.addStringField ("Maximal iterations", intsToString(terr_num_iters), 40, "Maximal number of LMA iterations per series, 1 or several values."); gd.addStringField ("Maximal iterations", intsToString(terr_num_iters), 40, "Maximal number of LMA iterations per series, 1 or several values.");
gd.addMessage ("Terrain-only LMA"); gd.addMessage ("Terrain-only LMA");
gd.addCheckbox ("Terrain-only mode", terr_only_special, "Treat terrain-only tiles differently (below)."); /// gd.addCheckbox ("Terrain-only mode", terr_only_special, "Treat terrain-only tiles differently (below).");
gd.addCheckbox ("Adjust pixel elevation",terr_only_pix, "Force per-pixel terrain elevation adjustment in terrain-only mode."); /// gd.addCheckbox ("Adjust pixel elevation",terr_only_pix, "Force per-pixel terrain elevation adjustment in terrain-only mode.");
gd.addNumericField("Terrain-only iterations",terr_only_series, 0,3,"", "Last LMA series in terrain-only mode, -1 - to last available in the sequence below."); gd.addNumericField("Terrain-only iterations",terr_only_series, 0,3,"", "Last LMA series in terrain-only mode, -1 - to last available in the sequence below.");
gd.addStringField ("Maximal iterations", intsToString(terr_only_num_iters), 40, "Maximal number of LMA iterations per series, 1 or several values."); gd.addStringField ("Maximal iterations", intsToString(terr_only_num_iters), 40, "Maximal number of LMA iterations per series, 1 or several values.");
...@@ -3041,8 +3041,8 @@ min_str_neib_fpn 0.35 ...@@ -3041,8 +3041,8 @@ min_str_neib_fpn 0.35
terr_last_series = (int) gd.getNextNumber();// int terr_last_series = (int) gd.getNextNumber();// int
terr_num_iters = StringToInts(gd.getNextString()); terr_num_iters = StringToInts(gd.getNextString());
terr_only_special = gd.getNextBoolean();// boolean /// terr_only_special = gd.getNextBoolean();// boolean
terr_only_pix = gd.getNextBoolean();// boolean /// terr_only_pix = gd.getNextBoolean();// boolean
terr_only_series = (int) gd.getNextNumber();// int terr_only_series = (int) gd.getNextNumber();// int
terr_only_num_iters = StringToInts(gd.getNextString()); terr_only_num_iters = StringToInts(gd.getNextString());
...@@ -3811,8 +3811,8 @@ min_str_neib_fpn 0.35 ...@@ -3811,8 +3811,8 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"terr_last_series", terr_last_series+""); // int properties.setProperty(prefix+"terr_last_series", terr_last_series+""); // int
properties.setProperty(prefix+"terr_num_iters", intsToString(terr_num_iters)+""); // int [] properties.setProperty(prefix+"terr_num_iters", intsToString(terr_num_iters)+""); // int []
properties.setProperty(prefix+"terr_only_special", terr_only_special+""); // boolean /// properties.setProperty(prefix+"terr_only_special", terr_only_special+""); // boolean
properties.setProperty(prefix+"terr_only_pix", terr_only_pix+""); // boolean /// properties.setProperty(prefix+"terr_only_pix", terr_only_pix+""); // boolean
properties.setProperty(prefix+"terr_only_series", terr_only_series+""); // int properties.setProperty(prefix+"terr_only_series", terr_only_series+""); // int
properties.setProperty(prefix+"terr_only_num_iters", intsToString(terr_only_num_iters)+""); // int [] properties.setProperty(prefix+"terr_only_num_iters", intsToString(terr_only_num_iters)+""); // int []
...@@ -4596,8 +4596,8 @@ min_str_neib_fpn 0.35 ...@@ -4596,8 +4596,8 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"terr_num_iter")!= null) terr_num_iters=new int[] {Integer.parseInt(properties.getProperty(prefix+"terr_num_iter"))}; if (properties.getProperty(prefix+"terr_num_iter")!= null) terr_num_iters=new int[] {Integer.parseInt(properties.getProperty(prefix+"terr_num_iter"))};
if (properties.getProperty(prefix+"terr_num_iters")!= null) terr_num_iters=StringToInts((String) properties.getProperty(prefix+"terr_num_iters")); if (properties.getProperty(prefix+"terr_num_iters")!= null) terr_num_iters=StringToInts((String) properties.getProperty(prefix+"terr_num_iters"));
if (properties.getProperty(prefix+"terr_only_special")!= null) terr_only_special=Boolean.parseBoolean(properties.getProperty(prefix+"terr_only_special")); /// if (properties.getProperty(prefix+"terr_only_special")!= null) terr_only_special=Boolean.parseBoolean(properties.getProperty(prefix+"terr_only_special"));
if (properties.getProperty(prefix+"terr_only_pix")!= null) terr_only_pix=Boolean.parseBoolean(properties.getProperty(prefix+"terr_only_pix")); /// if (properties.getProperty(prefix+"terr_only_pix")!= null) terr_only_pix=Boolean.parseBoolean(properties.getProperty(prefix+"terr_only_pix"));
if (properties.getProperty(prefix+"terr_only_series")!= null) terr_only_series=Integer.parseInt(properties.getProperty(prefix+"terr_only_series")); if (properties.getProperty(prefix+"terr_only_series")!= null) terr_only_series=Integer.parseInt(properties.getProperty(prefix+"terr_only_series"));
if (properties.getProperty(prefix+"terr_only_num_iters")!= null) terr_only_num_iters=StringToInts((String) properties.getProperty(prefix+"terr_only_num_iters")); if (properties.getProperty(prefix+"terr_only_num_iters")!= null) terr_only_num_iters=StringToInts((String) properties.getProperty(prefix+"terr_only_num_iters"));
...@@ -5344,8 +5344,8 @@ min_str_neib_fpn 0.35 ...@@ -5344,8 +5344,8 @@ min_str_neib_fpn 0.35
imp.terr_last_series = this.terr_last_series; imp.terr_last_series = this.terr_last_series;
imp.terr_num_iters = this.terr_num_iters.clone(); imp.terr_num_iters = this.terr_num_iters.clone();
imp.terr_only_special = this.terr_only_special; /// imp.terr_only_special = this.terr_only_special;
imp.terr_only_pix = this.terr_only_pix; /// imp.terr_only_pix = this.terr_only_pix;
imp.terr_only_series = this.terr_only_series; imp.terr_only_series = this.terr_only_series;
imp.terr_only_num_iters = this.terr_only_num_iters.clone(); imp.terr_only_num_iters = this.terr_only_num_iters.clone();
......
...@@ -164,7 +164,8 @@ public class VegetationLMA { ...@@ -164,7 +164,8 @@ public class VegetationLMA {
private double weight_pure = 0; private double weight_pure = 0;
private double [] weights; // normalized so sum is 1.0 for all - samples and extra regularization private double [] weights; // normalized so sum is 1.0 for all - samples and extra regularization
boolean [] fits_disable = new boolean[TVAO_TYPES]; // (+) boolean [] fits_disable = new boolean[TVAO_TYPES]; // (+)
boolean [] fits_disable_terronly = new boolean[TVAO_TYPES]; // (+)
private double terrain_correction = 0.02; // (+) weight of y_wavg private double terrain_correction = 0.02; // (+) weight of y_wavg
// Parameters saved/resored in a file // Parameters saved/resored in a file
...@@ -234,8 +235,8 @@ public class VegetationLMA { ...@@ -234,8 +235,8 @@ public class VegetationLMA {
public double ttop_rel_rad = 0.25; // (+) Relative (to the top height) sample ring radius public double ttop_rel_rad = 0.25; // (+) Relative (to the top height) sample ring radius
public double ttop_frac = 0.5; // (+) Minimal fraction of the ring pixels below sample level public double ttop_frac = 0.5; // (+) Minimal fraction of the ring pixels below sample level
public double ttop_rem_rad = 0.25; // (+) Relative (to the top height) remove transparency radius public double ttop_rem_rad = 0.25; // (+) Relative (to the top height) remove transparency radius
public boolean terr_only_special = true; // (+) special sequences for terrain-only tiles // public boolean terr_only_special = true; // (+) special sequences for terrain-only tiles
public boolean terr_only_pix = true; // (+) force per-pixel terrain elevation in terrain-only mode, overwrite fits_disable[TVAO_TERR_ELEV_PIX] // public boolean terr_only_pix = true; // (+) force per-pixel terrain elevation in terrain-only mode, overwrite fits_disable[TVAO_TERR_ELEV_PIX]
public double boost_parallax = 1; // (+) public double boost_parallax = 1; // (+)
public double max_parallax = 10; // (+) public double max_parallax = 10; // (+)
...@@ -867,7 +868,8 @@ public class VegetationLMA { ...@@ -867,7 +868,8 @@ public class VegetationLMA {
final boolean fit_elevations, final boolean fit_elevations,
final boolean fit_terr_elev, final boolean fit_terr_elev,
final boolean fit_terr_elev_pix, final boolean fit_terr_elev_pix,
final boolean [] fits_disable, final boolean [] fits_disable,
final boolean [] fits_disable_terronly,
final double reg_weights, // fraction of the total weight used for regularization final double reg_weights, // fraction of the total weight used for regularization
final double alpha_loss, // alpha quadratic growing loss for when out of [0,1] range final double alpha_loss, // alpha quadratic growing loss for when out of [0,1] range
final double alpha_loss_lin, // alpha linear growing loss for when out of [0,1] range and below minimal vegetation alpha final double alpha_loss_lin, // alpha linear growing loss for when out of [0,1] range and below minimal vegetation alpha
...@@ -912,8 +914,8 @@ public class VegetationLMA { ...@@ -912,8 +914,8 @@ public class VegetationLMA {
final double ttop_rel_rad, // 0.25; // Relative (to the top height) sample ring radius final double ttop_rel_rad, // 0.25; // Relative (to the top height) sample ring radius
final double ttop_frac, // 0.5; // Minimal fraction of the ring pixels below sample level final double ttop_frac, // 0.5; // Minimal fraction of the ring pixels below sample level
final double ttop_rem_rad, // 0.25; // Relative (to the top height) remove transparency radius final double ttop_rem_rad, // 0.25; // Relative (to the top height) remove transparency radius
final boolean terr_only_special,//true; // special sequences for terrain-only tiles /// final boolean terr_only_special,//true; // special sequences for terrain-only tiles
final boolean terr_only_pix, //true; // force per-pixel terrain elevation in terrain-only mode, overwrite fits_disable[TVAO_TERR_ELEV_PIX] /// final boolean terr_only_pix, //true; // force per-pixel terrain elevation in terrain-only mode, overwrite fits_disable[TVAO_TERR_ELEV_PIX]
final double boost_parallax, // increase weight of scene with maximal parallax relative to the reference scene final double boost_parallax, // increase weight of scene with maximal parallax relative to the reference scene
final double max_parallax, // do not consider maximal parallax above this (consider it a glitch) final double max_parallax, // do not consider maximal parallax above this (consider it a glitch)
final int debugLevel, final int debugLevel,
...@@ -931,9 +933,13 @@ public class VegetationLMA { ...@@ -931,9 +933,13 @@ public class VegetationLMA {
fits[TVAO_ELEVATION] = fit_elevations; fits[TVAO_ELEVATION] = fit_elevations;
fits[TVAO_TERR_ELEV] = fit_terr_elev || fit_terr_elev_pix; // always both fits[TVAO_TERR_ELEV] = fit_terr_elev || fit_terr_elev_pix; // always both
fits[TVAO_TERR_ELEV_PIX] = fit_terr_elev || fit_terr_elev_pix; fits[TVAO_TERR_ELEV_PIX] = fit_terr_elev || fit_terr_elev_pix;
this.fits_disable = fits_disable.clone(); this.fits_disable = fits_disable.clone();
this.fits_disable_terronly = (fits_disable_terronly != null)? fits_disable_terronly.clone() : null;
// TODO: modify fits_disable with setter only ? // TODO: modify fits_disable with setter only ?
this.fits_disable[TVAO_TERR_ELEV] |= !(this.fits_disable[TVAO_TERR_ELEV_PIX] && fits[TVAO_TERR_ELEV_PIX]); // can not be enabled simultaneously this.fits_disable[TVAO_TERR_ELEV] |= !(this.fits_disable[TVAO_TERR_ELEV_PIX] && fits[TVAO_TERR_ELEV_PIX]); // can not be enabled simultaneously
if (this.fits_disable_terronly!= null) {
this.fits_disable_terronly[TVAO_TERR_ELEV] |= !(this.fits_disable_terronly[TVAO_TERR_ELEV_PIX] && fits[TVAO_TERR_ELEV_PIX]); // can not be enabled simultaneously
}
this.reg_weights = reg_weights; // fraction of the total weight used for regularization this.reg_weights = reg_weights; // fraction of the total weight used for regularization
this.alpha_loss = alpha_loss; this.alpha_loss = alpha_loss;
this.alpha_loss_lin = alpha_loss_lin; this.alpha_loss_lin = alpha_loss_lin;
...@@ -978,8 +984,8 @@ public class VegetationLMA { ...@@ -978,8 +984,8 @@ public class VegetationLMA {
this.ttop_rel_rad = ttop_rel_rad; this.ttop_rel_rad = ttop_rel_rad;
this.ttop_frac = ttop_frac; this.ttop_frac = ttop_frac;
this.ttop_rem_rad = ttop_rem_rad; this.ttop_rem_rad = ttop_rem_rad;
this.terr_only_special = terr_only_special; /// this.terr_only_special = terr_only_special;
this.terr_only_pix = terr_only_pix; /// this.terr_only_pix = terr_only_pix;
this.boost_parallax = boost_parallax; this.boost_parallax = boost_parallax;
this.max_parallax = max_parallax; // parallax limit when evaluating boost parallax this.max_parallax = max_parallax; // parallax limit when evaluating boost parallax
this.max_warp = max_warp; this.max_warp = max_warp;
...@@ -1109,10 +1115,21 @@ public class VegetationLMA { ...@@ -1109,10 +1115,21 @@ public class VegetationLMA {
fits[TVAO_ALPHA] = false; fits[TVAO_ALPHA] = false;
fits[TVAO_ELEVATION] = false; fits[TVAO_ELEVATION] = false;
} }
if (fits_disable_terronly!= null) {
for (int i = 0; i < this.fits_disable.length; i++) {
this.fits_disable[i] = fits_disable_terronly[i];
}
if (debugLevel > -3) {
System.out.println("Using fits="+IntersceneMatchParameters.booleansToString(this.fits,2)+
" fits_disable = "+IntersceneMatchParameters.booleansToString(this.fits_disable,2));
}
}
/*
if (terr_only_special) { if (terr_only_special) {
fits_disable[TVAO_TERR_ELEV] = terr_only_pix; fits_disable[TVAO_TERR_ELEV] = terr_only_pix;
fits_disable[TVAO_TERR_ELEV_PIX] = !terr_only_pix; fits_disable[TVAO_TERR_ELEV_PIX] = !terr_only_pix;
} }
*/
} }
...@@ -1877,7 +1894,7 @@ public class VegetationLMA { ...@@ -1877,7 +1894,7 @@ public class VegetationLMA {
max_elev_terr_chg, // double max_diff, max_elev_terr_chg, // double max_diff,
debug_level + 2); // int debugLevel) debug_level + 2); // int debugLevel)
if ((debug_level > -3) && (num_terr_elev_mods > 0)) { if ((debug_level > -3) && (num_terr_elev_mods > 0)) {
System.out.println("lmaStep(): modified "+num_terr_elev_mods+" terrain elevation values to fit limuts."); System.out.println("lmaStep(): modified "+num_terr_elev_mods+" terrain elevation values to fit limits.");
} }
/* /*
if (par_indx_terr_elev >= 0) { if (par_indx_terr_elev >= 0) {
...@@ -3341,22 +3358,47 @@ public class VegetationLMA { ...@@ -3341,22 +3358,47 @@ public class VegetationLMA {
vector, // final double [] vector, vector, // final double [] vector,
(jt != null), // final boolean calc_derivatives, (jt != null), // final boolean calc_derivatives,
debug_level); // final int debugLevel) { debug_level); // final int debugLevel) {
final boolean use_terr_elev_pix = (getIndxTerrElevPix() >=0) &&
(!fits_disable[TVAO_TERR_ELEV_PIX] || fits_disable[TVAO_TERR_ELEV]); // when both are disabled
final boolean use_terr_elev = (getIndxTerrElev() >=0) && !use_terr_elev_pix;
// only one of terr_elev_parameters, terr_elpix_parameters may be true simultaneously
final boolean terr_elev_parameters = use_terr_elev; // (num_pars[TVAO_TERR_ELEV] > 0) && !fits_disable[TVAO_TERR_ELEV];
final boolean terr_elpix_parameters = use_terr_elev_pix; // (num_pars[TVAO_TERR_ELEV_PIX]> 0) && !fits_disable[TVAO_TERR_ELEV_PIX];
if (use_terr_elev_pix) { // (getIndxTerrElevPix() >=0) && !fits_disable[TVAO_TERR_ELEV_PIX]) {
setupTerrainElevationPixLMA(
vector, // final double [] vector,
terr_elev_radius, // final double radius,
(jt != null), // final boolean calc_derivatives,
debug_level); // final int debugLevel)
} else {
terr_elpix_woi4 = null;
if (use_terr_elev) { //(getIndxTerrElev() >=0) && !fits_disable[TVAO_TERR_ELEV]) {
setupTerrainElevationLMA(
vector, // final double [] vector,
terr_elev_radius, // final double radius,
(jt != null), // final boolean calc_derivatives,
debug_level); // final int debugLevel) {
} else {
terr_elev_woi4 = null;
}
}
/*
// FIXME: probably wrong - as soon as per-pixel are different, has to always use them // FIXME: probably wrong - as soon as per-pixel are different, has to always use them
if ((getIndxTerrElev() >=0) && !fits_disable[TVAO_TERR_ELEV]) { if (use_terr_elev) { //(getIndxTerrElev() >=0) && !fits_disable[TVAO_TERR_ELEV]) {
setupTerrainElevationLMA( setupTerrainElevationLMA(
vector, // final double [] vector, vector, // final double [] vector,
terr_elev_radius, // final double radius, terr_elev_radius, // final double radius,
(jt != null), // final boolean calc_derivatives, (jt != null), // final boolean calc_derivatives,
debug_level); // final int debugLevel) { debug_level); // final int debugLevel) {
} else if ((getIndxTerrElevPix() >=0) && !fits_disable[TVAO_TERR_ELEV_PIX]) { } else if (use_terr_elev_pix) { // (getIndxTerrElevPix() >=0) && !fits_disable[TVAO_TERR_ELEV_PIX]) {
setupTerrainElevationPixLMA( setupTerrainElevationPixLMA(
vector, // final double [] vector, vector, // final double [] vector,
terr_elev_radius, // final double radius, terr_elev_radius, // final double radius,
(jt != null), // final boolean calc_derivatives, (jt != null), // final boolean calc_derivatives,
debug_level); // final int debugLevel) { debug_level); // final int debugLevel) {
} }
*/
/// final boolean offset_terrain = !Double.isNaN(terr_elev_last) && (terr_elev_last != 0); // if 0, use terrain pixels directly /// final boolean offset_terrain = !Double.isNaN(terr_elev_last) && (terr_elev_last != 0); // if 0, use terrain pixels directly
final int woi_length = woi.width * woi.height; final int woi_length = woi.width * woi.height;
...@@ -3369,9 +3411,6 @@ public class VegetationLMA { ...@@ -3369,9 +3411,6 @@ public class VegetationLMA {
final boolean vegetation_parameters = (num_pars[TVAO_VEGETATION] > 0); // 0 when woi_veg==null final boolean vegetation_parameters = (num_pars[TVAO_VEGETATION] > 0); // 0 when woi_veg==null
final boolean alpha_parameters = (num_pars[TVAO_ALPHA] > 0); // 0 when woi_veg==null final boolean alpha_parameters = (num_pars[TVAO_ALPHA] > 0); // 0 when woi_veg==null
final boolean terrain_parameters = (num_pars[TVAO_TERRAIN] > 0); final boolean terrain_parameters = (num_pars[TVAO_TERRAIN] > 0);
// only one of terr_elev_parameters, terr_elpix_parameters may be true simultaneously
final boolean terr_elev_parameters = (num_pars[TVAO_TERR_ELEV] > 0) && !fits_disable[TVAO_TERR_ELEV];
final boolean terr_elpix_parameters = (num_pars[TVAO_TERR_ELEV_PIX]> 0) && !fits_disable[TVAO_TERR_ELEV_PIX];
final boolean scenes_parameters = (num_pars[TVAO_SCENE_OFFSET] > 0); final boolean scenes_parameters = (num_pars[TVAO_SCENE_OFFSET] > 0);
final AtomicInteger anum_elev_err = new AtomicInteger(0); final AtomicInteger anum_elev_err = new AtomicInteger(0);
// final boolean use_hf = samples_pointers[SAMPLES_Y_HF][1]>0; // final boolean use_hf = samples_pointers[SAMPLES_Y_HF][1]>0;
...@@ -3429,7 +3468,7 @@ public class VegetationLMA { ...@@ -3429,7 +3468,7 @@ public class VegetationLMA {
double [][] dveget_woi = null; double [][] dveget_woi = null;
double [][] dterrain_woi_dterrain = null; // derivatives of terrain in image [woi] per terrain [woi_terr] double [][] dterrain_woi_dterrain = null; // derivatives of terrain in image [woi] per terrain [woi_terr]
double [] dterrain_woi_dtelev = null; // derivatives of terrain in image [woi] per terrain elevation [1] double [] dterrain_woi_dtelev = null; // derivatives of terrain in image [woi] per terrain elevation [1]
double [][] dterrain_woi_dtelpix = null; // derivatives of terrain in image [woi] per terrain elevation [woi_terr] //// double [][] dterrain_woi_dtelpix = null; // derivatives of terrain in image [woi] per terrain elevation [woi_terr]
int nthread = ati.getAndIncrement(); int nthread = ati.getAndIncrement();
ArrayList<HashSet<Integer>> contrib_thread = null; ArrayList<HashSet<Integer>> contrib_thread = null;
if (need_derivs) { if (need_derivs) {
...@@ -3445,9 +3484,9 @@ public class VegetationLMA { ...@@ -3445,9 +3484,9 @@ public class VegetationLMA {
if (terr_elev_parameters) { if (terr_elev_parameters) {
dterrain_woi_dtelev = new double [woi_length]; dterrain_woi_dtelev = new double [woi_length];
} }
if (terr_elpix_parameters) { //// if (terr_elpix_parameters) {
dterrain_woi_dtelpix = new double [num_pars[TVAO_TERR_ELEV_PIX]][woi_length]; //// dterrain_woi_dtelpix = new double [num_pars[TVAO_TERR_ELEV_PIX]][woi_length];
} //// }
} }
for (int nScene = ai.getAndIncrement(); nScene < num_scenes; nScene = ai.getAndIncrement()) if (valid_scenes[nScene]){ for (int nScene = ai.getAndIncrement(); nScene < num_scenes; nScene = ai.getAndIncrement()) if (valid_scenes[nScene]){
Arrays.fill(alpha_woi,0); Arrays.fill(alpha_woi,0);
...@@ -3602,7 +3641,6 @@ public class VegetationLMA { ...@@ -3602,7 +3641,6 @@ public class VegetationLMA {
} }
} // if (terr_elev_woi4 != null) { } // if (terr_elev_woi4 != null) {
if (terr_elpix_woi4 != null) { // per-pixel terrain elevation. Make mutually-exclusive with terr_elev_woi4 if (terr_elpix_woi4 != null) { // per-pixel terrain elevation. Make mutually-exclusive with terr_elev_woi4
for (int wtindex = 0; wtindex < woi_terr_length; wtindex++) if (terr_elpix_woi4[nScene][wtindex] != null) { for (int wtindex = 0; wtindex < woi_terr_length; wtindex++) if (terr_elpix_woi4[nScene][wtindex] != null) {
int wtx = wtindex % woi_terr.width; // relative to woi_terr int wtx = wtindex % woi_terr.width; // relative to woi_terr
...@@ -3664,7 +3702,7 @@ public class VegetationLMA { ...@@ -3664,7 +3702,7 @@ public class VegetationLMA {
} }
} }
} }
} // if (terr_elev_woi4 != null) { } // if (terr_elpix_woi4 != null) {
for (int windx = 0; windx < woi_length; windx++) if (valid_terr_proj[windx]) { for (int windx = 0; windx < woi_length; windx++) if (valid_terr_proj[windx]) {
...@@ -3681,7 +3719,7 @@ public class VegetationLMA { ...@@ -3681,7 +3719,7 @@ public class VegetationLMA {
} }
double terrain = 0; double terrain = 0;
double stw = 0; double stw = 0;
if (terr_elpix_parameters) { if (terr_elpix_parameters) { // almost always
stw = terr_elpix_sum_weights[nScene][windx]; stw = terr_elpix_sum_weights[nScene][windx];
} else if (terr_elev_parameters) { } else if (terr_elev_parameters) {
stw = terr_elev_sum_weights[nScene][windx]; stw = terr_elev_sum_weights[nScene][windx];
...@@ -3857,7 +3895,7 @@ public class VegetationLMA { ...@@ -3857,7 +3895,7 @@ public class VegetationLMA {
jt[ind_pars[TVAO_TERR_ELEV]][y_indx] += dterrain_woi_dtelev[windx] * (1 - k);// sum_a; // d/dterrain jt[ind_pars[TVAO_TERR_ELEV]][y_indx] += dterrain_woi_dtelev[windx] * (1 - k);// sum_a; // d/dterrain
} // if (terr_elev_parameters) { } // if (terr_elev_parameters) {
if (terr_elpix_parameters) { if (terr_elpix_parameters && !fits_disable[TVAO_TERR_ELEV_PIX]) { // skip if derivatives not needed
/// here - just derivatives as direct influence of elevations is already processed /// here - just derivatives as direct influence of elevations is already processed
/// we have dsw_delevations (for all elevation parameters) - , /// we have dsw_delevations (for all elevation parameters) - ,
HashSet<Integer> tepars_set = terr_elpix_contribs.get(windx); HashSet<Integer> tepars_set = terr_elpix_contribs.get(windx);
...@@ -3936,7 +3974,7 @@ public class VegetationLMA { ...@@ -3936,7 +3974,7 @@ public class VegetationLMA {
contrib_thread.get(windx).add(ind_pars[TVAO_TERR_ELEV]); // full parameter index - this result pixel depends on this terrain parameter contrib_thread.get(windx).add(ind_pars[TVAO_TERR_ELEV]); // full parameter index - this result pixel depends on this terrain parameter
jt[ind_pars[TVAO_TERR_ELEV]][y_indx] += dterrain_woi_dtelev[windx];// sum_a; // d/dterrain jt[ind_pars[TVAO_TERR_ELEV]][y_indx] += dterrain_woi_dtelev[windx];// sum_a; // d/dterrain
} }
if (terr_elpix_parameters) { if (terr_elpix_parameters && !fits_disable[TVAO_TERR_ELEV_PIX]) { // skip if derivatives are not needed
HashSet<Integer> tepars_set = terr_elpix_contribs.get(windx); HashSet<Integer> tepars_set = terr_elpix_contribs.get(windx);
for (int npar: tepars_set) { // elevation parameters - full for (int npar: tepars_set) { // elevation parameters - full
int ntepar = npar-ind_pars[TVAO_TERR_ELEV_PIX]; int ntepar = npar-ind_pars[TVAO_TERR_ELEV_PIX];
...@@ -5567,6 +5605,7 @@ public class VegetationLMA { ...@@ -5567,6 +5605,7 @@ public class VegetationLMA {
imp.setProperty("FIT_DISABLE_ALPHA", ""+fits_disable[TVAO_ALPHA]); imp.setProperty("FIT_DISABLE_ALPHA", ""+fits_disable[TVAO_ALPHA]);
imp.setProperty("FIT_DISABLE_ELEVATION", ""+fits_disable[TVAO_ELEVATION]); imp.setProperty("FIT_DISABLE_ELEVATION", ""+fits_disable[TVAO_ELEVATION]);
imp.setProperty("FIT_DISABLE_TERR_ELEV", ""+fits_disable[TVAO_TERR_ELEV]); imp.setProperty("FIT_DISABLE_TERR_ELEV", ""+fits_disable[TVAO_TERR_ELEV]);
imp.setProperty("FIT_DISABLE_TERR_ELEV_PIX", ""+fits_disable[TVAO_TERR_ELEV_PIX]);
imp.setProperty("FIT_DISABLE_SCENE_OFFSET", ""+fits_disable[TVAO_SCENE_OFFSET]); imp.setProperty("FIT_DISABLE_SCENE_OFFSET", ""+fits_disable[TVAO_SCENE_OFFSET]);
// imp.setProperty("TERR_ELEVATION_FULL", ""+terr_elevation_full); // imp.setProperty("TERR_ELEVATION_FULL", ""+terr_elevation_full);
imp.setProperty("ALPHA_LOSS", ""+alpha_loss); imp.setProperty("ALPHA_LOSS", ""+alpha_loss);
...@@ -5629,8 +5668,8 @@ public class VegetationLMA { ...@@ -5629,8 +5668,8 @@ public class VegetationLMA {
imp.setProperty("TTOP_REL_RAD", ""+ttop_rel_rad); imp.setProperty("TTOP_REL_RAD", ""+ttop_rel_rad);
imp.setProperty("TTOP_FRAC", ""+ttop_frac); imp.setProperty("TTOP_FRAC", ""+ttop_frac);
imp.setProperty("TTOP_REM_RAD", ""+ttop_rem_rad); imp.setProperty("TTOP_REM_RAD", ""+ttop_rem_rad);
imp.setProperty("TERR_ONLY_SPECIAL", ""+terr_only_special); /// imp.setProperty("TERR_ONLY_SPECIAL", ""+terr_only_special);
imp.setProperty("TERR_ONLY_PIX", ""+terr_only_pix); /// imp.setProperty("TERR_ONLY_PIX", ""+terr_only_pix);
imp.setProperty("BOOST_PARALLAX", ""+boost_parallax); imp.setProperty("BOOST_PARALLAX", ""+boost_parallax);
imp.setProperty("MAX_PARALLAX", ""+max_parallax); imp.setProperty("MAX_PARALLAX", ""+max_parallax);
imp.setProperty("MAX_WARP", ""+max_warp); imp.setProperty("MAX_WARP", ""+max_warp);
...@@ -5758,12 +5797,16 @@ public class VegetationLMA { ...@@ -5758,12 +5797,16 @@ public class VegetationLMA {
fits[TVAO_VEGETATION] = Boolean.parseBoolean((String) imp_pars.getProperty("FIT_VEGETATION")); fits[TVAO_VEGETATION] = Boolean.parseBoolean((String) imp_pars.getProperty("FIT_VEGETATION"));
fits[TVAO_ALPHA] = Boolean.parseBoolean((String) imp_pars.getProperty("FIT_ALPHA")); fits[TVAO_ALPHA] = Boolean.parseBoolean((String) imp_pars.getProperty("FIT_ALPHA"));
fits[TVAO_ELEVATION] = Boolean.parseBoolean((String) imp_pars.getProperty("FIT_ELEVATION")); fits[TVAO_ELEVATION] = Boolean.parseBoolean((String) imp_pars.getProperty("FIT_ELEVATION"));
fits[TVAO_TERR_ELEV] = getProperty(imp_pars,"FIT_TERR_ELEV", fits[TVAO_TERR_ELEV]);
fits[TVAO_TERR_ELEV_PIX] = getProperty(imp_pars,"FIT_TERR_ELEV_PIX", fits[TVAO_TERR_ELEV_PIX]);
fits[TVAO_SCENE_OFFSET] = Boolean.parseBoolean((String) imp_pars.getProperty("FIT_SCENE_OFFSET")); fits[TVAO_SCENE_OFFSET] = Boolean.parseBoolean((String) imp_pars.getProperty("FIT_SCENE_OFFSET"));
fits_disable[TVAO_TERRAIN] = getProperty(imp_pars,"FIT_DISABLE_TERRAIN", fits_disable[TVAO_TERRAIN]); fits_disable[TVAO_TERRAIN] = getProperty(imp_pars,"FIT_DISABLE_TERRAIN", fits_disable[TVAO_TERRAIN]);
fits_disable[TVAO_VEGETATION] = getProperty(imp_pars,"FIT_DISABLE_VEGETATION", fits_disable[TVAO_VEGETATION]); fits_disable[TVAO_VEGETATION] = getProperty(imp_pars,"FIT_DISABLE_VEGETATION", fits_disable[TVAO_VEGETATION]);
fits_disable[TVAO_ALPHA] = getProperty(imp_pars,"FIT_DISABLE_ALPHA", fits_disable[TVAO_ALPHA]); fits_disable[TVAO_ALPHA] = getProperty(imp_pars,"FIT_DISABLE_ALPHA", fits_disable[TVAO_ALPHA]);
fits_disable[TVAO_ELEVATION] = getProperty(imp_pars,"FIT_DISABLE_ELEVATION", fits_disable[TVAO_ELEVATION]); fits_disable[TVAO_ELEVATION] = getProperty(imp_pars,"FIT_DISABLE_ELEVATION", fits_disable[TVAO_ELEVATION]);
fits_disable[TVAO_TERR_ELEV] = getProperty(imp_pars,"FIT_DISABLE_TERR_ELEV", fits_disable[TVAO_TERR_ELEV]);
fits_disable[TVAO_TERR_ELEV_PIX] =getProperty(imp_pars,"FIT_DISABLE_TERR_ELEV_PIX",fits_disable[TVAO_TERR_ELEV_PIX]);
fits_disable[TVAO_SCENE_OFFSET] = getProperty(imp_pars,"FIT_DISABLE_SCENE_OFFSET", fits_disable[TVAO_SCENE_OFFSET]); fits_disable[TVAO_SCENE_OFFSET] = getProperty(imp_pars,"FIT_DISABLE_SCENE_OFFSET", fits_disable[TVAO_SCENE_OFFSET]);
// terr_elevation_full = getProperty(imp_pars,"TERR_ELEVATION_FULL", terr_elevation_full); // terr_elevation_full = getProperty(imp_pars,"TERR_ELEVATION_FULL", terr_elevation_full);
...@@ -5826,8 +5869,8 @@ public class VegetationLMA { ...@@ -5826,8 +5869,8 @@ public class VegetationLMA {
ttop_rel_rad = getProperty(imp_pars,"TTOP_REL_RAD", ttop_rel_rad); ttop_rel_rad = getProperty(imp_pars,"TTOP_REL_RAD", ttop_rel_rad);
ttop_frac = getProperty(imp_pars,"TTOP_FRAC", ttop_frac); ttop_frac = getProperty(imp_pars,"TTOP_FRAC", ttop_frac);
ttop_rem_rad = getProperty(imp_pars,"TTOP_REM_RAD", ttop_rem_rad); ttop_rem_rad = getProperty(imp_pars,"TTOP_REM_RAD", ttop_rem_rad);
terr_only_special = getProperty(imp_pars,"TERR_ONLY_SPECIAL", terr_only_special); /// terr_only_special = getProperty(imp_pars,"TERR_ONLY_SPECIAL", terr_only_special);
terr_only_pix = getProperty(imp_pars,"TERR_ONLY_PIX", terr_only_pix); /// terr_only_pix = getProperty(imp_pars,"TERR_ONLY_PIX", terr_only_pix);
boost_parallax = getProperty(imp_pars,"BOOST_PARALLAX", boost_parallax); boost_parallax = getProperty(imp_pars,"BOOST_PARALLAX", boost_parallax);
max_parallax = getProperty(imp_pars,"MAX_PARALLAX", max_parallax); max_parallax = getProperty(imp_pars,"MAX_PARALLAX", max_parallax);
max_warp = getProperty(imp_pars,"MAX_WARP", max_warp); max_warp = getProperty(imp_pars,"MAX_WARP", max_warp);
...@@ -6097,7 +6140,8 @@ public class VegetationLMA { ...@@ -6097,7 +6140,8 @@ public class VegetationLMA {
getProperty(imp_pars, "FIT_TERR_ELEV", fits[TVAO_TERR_ELEV]), // final boolean adjust_terr_elev, getProperty(imp_pars, "FIT_TERR_ELEV", fits[TVAO_TERR_ELEV]), // final boolean adjust_terr_elev,
getProperty(imp_pars, "FIT_TERR_ELEV_PIX", fits[TVAO_TERR_ELEV_PIX]),// final boolean adjust_terr_elev_pix, getProperty(imp_pars, "FIT_TERR_ELEV_PIX", fits[TVAO_TERR_ELEV_PIX]),// final boolean adjust_terr_elev_pix,
// getProperty(imp_pars,"TERR_ELEVATION_FULL", terr_elevation_full), // getProperty(imp_pars,"TERR_ELEVATION_FULL", terr_elevation_full),
getProperty(imp_pars, disable_names, fits_disable), // final boolean [] fit_disable, getProperty(imp_pars, disable_names, fits_disable), // final boolean [] fit_disable,
null, // fits_disable_terronly,// final boolean [] fits_disable_terronly,
getProperty(imp_pars, "REG_WEIGHTS", reg_weights), // final double reg_weights, // fraction of the total weight used for regularization getProperty(imp_pars, "REG_WEIGHTS", reg_weights), // final double reg_weights, // fraction of the total weight used for regularization
getProperty(imp_pars, "ALPHA_LOSS", alpha_loss), // final double alpha_loss, // alpha quadratic growing loss for when out of [0,1] range getProperty(imp_pars, "ALPHA_LOSS", alpha_loss), // final double alpha_loss, // alpha quadratic growing loss for when out of [0,1] range
getProperty(imp_pars, "ALPHA_LOSS_LIN", alpha_loss_lin), // final double alpha_loss_lin, // alpha linear growing loss for when out of [0,1] range and below minimal vegetation alpha getProperty(imp_pars, "ALPHA_LOSS_LIN", alpha_loss_lin), // final double alpha_loss_lin, // alpha linear growing loss for when out of [0,1] range and below minimal vegetation alpha
...@@ -6143,8 +6187,8 @@ public class VegetationLMA { ...@@ -6143,8 +6187,8 @@ public class VegetationLMA {
getProperty(imp_pars, "TTOP_REL_RAD", ttop_rel_rad), // final double ttop_rel_rad, getProperty(imp_pars, "TTOP_REL_RAD", ttop_rel_rad), // final double ttop_rel_rad,
getProperty(imp_pars, "TTOP_FRAC", ttop_frac), // final double ttop_frac, getProperty(imp_pars, "TTOP_FRAC", ttop_frac), // final double ttop_frac,
getProperty(imp_pars, "TTOP_REM_RAD", ttop_rem_rad), // final double ttop_rem_rad, getProperty(imp_pars, "TTOP_REM_RAD", ttop_rem_rad), // final double ttop_rem_rad,
getProperty(imp_pars, "TERR_ONLY_SPECIAL", terr_only_special), // final boolean terr_only_special,//true; // special sequences for terrain-only tiles /// getProperty(imp_pars, "TERR_ONLY_SPECIAL", terr_only_special), // final boolean terr_only_special,//true; // special sequences for terrain-only tiles
getProperty(imp_pars, "TERR_ONLY_PIX", terr_only_pix), // final boolean terr_only_pix, //true; // force per-pixel terrain elevation in terrain-only mode, overwrite fits_disable[TVAO_TERR_ELEV_PIX] /// getProperty(imp_pars, "TERR_ONLY_PIX", terr_only_pix), // final boolean terr_only_pix, //true; // force per-pixel terrain elevation in terrain-only mode, overwrite fits_disable[TVAO_TERR_ELEV_PIX]
getProperty(imp_pars, "BOOST_PARALLAX", boost_parallax), // final double boost_parallax, // increase weight of scene with maximal parallax relative to the reference scene getProperty(imp_pars, "BOOST_PARALLAX", boost_parallax), // final double boost_parallax, // increase weight of scene with maximal parallax relative to the reference scene
getProperty(imp_pars, "MAX_PARALLAX", max_parallax), // final double max_parallax, // do not consider maximal parallax above this (consider it a glitch) getProperty(imp_pars, "MAX_PARALLAX", max_parallax), // final double max_parallax, // do not consider maximal parallax above this (consider it a glitch)
......
...@@ -1584,9 +1584,9 @@ public class VegetationModel { ...@@ -1584,9 +1584,9 @@ public class VegetationModel {
fits_disable[i] = clt_parameters.imp.terr_fits_disable[i].clone(); 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][]; boolean [][] fits_disable_terronly = new boolean[clt_parameters.imp.terr_only_fits_disable.length][];
for (int i = 0; i < terr_only_fits_disable.length; i++) { for (int i = 0; i < fits_disable_terronly.length; i++) {
terr_only_fits_disable[i] = clt_parameters.imp.terr_only_fits_disable[i].clone(); fits_disable_terronly[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 reg_weights = clt_parameters.imp.terr_reg_weights; // 0.25; // fraction of the total weight used for regularization
...@@ -1599,8 +1599,8 @@ public class VegetationModel { ...@@ -1599,8 +1599,8 @@ public class VegetationModel {
int last_series = clt_parameters.imp.terr_last_series; // -1; // 100; int last_series = clt_parameters.imp.terr_last_series; // -1; // 100;
if (last_series < 0) last_series = num_iters.length - 1; if (last_series < 0) last_series = num_iters.length - 1;
boolean terr_only_special = clt_parameters.imp.terr_only_special; // true; // special sequences for terrain-only tiles /// boolean terr_only_special = clt_parameters.imp.terr_only_special; // true; // special sequences for terrain-only tiles
boolean terr_only_pix = clt_parameters.imp.terr_only_pix; // true; // force per-pixel terrain elevation in terrain-only mode, overwrite fits_disable[TVAO_TERR_ELEV_PIX] /// boolean terr_only_pix = clt_parameters.imp.terr_only_pix; // true; // force per-pixel terrain elevation in terrain-only mode, overwrite fits_disable[TVAO_TERR_ELEV_PIX]
int terr_only_series = clt_parameters.imp.terr_only_series; // -1; // similar to terr_last_series but for terrain-only mode (<0 - length of terr_only_num_iters) int terr_only_series = clt_parameters.imp.terr_only_series; // -1; // similar to terr_last_series but for terrain-only mode (<0 - length of terr_only_num_iters)
int [] terr_only_num_iters=clt_parameters.imp.terr_only_num_iters; // {25}; // number of iterations int [] terr_only_num_iters=clt_parameters.imp.terr_only_num_iters; // {25}; // number of iterations
if (terr_only_series < 0) terr_only_series = terr_only_num_iters.length - 1; if (terr_only_series < 0) terr_only_series = terr_only_num_iters.length - 1;
...@@ -2143,7 +2143,8 @@ public class VegetationModel { ...@@ -2143,7 +2143,8 @@ public class VegetationModel {
fit_elevations, // final boolean adjust_elevations, fit_elevations, // final boolean adjust_elevations,
fit_terr_elev, // final boolean fit_terr_elev, fit_terr_elev, // final boolean fit_terr_elev,
fit_terr_elev_pix, // final boolean fit_terr_elev_pix, fit_terr_elev_pix, // final boolean fit_terr_elev_pix,
thisOrLast(step_restore, fits_disable), // fits_disables[0], // final boolean [] fit_disable, thisOrLast(step_restore, fits_disable), // fits_disables[0], // final boolean [] fit_disable,
thisOrLast(step_restore, fits_disable_terronly),// final boolean [] fits_disable_terronly,
reg_weights, // final double reg_weights, // fraction of the total weight used for regularization reg_weights, // final double reg_weights, // fraction of the total weight used for regularization
alpha_loss, // final double alpha_loss, // alpha quadratic growing loss for when out of [0,1] range alpha_loss, // final double alpha_loss, // alpha quadratic growing loss for when out of [0,1] range
alpha_loss_lin, // final double alpha_loss_lin, // alpha linear growing loss for when out of [0,1] range and below minimal vegetation alpha alpha_loss_lin, // final double alpha_loss_lin, // alpha linear growing loss for when out of [0,1] range and below minimal vegetation alpha
...@@ -2190,8 +2191,8 @@ public class VegetationModel { ...@@ -2190,8 +2191,8 @@ public class VegetationModel {
ttop_rel_rad, // final double ttop_rel_rad, // 0.25; // Relative (to the top height) sample ring radius ttop_rel_rad, // final double ttop_rel_rad, // 0.25; // Relative (to the top height) sample ring radius
ttop_frac, // final double ttop_frac, // 0.5; // Minimal fraction of the ring pixels below sample level ttop_frac, // final double ttop_frac, // 0.5; // Minimal fraction of the ring pixels below sample level
ttop_rem_rad, // final double ttop_rem_rad, // 0.25; // Relative (to the top height) remove transparency radius ttop_rem_rad, // final double ttop_rem_rad, // 0.25; // Relative (to the top height) remove transparency radius
terr_only_special,// final boolean terr_only_special,//true; // special sequences for terrain-only tiles /// terr_only_special,// final boolean terr_only_special,//true; // special sequences for terrain-only tiles
terr_only_pix, // final boolean terr_only_pix, //true; // force per-pixel terrain elevation in terrain-only mode, overwrite fits_disable[TVAO_TERR_ELEV_PIX] /// terr_only_pix, // final boolean terr_only_pix, //true; // force per-pixel terrain elevation in terrain-only mode, overwrite fits_disable[TVAO_TERR_ELEV_PIX]
boost_parallax, // final double boost_parallax, // increase weight of scene with maximal parallax relative to the reference scene 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) max_parallax, //final double max_parallax, // do not consider maximal parallax above this (consider it a glitch)
debugLevel, // final int debugLevel); debugLevel, // final int debugLevel);
...@@ -2204,7 +2205,7 @@ public class VegetationModel { ...@@ -2204,7 +2205,7 @@ public class VegetationModel {
continue; continue;
} }
/// Handle terrain-only tiles /// Handle terrain-only tiles
if ((vegetationLMA.getWoiVeg() == null) && terr_only_special) { if (vegetationLMA.getWoiVeg() == null) {// && terr_only_special) {
last_series = terr_only_series; last_series = terr_only_series;
num_iters = terr_only_num_iters; num_iters = terr_only_num_iters;
} }
...@@ -2329,9 +2330,13 @@ public class VegetationModel { ...@@ -2329,9 +2330,13 @@ public class VegetationModel {
} }
step_restore++; step_restore++;
for (; step_restore <= last_series; step_restore++) { for (; step_restore <= last_series; step_restore++) {
// vegetationLMA.fits_disable[VegetationLMA.TVAO_ELEVATION] = fits_disable[step_restore][VegetationLMA.TVAO_ELEVATION]; for (int i = 0; i < VegetationLMA.TVAO_TYPES; i++) {
vegetationLMA.fits_disable[VegetationLMA.TVAO_ELEVATION] =thisOrLast(step_restore,fits_disable)[VegetationLMA.TVAO_ELEVATION]; vegetationLMA.fits_disable[i] = thisOrLast(step_restore,fits_disable)[i];
vegetationLMA.fits_disable[VegetationLMA.TVAO_TERR_ELEV] =thisOrLast(step_restore,fits_disable)[VegetationLMA.TVAO_TERR_ELEV]; }
/// vegetationLMA.fits_disable[VegetationLMA.TVAO_ELEVATION] = thisOrLast(step_restore,fits_disable)[VegetationLMA.TVAO_ELEVATION];
/// vegetationLMA.fits_disable[VegetationLMA.TVAO_TERR_ELEV] = thisOrLast(step_restore,fits_disable)[VegetationLMA.TVAO_TERR_ELEV];
/// vegetationLMA.fits_disable[VegetationLMA.TVAO_TERR_ELEV_PIX] =thisOrLast(step_restore,fits_disable)[VegetationLMA.TVAO_TERR_ELEV_PIX];
vegetationLMA.fits_disable[VegetationLMA.TVAO_TERR_ELEV] |= !vegetationLMA.fits_disable[VegetationLMA.TVAO_TERR_ELEV_PIX];
if (thisOrLast(step_restore,recalc_weights)) { if (thisOrLast(step_restore,recalc_weights)) {
System.out.println ("---- Recalculating weights from transparency"); System.out.println ("---- Recalculating weights from transparency");
String dbg_title= (!tile_woi && (debugLevel > -2)) ? ("transparency_"+step_restore) : null; String dbg_title= (!tile_woi && (debugLevel > -2)) ? ("transparency_"+step_restore) : null;
......
...@@ -4,10 +4,14 @@ import java.awt.Rectangle; ...@@ -4,10 +4,14 @@ import java.awt.Rectangle;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import com.elphel.imagej.common.GenericJTabbedDialog;
import com.elphel.imagej.common.ShowDoubleFloatArrays; import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.tileprocessor.ImageDtt; import com.elphel.imagej.tileprocessor.ImageDtt;
import com.elphel.imagej.tileprocessor.QuadCLT; import com.elphel.imagej.tileprocessor.QuadCLT;
import ij.ImagePlus;
import ij.gui.GenericDialog;
public class VegetationSegment { public class VegetationSegment {
public Rectangle woi_max; public Rectangle woi_max;
public Rectangle woi; public Rectangle woi;
...@@ -247,178 +251,6 @@ public class VegetationSegment { ...@@ -247,178 +251,6 @@ public class VegetationSegment {
result_titles); result_titles);
// Combine offsets per scene
/*
double [][] combined_offsets = new double [num_scenes][full_length];
String [] titles_scenes = new String [num_scenes];
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
double [] sw = new double [full_length];
for (int nscene = ai.getAndIncrement(); nscene < num_scenes; nscene = ai.getAndIncrement()) {
titles_scenes[nscene] = "scene "+nscene;
double [] swd = combined_offsets[nscene];
Arrays.fill(sw, 0);
for (int ns = 0; ns < segments.length; ns++) {
Rectangle woi_veg = segments[ns].woi;
int woi_length = woi_veg.width*woi_veg.height;
double scene_offset = segments[ns].scene_offsets[nscene];
if (!Double.isNaN(scene_offset)) {
double [] wnd = overlapCosineWindow (woi, width);
for (int windx = 0; windx < woi_length; windx++) {
int x = windx % woi_veg.width + woi_veg.x;
int y = windx / woi_veg.width + woi_veg.y;
int indx = x + y * full.width;
for (int t = 0; t < preview_data.length; t++) {
double w = wnd[windx];
sw [indx] += w;
swd[indx] += w * scene_offset ;
}
}
}
}
(new DoubleGaussianBlur()).blurDouble(
sw, //
full.width,
full.height,
ksigma*width, // double sigmaX,
ksigma*width, // double sigmaY,
0.01); // double accuracy)
(new DoubleGaussianBlur()).blurDouble(
swd, //
full.width,
full.height,
ksigma*width, // double sigmaX,
ksigma*width, // double sigmaY,
0.01); // double accuracy)
for (int i = 0; i < full_length; i++) {
if (sw[i] < min_sw) {
swd[i] = Double.NaN;
} else {
swd[i] /= sw[i];
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
double [][] tva = {preview_data[0][accum_indx],preview_data[1][accum_indx],preview_data[2][accum_indx]};
vegetationModel.setTVA(tva);
// new String[] {"full average", "filtered average"});
// String ref_scene = vegetationModel.reference_scene;
String render_title = "render-ro_"+render_open+"-rna_"+render_no_alpha+"-amn"+alpha_min+"-amx"+alpha_max+"-wo"+weight_opaque+"-bp"+boost_parallax+".tiff";
double [] render = renderWithAlpha(
preview_data[2][accum_indx], // final double [] alpha,
combined_offsets, // final double [][] scene_offsets, // subtract if not null
render_open, // final boolean render_open, // render open areas (no vegetation offset)
render_no_alpha, // final boolean render_no_alpha, // render where no opacity is available
alpha_min, // final double alpha_min, // below - completely transparent vegetation
alpha_max, // final double alpha_max, // above - completely opaque
weight_opaque, // final double weight_opaque, // render through completely opaque vegetation
boost_parallax, // final double boost_parallax) { // increase weights of scenes with high parallax relative to the reference one
max_parallax); // final double max_parallax)
// num_exaggerate
double [][] result_renders = new double [1+num_exaggerate][];
String [] result_titles = new String [result_renders.length];
result_titles[0] = "full average";
result_titles[1] = "filtered average";
result_renders[0] = terrain_average;
result_renders[1] = render;
for (int n = 2; n <= num_exaggerate; n++) {
result_titles[n]="exaggerate x "+n;
result_renders[n] = new double [full_length];
for (int i = 0; i < full_length; i++) {
result_renders[n][i] = terrain_average[i] + n * (render[i] - terrain_average[i]);
}
}
ShowDoubleFloatArrays.showArrays(
combined_offsets,
full.width,
full.height,
true,
ref_scene+"-scene_offsets",
titles_scenes);
ShowDoubleFloatArrays.showArrays(
result_renders,
full.width,
full.height,
true,
ref_scene+"-"+render_title,
result_titles);
String [] synt_titles = {"render","synthetic", "synt_terrain", "synt vegetation","masked render", "render"};
final double [][][] synt_data = new double [synt_titles.length][num_scenes][];
final double terrain_max = alpha_min;
final double vegetation_min = 0.5; // alpha_max;
String synt_name = "synthetic-terr"+terrain_max+"-veg"+vegetation_min;
synt_data[0] = terrain_rendered;
synt_data[5] = terrain_rendered;
double [][][] synt_tv= renderSynthetic(
preview_data[2][accum_indx], // final double [] alpha,
combined_offsets, // final double [][] scene_offsets, // subtract if not null
terrain_max, // final double terrain_max, // below - terrain is visible
vegetation_min, // final double vegetation_min, // above - vegetation is visible
boost_parallax, // final double boost_parallax, // increase weights of scenes with high parallax relative to the reference one
max_parallax); //final double max_parallax) {
synt_data[2] = synt_tv[0];
synt_data[3] = synt_tv[1];
// for (int nscene = 0; nscene < num_scenes; nscene++) { // use threads
// synt_data[1][nscene] = synt_tv[0][nscene].clone();
// synt_data[4][nscene] = terrain_rendered[nscene].clone();
// double [] veg_scene = synt_tv[1][nscene];
// for (int i = 0; i < veg_scene.length; i++) {
// if (!Double.isNaN(veg_scene[i])) {
// synt_data[1][nscene][i] = veg_scene[i];
// synt_data[4][nscene][i] = Double.NaN;
// }
// }
// }
ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nscene = ai.getAndIncrement(); nscene < num_scenes; nscene = ai.getAndIncrement()) {
synt_data[1][nscene] = synt_tv[0][nscene].clone();
synt_data[4][nscene] = terrain_rendered[nscene].clone();
double [] veg_scene = synt_tv[1][nscene];
for (int i = 0; i < veg_scene.length; i++) {
if (!Double.isNaN(veg_scene[i])) {
synt_data[1][nscene][i] = veg_scene[i];
synt_data[4][nscene][i] = Double.NaN;
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
ShowDoubleFloatArrays.showArraysHyperstack(
synt_data, // double[][][] pixels,
full.width, // int width,
ref_scene+"-"+synt_name, // String title, "time_derivs-rt"+diff_time_rt+"-rxy"+diff_time_rxy,
titles_scenes, // String [] titles, // all slices*frames titles or just slice titles or null
synt_titles, // String [] frame_titles, // frame titles or null
true); // boolean show)
*/
return; return;
} }
...@@ -554,5 +386,67 @@ public class VegetationSegment { ...@@ -554,5 +386,67 @@ public class VegetationSegment {
ImageDtt.startAndJoin(threads); ImageDtt.startAndJoin(threads);
return normalized; return normalized;
} }
public static ImagePlus generateSineTarget() {
int width = 1024;
int height = 1024;
double period_hor = 0.3333; // fraction of width - 1.0 single horizontal period
double period_vert = 0.3333; // fraction of height - 1.0 single vertical period
double phase_hor = 0; // phase at left edge as fraction of 2*PI (0.25 - 90 degree shift)
double phase_vert= 0;// phase at top edge as fraction of 2*PI (0.25 - 90 degree shift)
GenericJTabbedDialog gd = new GenericJTabbedDialog("Set CLT parameters",600,250);
gd.addNumericField("Width", width, 0,4,"pix","Image width." );
gd.addNumericField("Height", width, 0,4,"pix","Image height." );
gd.addNumericField("Horizontal period",period_hor, 5,8,"", "Horisontal period (1.0 - one full period, 0.2 - two full periods)." );
gd.addNumericField("Vertical period", period_vert,5,8,"", "Vertical period (1.0 - one full period, 0.2 - two full periods)." );
gd.addNumericField("Horizontal phase", phase_hor, 5,8,"", "Horisontal phase at left edge (1.0 - 2*PI, 0.25 - 90 degrees)." );
gd.addNumericField("Vertical phase", phase_vert, 5,8,"", "Vertical phase at top edge (1.0 - 2*PI, 0.25 - 90 degrees)." );
gd.showDialog();
if (gd.wasCanceled()) return null;
width = (int) gd.getNextNumber();
height = (int) gd.getNextNumber();
period_hor = gd.getNextNumber(); // fraction of width - 1.0 single horizontal period
period_vert = gd.getNextNumber(); // fraction of height - 1.0 single vertical period
phase_hor = gd.getNextNumber(); // phase at left edge as fraction of 2*PI (0.25 - 90 degree shift)
phase_vert= gd.getNextNumber(); // phase at top edge as fraction of 2*PI (0.25 - 90 degree shift)
double [] data = generateSineTarget(
width, // int width,
height, // int height,
period_hor, // double period_hor, // fraction of width - 1.0 single horizontal period
period_vert, //double period_vert, // fraction of height - 1.0 single vertical period
phase_hor, // double phase_hor, // phase at left edge as fraction of 2*PI (0.25 - 90 degree shift)
phase_vert); // double phase_vert) {// phase at top edge as fraction of 2*PI (0.25 - 90 degree shift)
String title = "pattern_perx"+period_hor+"_pery"+period_vert+"_phx"+phase_hor+"_phy"+phase_vert;
ImagePlus imp = ShowDoubleFloatArrays.makeArrays(
data, // double[] pixels,
width, // int width,
height, // int height,
title); // String title);
imp.getProcessor().resetMinAndMax();
imp.show();
return imp;
}
public static double [] generateSineTarget(
int width,
int height,
double period_hor, // fraction of width - 1.0 single horizontal period
double period_vert, // fraction of height - 1.0 single vertical period
double phase_hor, // phase at left edge as fraction of 2*PI (0.25 - 90 degree shift)
double phase_vert) {// phase at top edge as fraction of 2*PI (0.25 - 90 degree shift)
double [] data = new double[width*height];
double [] vx= new double [width];
for (int x = 0; x <width; x++) {
vx[x] = Math.sin(2*Math.PI*((x / (period_hor*width)) + phase_hor));
}
for (int y = 0; y < height; y++) {
double vy = Math.sin(2*Math.PI*((y / (period_vert * height)) + phase_vert));
for (int x = 0; x <width; x++) {
data [y*width+x] = vx[x] * vy;
}
}
return data;
}
} }
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