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

Added terrain correction (minimizing average difference between images

and model)
parent 85bebb08
...@@ -796,6 +796,7 @@ min_str_neib_fpn 0.35 ...@@ -796,6 +796,7 @@ min_str_neib_fpn 0.35
public double terr_boost_parallax = 3.0; // public double terr_boost_parallax = 3.0; //
public double terr_max_parallax = 10.0; // parallax limit when evaluating boost parallax public double terr_max_parallax = 10.0; // parallax limit when evaluating boost parallax
public double terr_hifreq_weight = 10.0; // 22.5; // 0 - do not use high-freq. Relative weight of laplacian components differfences to the DC ones public double terr_hifreq_weight = 10.0; // 22.5; // 0 - do not use high-freq. Relative weight of laplacian components differfences to the DC ones
public double terr_terr_corr = 1.0; // relative weight of average mismatch between images and model (terrain corrections)
public double terr_reg_weights = 0.25; // fraction of the total weight used for regularization public double terr_reg_weights = 0.25; // fraction of the total weight used for regularization
public double terr_lambda = 5.0; // public double terr_lambda = 5.0; //
public double terr_lambda_scale_good = 0.5; public double terr_lambda_scale_good = 0.5;
...@@ -2068,6 +2069,7 @@ min_str_neib_fpn 0.35 ...@@ -2068,6 +2069,7 @@ min_str_neib_fpn 0.35
gd.addNumericField("Boost parallax", terr_boost_parallax, 5,7,"", "Increase weight of scenes that have high parallax to the reference one."); gd.addNumericField("Boost parallax", terr_boost_parallax, 5,7,"", "Increase weight of scenes that have high parallax to the reference one.");
gd.addNumericField("Limit parallax", terr_max_parallax, 5,7,"", "Parallax limit when evaluating boost parallax."); gd.addNumericField("Limit parallax", terr_max_parallax, 5,7,"", "Parallax limit when evaluating boost parallax.");
gd.addNumericField("High freq. weight", terr_hifreq_weight, 5,7,"", "Relative weight of laplacian components differfences to the DC ones (0 - do not use)."); gd.addNumericField("High freq. weight", terr_hifreq_weight, 5,7,"", "Relative weight of laplacian components differfences to the DC ones (0 - do not use).");
gd.addNumericField("Terrain correction", terr_terr_corr, 5,7,"", "Relative weight of terrain correction (mismatch between average image and average model).");
gd.addNumericField("Losses weight", terr_reg_weights, 5,7,"", "Fraction of other losses compared to the RMSE."); gd.addNumericField("Losses weight", terr_reg_weights, 5,7,"", "Fraction of other losses compared to the RMSE.");
gd.addNumericField("Initial lambda", terr_lambda, 5,7,"", "Initial LMA lambda."); gd.addNumericField("Initial lambda", terr_lambda, 5,7,"", "Initial LMA lambda.");
...@@ -2776,6 +2778,7 @@ min_str_neib_fpn 0.35 ...@@ -2776,6 +2778,7 @@ min_str_neib_fpn 0.35
terr_boost_parallax = gd.getNextNumber();// double terr_boost_parallax = gd.getNextNumber();// double
terr_max_parallax = gd.getNextNumber();// double terr_max_parallax = gd.getNextNumber();// double
terr_hifreq_weight = gd.getNextNumber();// double terr_hifreq_weight = gd.getNextNumber();// double
terr_terr_corr = gd.getNextNumber();// double
terr_reg_weights = gd.getNextNumber();// double terr_reg_weights = gd.getNextNumber();// double
terr_lambda = gd.getNextNumber();// double terr_lambda = gd.getNextNumber();// double
terr_lambda_scale_good = gd.getNextNumber();// double terr_lambda_scale_good = gd.getNextNumber();// double
...@@ -3451,7 +3454,8 @@ min_str_neib_fpn 0.35 ...@@ -3451,7 +3454,8 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"terr_boost_parallax", terr_boost_parallax+""); // double properties.setProperty(prefix+"terr_boost_parallax", terr_boost_parallax+""); // double
properties.setProperty(prefix+"terr_max_parallax", terr_max_parallax+""); // double properties.setProperty(prefix+"terr_max_parallax", terr_max_parallax+""); // double
properties.setProperty(prefix+"terr_hifreq_weight", terr_hifreq_weight+""); // double properties.setProperty(prefix+"terr_hifreq_weight", terr_hifreq_weight+""); // double
properties.setProperty(prefix+"terr_terr_corr", terr_terr_corr+""); // double
properties.setProperty(prefix+"terr_reg_weights", terr_reg_weights+""); // double properties.setProperty(prefix+"terr_reg_weights", terr_reg_weights+""); // double
properties.setProperty(prefix+"terr_lambda", terr_lambda+""); // double properties.setProperty(prefix+"terr_lambda", terr_lambda+""); // double
properties.setProperty(prefix+"terr_lambda_scale_good", terr_lambda_scale_good+""); // double properties.setProperty(prefix+"terr_lambda_scale_good", terr_lambda_scale_good+""); // double
...@@ -4150,8 +4154,8 @@ min_str_neib_fpn 0.35 ...@@ -4150,8 +4154,8 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"terr_boost_parallax")!= null) terr_boost_parallax=Double.parseDouble(properties.getProperty(prefix+"terr_boost_parallax")); if (properties.getProperty(prefix+"terr_boost_parallax")!= null) terr_boost_parallax=Double.parseDouble(properties.getProperty(prefix+"terr_boost_parallax"));
if (properties.getProperty(prefix+"terr_max_parallax")!= null) terr_max_parallax=Double.parseDouble(properties.getProperty(prefix+"terr_max_parallax")); if (properties.getProperty(prefix+"terr_max_parallax")!= null) terr_max_parallax=Double.parseDouble(properties.getProperty(prefix+"terr_max_parallax"));
//
if (properties.getProperty(prefix+"terr_hifreq_weight")!= null) terr_hifreq_weight=Double.parseDouble(properties.getProperty(prefix+"terr_hifreq_weight")); if (properties.getProperty(prefix+"terr_hifreq_weight")!= null) terr_hifreq_weight=Double.parseDouble(properties.getProperty(prefix+"terr_hifreq_weight"));
if (properties.getProperty(prefix+"terr_terr_corr")!= null) terr_terr_corr=Double.parseDouble(properties.getProperty(prefix+"terr_terr_corr"));
if (properties.getProperty(prefix+"terr_reg_weights")!= null) terr_reg_weights=Double.parseDouble(properties.getProperty(prefix+"terr_reg_weights")); if (properties.getProperty(prefix+"terr_reg_weights")!= null) terr_reg_weights=Double.parseDouble(properties.getProperty(prefix+"terr_reg_weights"));
if (properties.getProperty(prefix+"terr_lambda")!= null) terr_lambda=Double.parseDouble(properties.getProperty(prefix+"terr_lambda")); if (properties.getProperty(prefix+"terr_lambda")!= null) terr_lambda=Double.parseDouble(properties.getProperty(prefix+"terr_lambda"));
if (properties.getProperty(prefix+"terr_lambda_scale_good")!= null) terr_lambda_scale_good=Double.parseDouble(properties.getProperty(prefix+"terr_lambda_scale_good")); if (properties.getProperty(prefix+"terr_lambda_scale_good")!= null) terr_lambda_scale_good=Double.parseDouble(properties.getProperty(prefix+"terr_lambda_scale_good"));
...@@ -4817,6 +4821,7 @@ min_str_neib_fpn 0.35 ...@@ -4817,6 +4821,7 @@ min_str_neib_fpn 0.35
imp.terr_boost_parallax = this.terr_boost_parallax; imp.terr_boost_parallax = this.terr_boost_parallax;
imp.terr_max_parallax = this.terr_max_parallax; imp.terr_max_parallax = this.terr_max_parallax;
imp.terr_hifreq_weight = this.terr_hifreq_weight; imp.terr_hifreq_weight = this.terr_hifreq_weight;
imp.terr_terr_corr = this.terr_terr_corr;
imp.terr_reg_weights = this.terr_reg_weights; imp.terr_reg_weights = this.terr_reg_weights;
imp.terr_lambda = this.terr_lambda; imp.terr_lambda = this.terr_lambda;
imp.terr_lambda_scale_good = this.terr_lambda_scale_good; imp.terr_lambda_scale_good = this.terr_lambda_scale_good;
......
...@@ -44,16 +44,17 @@ public class VegetationLMA { ...@@ -44,16 +44,17 @@ public class VegetationLMA {
public static final int SAMPLES_Y = 0; public static final int SAMPLES_Y = 0;
public static final int SAMPLES_Y_HF = 1; public static final int SAMPLES_Y_HF = 1;
public static final int SAMPLES_SCENES = 2; public static final int SAMPLES_Y_AVG = 2;
public static final int SAMPLES_ALPHA_PULL = 3; public static final int SAMPLES_SCENES = 3;
public static final int SAMPLES_ALPHA_LPF = 4; public static final int SAMPLES_ALPHA_PULL = 4;
public static final int SAMPLES_TERRAIN_PULL = 5; public static final int SAMPLES_ALPHA_LPF = 5;
public static final int SAMPLES_TERRAIN_LPF = 6; public static final int SAMPLES_TERRAIN_PULL = 6;
public static final int SAMPLES_VEGETATION_PULL = 7; public static final int SAMPLES_TERRAIN_LPF = 7;
public static final int SAMPLES_VEGETATION_LPF = 8; public static final int SAMPLES_VEGETATION_PULL = 8;
public static final int SAMPLES_ELEVATION_PULL = 9; public static final int SAMPLES_VEGETATION_LPF = 9;
public static final int SAMPLES_ELEVATION_LPF = 10; public static final int SAMPLES_ELEVATION_PULL = 10;
public static final int SAMPLES_TOTAL = 11; // {total samples, extra_samples} public static final int SAMPLES_ELEVATION_LPF = 11;
public static final int SAMPLES_TOTAL = 12; // {total samples, extra_samples}
public static final int SAMPLES_SIZE = SAMPLES_TOTAL+1; public static final int SAMPLES_SIZE = SAMPLES_TOTAL+1;
public static final int SAMPLES_EXTRA = SAMPLES_SCENES; // start of "extra" samples public static final int SAMPLES_EXTRA = SAMPLES_SCENES; // start of "extra" samples
...@@ -116,6 +117,9 @@ public class VegetationLMA { ...@@ -116,6 +117,9 @@ public class VegetationLMA {
private int [][] y_src_hf; // subset of pointers that have all 4 neighbors private int [][] y_src_hf; // subset of pointers that have all 4 neighbors
private int [][] y_src_scene; // [scene]{start_y_src, end_y_src+1} pointers to y_src per scene private int [][] y_src_scene; // [scene]{start_y_src, end_y_src+1} pointers to y_src per scene
private int [][] y_wsrc; // [scene][windex] ysrc index for scene, windex [num_scenes][woi_length] private int [][] y_wsrc; // [scene][windex] ysrc index for scene, windex [num_scenes][woi_length]
// private double [] y_wavg; // [woi_length] - weighted average of y-values over woi
private double terrain_correction;// weight of y_wavg
private int [][] samples_pointers; // {start,length} for each samples section, for extra 3-rd is ind_pars_* private int [][] samples_pointers; // {start,length} for each samples section, for extra 3-rd is ind_pars_*
// elevation-dependent parameters, calculated once if elevations are not adjusted or each time if they are // elevation-dependent parameters, calculated once if elevations are not adjusted or each time if they are
...@@ -204,6 +208,7 @@ public class VegetationLMA { ...@@ -204,6 +208,7 @@ public class VegetationLMA {
private double elevation_pull0 = 0; // now - pull to initial elevation private double elevation_pull0 = 0; // now - pull to initial elevation
private double scenes_pull0 = 0; // pull average scene offset to 0; private double scenes_pull0 = 0; // pull average scene offset to 0;
private boolean use_scenes_pull0 = true; // derivative, set in setWeights private boolean use_scenes_pull0 = true; // derivative, set in setWeights
// private boolean use_y_avg = true; // derivative, set in setWeights
private double scale_scenes_pull = 0; // used in getFxDerivs to scale scene offsets as their weight will be reg_weights / extra_samples private double scale_scenes_pull = 0; // used in getFxDerivs to scale scene offsets as their weight will be reg_weights / extra_samples
...@@ -227,6 +232,7 @@ public class VegetationLMA { ...@@ -227,6 +232,7 @@ public class VegetationLMA {
public int debug_iter; // LMA iteration for images public int debug_iter; // LMA iteration for images
public double [][] debug_image; public double [][] debug_image;
public int [] debug_iters; public int [] debug_iters;
public double [][] debug_rms;
public static double [] debug_alpha_scales = {0, 50, 0, 10, 25, 50}; // {100,150}; public static double [] debug_alpha_scales = {0, 50, 0, 10, 25, 50}; // {100,150};
public static boolean debug_show_iter_results = false; // true; public static boolean debug_show_iter_results = false; // true;
public String debug_path = "/media/elphel/SSD3-4GB/lwir16-proc/berdich3/debug/vegetation/lma_um/"; public String debug_path = "/media/elphel/SSD3-4GB/lwir16-proc/berdich3/debug/vegetation/lma_um/";
...@@ -420,7 +426,7 @@ public class VegetationLMA { ...@@ -420,7 +426,7 @@ public class VegetationLMA {
final double elevation_radius, //Radius of elevation/vegetation influence. final double elevation_radius, //Radius of elevation/vegetation influence.
final double default_alpha, final double default_alpha,
final double hifreq_weight, // 22.5 0 - do not use high-freq. Relative weight of laplacian components final double hifreq_weight, // 22.5 0 - do not use high-freq. Relative weight of laplacian components
final double terrain_correction,
final boolean fit_terr, final boolean fit_terr,
final boolean fit_veget, final boolean fit_veget,
final boolean fit_alpha, final boolean fit_alpha,
...@@ -463,7 +469,7 @@ public class VegetationLMA { ...@@ -463,7 +469,7 @@ public class VegetationLMA {
this.terr_difference = terr_difference; this.terr_difference = terr_difference;
this.terr_pull_cold = terr_pull_cold; this.terr_pull_cold = terr_pull_cold;
this.hifreq_weight = hifreq_weight; // 22.5 0 - do not use high-freq. Relative weight of laplacian components this.hifreq_weight = hifreq_weight; // 22.5 0 - do not use high-freq. Relative weight of laplacian components
this.terrain_correction = terrain_correction;
fits = new boolean[TVAO_TYPES]; fits = new boolean[TVAO_TYPES];
fits[TVAO_TERRAIN] = fit_terr; fits[TVAO_TERRAIN] = fit_terr;
fits[TVAO_VEGETATION] = fit_veget; fits[TVAO_VEGETATION] = fit_veget;
...@@ -696,8 +702,15 @@ public class VegetationLMA { ...@@ -696,8 +702,15 @@ public class VegetationLMA {
1) ;// int gap) 1) ;// int gap)
} }
setupYVector(); //(hifreq_weight > 0)); // boolean use_hf); boolean use_terr_corr = (terrain_correction>=0); // maybe not needed
setupYVector(
use_terr_corr, // boolean use_terr_corr); //(hifreq_weight > 0)); // boolean use_hf);
scene_weights); //
/*
if (use_y_avg) {
setupYWavg(scene_weights); // double [] scene_weights);
}
*/
setupWeights( // after setupParametersIndices setupWeights( // after setupParametersIndices
scene_weights, scene_weights,
reg_weights, // final double reg_weights, reg_weights, // final double reg_weights,
...@@ -967,8 +980,14 @@ public class VegetationLMA { ...@@ -967,8 +980,14 @@ public class VegetationLMA {
save_all, // boolean save_all, save_all, // boolean save_all,
show_this, // boolean show_this, show_this, // boolean show_this,
show_all); // boolean show_all) show_all); // boolean show_all)
if ((debug_level > 4) && (samples_pointers[SAMPLES_Y_AVG][1] > 0)){
String dbg_title = "terrain_corr_fX-INITIAL";
debugTerrCorr(
fx, // double [] fx,
dbg_title); // String title)
}
} }
} }
if (debug_level > 3) { // 0) { if (debug_level > 3) { // 0) {
double delta = this.delta; // 1E-3; double delta = this.delta; // 1E-3;
...@@ -1080,10 +1099,14 @@ public class VegetationLMA { ...@@ -1080,10 +1099,14 @@ public class VegetationLMA {
save_all, // boolean save_all, save_all, // boolean save_all,
show_this, // boolean show_this, show_this, // boolean show_this,
show_all); // boolean show_all) show_all); // boolean show_all)
if ((debug_level > 4) && (samples_pointers[SAMPLES_Y_AVG][1] > 0)){
String dbg_title = "terrain_corr_fX"+debug_iter;
debugTerrCorr(
fx, // double [] fx,
dbg_title); // String title)
}
} }
} else { // worsened } else { // worsened
rslt[0] = false; rslt[0] = false;
rslt[1] = false; // do not know, caller will decide rslt[1] = false; // do not know, caller will decide
...@@ -1110,6 +1133,37 @@ public class VegetationLMA { ...@@ -1110,6 +1133,37 @@ public class VegetationLMA {
return rslt; return rslt;
} }
public void debugTerrCorr(
double [] fx,
String title) {
// String dbg_title = "terrain_corr_fX"+debug_iter;
String [] dbg_titles = {"y","fX","diff"};
double [][] dbg_img = new double [3][woi.width*woi.height];
System.arraycopy(
y_vector,
samples_pointers[SAMPLES_Y_AVG][0],
dbg_img[0],
0,
dbg_img[0].length);
System.arraycopy(
fx,
samples_pointers[SAMPLES_Y_AVG][0],
dbg_img[1],
0,
dbg_img[1].length);
for (int i = 0; i < dbg_img[2].length; i++) {
dbg_img[2][i] = dbg_img[0][i]-dbg_img[1][i];
}
ShowDoubleFloatArrays.showArrays(
dbg_img,
woi.width,
woi.height,
true,
title,
dbg_titles);
}
public String getParametersDebugTitle() { public String getParametersDebugTitle() {
// alpha_en_holes -> alpha_mm_hole = NaN; // alpha_en_holes -> alpha_mm_hole = NaN;
// hifreq_weight // hifreq_weight
...@@ -1145,8 +1199,12 @@ public class VegetationLMA { ...@@ -1145,8 +1199,12 @@ public class VegetationLMA {
if (debug_iters == null) { if (debug_iters == null) {
debug_iters = new int [debug_image.length]; debug_iters = new int [debug_image.length];
} }
if (debug_rms == null) {
debug_rms = new double [debug_image.length][];
}
debug_iters[debug_index] = debug_iter; debug_iters[debug_index] = debug_iter;
title += "-"+debug_iter+ "_"+debug_index; debug_rms[debug_index] = last_rms.clone();
title += "-"+debug_iter+ "_"+debug_index+String.format("_rms%8.5f_rms-pure%8.5f", last_rms[0],last_rms[1]);
debug_image[debug_index++] = debug_img; debug_image[debug_index++] = debug_img;
} }
...@@ -1162,6 +1220,9 @@ public class VegetationLMA { ...@@ -1162,6 +1220,9 @@ public class VegetationLMA {
String [] titles = new String[debug_index]; String [] titles = new String[debug_index];
for (int i = 0; i < debug_index; i++) { for (int i = 0; i < debug_index; i++) {
titles[i] = "iter"+debug_iters[i]; titles[i] = "iter"+debug_iters[i];
if ((debug_rms != null) && (debug_rms[i] != null)) {
titles[i]+=String.format("_rms%8.5f_rms-pure%8.5f", debug_rms[i][0], debug_rms[i][1]);
}
dbg_img[i] = debug_image[i]; dbg_img[i] = debug_image[i];
} }
if (show_all) { if (show_all) {
...@@ -1862,58 +1923,7 @@ public class VegetationLMA { ...@@ -1862,58 +1923,7 @@ public class VegetationLMA {
return pars_with_neibs; return pars_with_neibs;
} }
private static int [][] addNeighborsLists_wrong(
final int [][] pars,
final int [][] par_neibs) {
final int [][] pars_with_neibs = new int [pars.length][];
if (pars.length != par_neibs.length) {
throw new IllegalArgumentException("addNeighborsLists(): pars.length="+pars.length+
" != par_neibs.length ="+par_neibs.length);
}
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
HashSet<Integer> this_par_set = new HashSet<Integer>(); //related parameters to nPar
for (int nPar = ai.getAndIncrement(); nPar < par_neibs.length; nPar = ai.getAndIncrement()){
// if ((nPar==84) || (nPar==1373)) {
// System.out.println("addNeighborsLists() nPar="+nPar);
// }
if ((par_neibs[nPar] != null) && (par_neibs[nPar].length > 0)) {
this_par_set.clear();
for (int neib_par: par_neibs[nPar]) {
int [] neib_pars = pars[neib_par]; // should all be >= 0
if (neib_pars != null) {
for (int par: neib_pars) {
this_par_set.add(par);
}
}
}
if (!this_par_set.isEmpty()) { // anything to add - probably always
if (pars[nPar] != null) { // adding it's own parameters
for (int par: pars[nPar]) {
this_par_set.add(par);
}
}
//https://stackoverflow.com/questions/2451184/how-can-i-convert-a-java-hashsetinteger-to-a-primitive-int-array
int [] pars_arr = this_par_set.stream().mapToInt(Integer::intValue).toArray();
Arrays.sort(pars_arr); // optional
pars_with_neibs[nPar] = pars_arr;
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return pars_with_neibs;
}
public static boolean [][] listsToPivot( public static boolean [][] listsToPivot(
final int [][] par_lists){ final int [][] par_lists){
final boolean [][] pivot = new boolean [par_lists.length][par_lists.length]; final boolean [][] pivot = new boolean [par_lists.length][par_lists.length];
...@@ -2080,7 +2090,7 @@ public class VegetationLMA { ...@@ -2080,7 +2090,7 @@ public class VegetationLMA {
final int debug_level) { final int debug_level) {
final boolean dbg1 = (debug_level > 4); final boolean dbg1 = (debug_level > 4);
// final int dbg_y_indx = 900; // and multiples ? // final int dbg_y_indx = 900; // and multiples ?
final int dbg_npar = 900; // first vegetation final int dbg_npar = -900; // first vegetation
setupElevationLMA( // return pivot? setupElevationLMA( // return pivot?
vector, // final double [] vector, vector, // final double [] vector,
...@@ -2531,8 +2541,68 @@ public class VegetationLMA { ...@@ -2531,8 +2541,68 @@ public class VegetationLMA {
// ind_next++; // ind_next++;
} // if (use_scenes_pull0) { // single sample after differences } // if (use_scenes_pull0) { // single sample after differences
if (samples_pointers[SAMPLES_Y_AVG][1]>0) { //
final double [][] fX_avg_thread = new double [threads.length][woi_length];
final double [][][] jt_avg_thread = (jt != null) ? new double [threads.length][jt.length][woi_length] : null;
/*
final double [] norm_scene_weights = new double [num_scenes];
double sw = 0;
for (int nscene = 0; nscene < num_scenes; nscene++) if (valid_scenes[nscene]) {
sw += scene_weights[nscene];
}
for (int nscene = 0; nscene < num_scenes; nscene++) if (valid_scenes[nscene]) {
norm_scene_weights[nscene] = scene_weights[nscene]/sw;
}
*/
final boolean debug_print = (debug_level >100);
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 yIndx = ai.getAndIncrement(); yIndx < y_src.length; yIndx = ai.getAndIncrement()){
int nscene = y_src[yIndx][YSRC_SCENE];
int indx = y_src[yIndx][YSRC_FINDEX];
int windx = getWindexFromFindex(indx);
if (debug_print && (windx == 0)) {
System.out.println("yIndx="+yIndx+", nscene="+nscene+", indx="+indx+", windx="+windx);
}
double w = scene_weights[nscene]; // norm_scene_weights[nscene];
fX_avg_thread[nthread][windx] += w * fX[yIndx]; // already calculated
if (jt_avg_thread != null) {
HashSet<Integer> pars_contribs = param_contribs.get(windx); // contributors before laplacians
for (int np: pars_contribs) {
jt_avg_thread[nthread][np][windx] += w * jt[np][yIndx];
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int wIndx = ai.getAndIncrement(); wIndx < woi_length; wIndx = ai.getAndIncrement()){
int nx = samples_pointers[SAMPLES_Y_AVG][0]+wIndx;
for (int nthread = 0; nthread < threads.length; nthread++) {
fX[nx] += fX_avg_thread[nthread][wIndx];
if (jt_avg_thread != null) {
HashSet<Integer> pars_contribs = param_contribs.get(wIndx); // contributors before laplacians
for (int np: pars_contribs) {
jt[np][nx] += jt_avg_thread[nthread][np][wIndx];
}
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
}
// splitting alpha_lpf from alpha_loss+alpha_push // splitting alpha_lpf from alpha_loss+alpha_push
// No need here to add contributors as this should not depend on any other parameters // No need here to add contributors as this should not depend on any other parameters
if (samples_pointers[SAMPLES_ALPHA_PULL][1] > 0) { // fits[TVAO_ALPHA] && ((alpha_loss > 0) || (alpha_push > 0))) { if (samples_pointers[SAMPLES_ALPHA_PULL][1] > 0) { // fits[TVAO_ALPHA] && ((alpha_loss > 0) || (alpha_push > 0))) {
...@@ -3245,27 +3315,29 @@ public class VegetationLMA { ...@@ -3245,27 +3315,29 @@ public class VegetationLMA {
private int [][] getParamDebugIndices( private int [][] getParamDebugIndices(
boolean extra, boolean extra,
int gap) { int gap) {
int num_img_cols = 4; int num_img_cols = 5; // 4;
int woi_width4=woi_veg.width * 4 + 3 * gap; int num_first_row_cols = 4;
int num_scene_rows = (int) Math.ceil(1.0 * num_scenes / woi_width4); // some scenes have NaN // int woi_width4=woi_veg.width * 4 + 3 * gap;
int woi_width= woi_veg.width * num_img_cols + (num_img_cols-1) * gap;
int num_scene_rows = (int) Math.ceil(1.0 * num_scenes / woi_width); // some scenes have NaN
int num_extra_rows = extra ? (2 *woi_veg.height + 3 * gap) : 0; int num_extra_rows = extra ? (2 *woi_veg.height + 3 * gap) : 0;
int main_hight = woi_veg.height + gap+ num_scene_rows; int main_hight = woi_veg.height + gap+ num_scene_rows;
int extra_start = main_hight+gap; int extra_start = main_hight+gap;
int [][] indices = new int [woi_width4 * (main_hight + num_extra_rows)][2]; int [][] indices = new int [woi_width * (main_hight + num_extra_rows)][2];
for (int i = 0; i < indices.length; i++) { for (int i = 0; i < indices.length; i++) {
indices[i][0] = -1; // unused indices[i][0] = -1; // unused
} }
for (int h = 0; h < woi_veg.height; h++) { for (int h = 0; h < woi_veg.height; h++) {
for (int n = 0; n < num_img_cols; n++) { for (int n = 0; n < num_first_row_cols; n++) {
for (int w = 0; w < woi_veg.width; w++) { for (int w = 0; w < woi_veg.width; w++) {
int indx = (h + woi_veg.y) * full.width + (w + woi_veg.x); int indx = (h + woi_veg.y) * full.width + (w + woi_veg.x);
int pindx = par_index[SAVE_TYPES[n]][indx]; int pindx = par_index[SAVE_TYPES[n]][indx];
if (pindx >= 0) { if (pindx >= 0) {
indices [(h * woi_width4) + (woi_veg.width + gap) * n + w][0] = 0; indices [(h * woi_width) + (woi_veg.width + gap) * n + w][0] = 0;
indices [(h * woi_width4) + (woi_veg.width + gap) * n + w][1] = pindx; indices [(h * woi_width) + (woi_veg.width + gap) * n + w][1] = pindx;
} else { } else {
indices [(h * woi_width4) + (woi_veg.width + gap) * n + w][0] = SAVE_TYPES[n] + 2; // 1; // type + 1 indices [(h * woi_width) + (woi_veg.width + gap) * n + w][0] = SAVE_TYPES[n] + 2; // 1; // type + 1
indices [(h * woi_width4) + (woi_veg.width + gap) * n + w][1] = indx; indices [(h * woi_width) + (woi_veg.width + gap) * n + w][1] = indx;
} }
} }
} }
...@@ -3273,11 +3345,11 @@ public class VegetationLMA { ...@@ -3273,11 +3345,11 @@ public class VegetationLMA {
for (int i = 0; i < par_index[TVAO_SCENE_OFFSET].length; i++) { for (int i = 0; i < par_index[TVAO_SCENE_OFFSET].length; i++) {
int pindx = par_index[TVAO_SCENE_OFFSET][i]; // some will be -1 int pindx = par_index[TVAO_SCENE_OFFSET][i]; // some will be -1
if (pindx >= 0) { if (pindx >= 0) {
indices [((woi_veg.height + gap) * woi_width4) + i][0] = 0; indices [((woi_veg.height + gap) * woi_width) + i][0] = 0;
indices [((woi_veg.height + gap) * woi_width4) + i][1] = pindx; indices [((woi_veg.height + gap) * woi_width) + i][1] = pindx;
} else { } else {
indices [((woi_veg.height + gap) * woi_width4) + i][0] = TVAO_SCENE_OFFSET + 2; // type + 1 indices [((woi_veg.height + gap) * woi_width) + i][0] = TVAO_SCENE_OFFSET + 2; // type + 1
indices [((woi_veg.height + gap) * woi_width4) + i][1] = i; indices [((woi_veg.height + gap) * woi_width) + i][1] = i;
} }
} }
// extra images: // extra images:
...@@ -3287,29 +3359,31 @@ public class VegetationLMA { ...@@ -3287,29 +3359,31 @@ public class VegetationLMA {
// second row: // second row:
// terrain, vegetation, alpha, elevation lpf // terrain, vegetation, alpha, elevation lpf
int [][] sample_types = { int [][] sample_types = {
{SAMPLES_TERRAIN_PULL, SAMPLES_VEGETATION_PULL, SAMPLES_ALPHA_PULL,SAMPLES_ELEVATION_PULL}, {SAMPLES_TERRAIN_PULL, SAMPLES_VEGETATION_PULL, SAMPLES_ALPHA_PULL,SAMPLES_ELEVATION_PULL, SAMPLES_Y_AVG},
{SAMPLES_TERRAIN_LPF, SAMPLES_VEGETATION_LPF, SAMPLES_ALPHA_LPF, SAMPLES_ELEVATION_LPF}}; {SAMPLES_TERRAIN_LPF, SAMPLES_VEGETATION_LPF, SAMPLES_ALPHA_LPF, SAMPLES_ELEVATION_LPF, -1}};
if (extra) { if (extra) {
for (int pull_lpf = 0; pull_lpf < 2; pull_lpf++) { for (int pull_lpf = 0; pull_lpf < 2; pull_lpf++) {
int row0 = extra_start + pull_lpf * (woi_veg.height + gap); int row0 = extra_start + pull_lpf * (woi_veg.height + gap);
for (int type = 0; type < num_img_cols; type++) { for (int type = 0; type < num_img_cols; type++) {
int col0 = (woi_veg.width + gap) * type; int col0 = (woi_veg.width + gap) * type;
int sample_type = sample_types[pull_lpf][type]; // lpf is always next after int sample_type = sample_types[pull_lpf][type]; // lpf is always next after
if (samples_pointers[sample_type][1] > 0) { // th if (sample_type >= 0) {
for (int n = 0; n < samples_pointers[sample_type][1]; n++) { if (samples_pointers[sample_type][1] > 0) { // th
int nx = n + samples_pointers[sample_type][0]; // fX index for (int n = 0; n < samples_pointers[sample_type][1]; n++) {
int np = n + samples_pointers[sample_type][2]; // full parameter index int nx = n + samples_pointers[sample_type][0]; // fX index
int findx = par_rindex[np][1]; int np = n + samples_pointers[sample_type][2]; // full parameter index
int wvx = findx % full.width - woi_veg.x; int findx = par_rindex[np][1];
int wvy = findx / full.width - woi_veg.y; int wvx = findx % full.width - woi_veg.x;
if ((wvx >=0) && (wvx < woi_veg.width) && (wvy >=0) && (wvx < woi_veg.height)) { int wvy = findx / full.width - woi_veg.y;
int row = row0 + wvy; if ((wvx >=0) && (wvx < woi_veg.width) && (wvy >=0) && (wvx < woi_veg.height)) {
int col = col0 + wvx; int row = row0 + wvy;
int indx = row * woi_width4 + col; int col = col0 + wvx;
indices [indx][0] = 1; int indx = row * woi_width + col;
indices [indx][1] = nx; indices [indx][0] = 1;
} else { indices [indx][1] = nx;
System.out.println("getParamDebugIndices() BUG: n="+n+" nx="+nx+" np="+np+" wvx="+wvx+", wvy="+wvy); } else {
System.out.println("getParamDebugIndices() BUG: n="+n+" nx="+nx+" np="+np+" wvx="+wvx+", wvy="+wvy);
}
} }
} }
} }
...@@ -3435,9 +3509,13 @@ public class VegetationLMA { ...@@ -3435,9 +3509,13 @@ public class VegetationLMA {
int [][] indices = getParamDebugIndices ( int [][] indices = getParamDebugIndices (
extra, // boolean extra, extra, // boolean extra,
gap); gap);
int num_img_cols = 5; // 4;
// int num_first_row_cols = 4;
int woi_width= woi_veg.width * num_img_cols + (num_img_cols-1) * gap;
// int woi_width3=woi.width*3 + 2 * gap; // int woi_width3=woi.width*3 + 2 * gap;
int woi_width4=woi_veg.width*4 + 3 * gap; // int woi_width4=woi_veg.width*4 + 3 * gap;
int height = indices.length / woi_width4; // int woi_width5=woi_veg.width*5 + 4 * gap;
int height = indices.length / woi_width;
int num_extra_rows = extra ? (2 *woi_veg.height + 3 * gap) : 0; int num_extra_rows = extra ? (2 *woi_veg.height + 3 * gap) : 0;
int extra_start_row = height - num_extra_rows; int extra_start_row = height - num_extra_rows;
double [] dbg_img = new double [indices.length]; double [] dbg_img = new double [indices.length];
...@@ -3463,8 +3541,8 @@ public class VegetationLMA { ...@@ -3463,8 +3541,8 @@ public class VegetationLMA {
} }
if (!Double.isNaN(dbg_img[i])) { if (!Double.isNaN(dbg_img[i])) {
// scale alpha for the same image // scale alpha for the same image
int w = i % woi_width4; int w = i % woi_width;
int h = i / woi_width4; int h = i / woi_width;
int nsub = w / (woi_veg.width + gap); int nsub = w / (woi_veg.width + gap);
if (h < woi_veg.height) { if (h < woi_veg.height) {
if (nsub == 2) { // alpha if (nsub == 2) { // alpha
...@@ -3487,14 +3565,14 @@ public class VegetationLMA { ...@@ -3487,14 +3565,14 @@ public class VegetationLMA {
} }
} }
if (wh != null) { if (wh != null) {
wh[0] = woi_width4; wh[0] = woi_width;
wh[1] = indices.length/woi_width4; wh[1] = indices.length/woi_width;
} }
if (title != null) { if (title != null) {
ShowDoubleFloatArrays.showArrays( ShowDoubleFloatArrays.showArrays(
dbg_img, dbg_img,
woi_width4, woi_width,
indices.length/woi_width4, indices.length/woi_width,
title); title);
} }
return dbg_img; return dbg_img;
...@@ -4307,11 +4385,16 @@ public class VegetationLMA { ...@@ -4307,11 +4385,16 @@ public class VegetationLMA {
throw new IllegalArgumentException("Could not read "+path); throw new IllegalArgumentException("Could not read "+path);
} }
// int woi_width3=woi.width*3 + 2 * gap; // int woi_width3=woi.width*3 + 2 * gap;
int woi_width4=woi_veg.width*4 + 3 * gap; // int woi_width4=woi_veg.width*4 + 3 * gap;
int height = indices.length/woi_width4; int num_img_cols = 5; // 4;
if ((woi_width4 != imp_pars.getWidth()) || (height != imp_pars.getHeight())) { int woi_width= woi_veg.width * num_img_cols + (num_img_cols-1) * gap;
int height = indices.length/woi_width;
if ((woi_width != imp_pars.getWidth()) || (height != imp_pars.getHeight())) {
throw new IllegalArgumentException("Read image size does not match required: ("+imp_pars.getWidth()+"x"+imp_pars.getHeight()+ throw new IllegalArgumentException("Read image size does not match required: ("+imp_pars.getWidth()+"x"+imp_pars.getHeight()+
") != ("+woi_width4+"x"+height+")"); ") != ("+woi_width+"x"+height+")");
} }
// float [] pixels = (float[]) imp_pars.getProcessor().getPixels(); // float [] pixels = (float[]) imp_pars.getProcessor().getPixels();
...@@ -4322,8 +4405,8 @@ public class VegetationLMA { ...@@ -4322,8 +4405,8 @@ public class VegetationLMA {
if (indices[i][0] == 0) { // parameter, > 0 nonmodified type+1, then [1] is full index. if (indices[i][0] == 0) { // parameter, > 0 nonmodified type+1, then [1] is full index.
double d = pixels[i]; double d = pixels[i];
// scale alpha for the same image // scale alpha for the same image
int w = i % woi_width4; int w = i % woi_width;
int h = i / woi_width4; int h = i / woi_width;
if (h < woi_veg.height) { if (h < woi_veg.height) {
int nsub = w / (woi_veg.width + gap); int nsub = w / (woi_veg.width + gap);
if (nsub == 2) { // alpha if (nsub == 2) { // alpha
...@@ -4348,15 +4431,15 @@ public class VegetationLMA { ...@@ -4348,15 +4431,15 @@ public class VegetationLMA {
double delta, double delta,
int debugLevel, int debugLevel,
boolean show_img) { boolean show_img) {
double [][] jt_delta = getFxDerivsDelta ( double [][] jt = new double [vector.length][];
vector, // double [] vector,
delta, // final double delta,
debugLevel); // final int debug_level)
double [][] jt = new double [jt_delta.length][];
getFxDerivs( getFxDerivs(
vector, // final double [] vector, vector, // final double [] vector,
jt, // final double [][] jt, // should be null or initialized with [vector.length][] jt, // final double [][] jt, // should be null or initialized with [vector.length][]
debugLevel); // final int debug_level) debugLevel); // final int debug_level)
double [][] jt_delta = getFxDerivsDelta (
vector, // double [] vector,
delta, // final double delta,
debugLevel - 10); // final int debug_level)
double [][] jt_diff = new double [jt_delta.length][jt_delta[0].length]; double [][] jt_diff = new double [jt_delta.length][jt_delta[0].length];
double max_err=0; double max_err=0;
for (int n = 0; n < jt_diff.length; n++) { for (int n = 0; n < jt_diff.length; n++) {
...@@ -4387,16 +4470,21 @@ public class VegetationLMA { ...@@ -4387,16 +4470,21 @@ public class VegetationLMA {
final double [] scene_weights_in, final double [] scene_weights_in,
final double reg_weights, final double reg_weights,
final double hifreq_weight) { final double hifreq_weight) {
boolean use_hf = (y_src_hf != null); boolean use_hf = (y_src_hf != null);
int y_avg_len = y_vector.length - (y_src.length + ((y_src_hf != null) ? y_src_hf.length : 0));
// boolean use_terr_corr = y_vector.length > y_lf_hf_len;
use_scenes_pull0 = (scenes_pull0 >=0); use_scenes_pull0 = (scenes_pull0 >=0);
// using >=0 no use 0 as NOP but reserve space, <0 - do not reserve space // using >=0 no use 0 as NOP but reserve space, <0 - do not reserve space
samples_pointers = new int [SAMPLES_SIZE][3]; // {start, length} samples_pointers = new int [SAMPLES_SIZE][3]; // {start, length}
// samples_pointers[SAMPLES_Y][0] = 0;
samples_pointers[SAMPLES_Y][1] = y_src.length; samples_pointers[SAMPLES_Y][1] = y_src.length;
if (y_src_hf != null) { if (y_src_hf != null) {
samples_pointers[SAMPLES_Y_HF][1] = y_src_hf.length; samples_pointers[SAMPLES_Y_HF][1] = y_src_hf.length;
} }
if (y_avg_len > 0) {
samples_pointers[SAMPLES_Y_AVG][1] = y_avg_len;
}
if (use_scenes_pull0) { if (use_scenes_pull0) {
samples_pointers[SAMPLES_SCENES][1] = 1; samples_pointers[SAMPLES_SCENES][1] = 1;
} }
...@@ -4471,6 +4559,14 @@ public class VegetationLMA { ...@@ -4471,6 +4559,14 @@ public class VegetationLMA {
s += scene_weights[nscene] * hifreq_weight ; s += scene_weights[nscene] * hifreq_weight ;
} }
} }
if (y_avg_len > 0) {
for (int ny = 0; ny < y_avg_len; ny++) {
s += terrain_correction; // scene_weights[nscene] is included in y_wavg and fX, jt
}
}
/// double s_pull_0 = s_scenes * scenes_pull0 * woi.width*woi.height; /// double s_pull_0 = s_scenes * scenes_pull0 * woi.width*woi.height;
final double s0 = s; final double s0 = s;
s *= (1+ reg_weights); s *= (1+ reg_weights);
...@@ -4484,21 +4580,27 @@ public class VegetationLMA { ...@@ -4484,21 +4580,27 @@ public class VegetationLMA {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
public void run() { public void run() {
for (int nw = ai.getAndIncrement(); nw < weights.length; nw = ai.getAndIncrement()) { for (int nw = ai.getAndIncrement(); nw < weights.length; nw = ai.getAndIncrement()) {
if (nw < y_src.length) { // DC differences if (nw < samples_pointers[SAMPLES_Y_HF][0]) { // DC differences
weights[nw] = scene_weights[y_src[nw][YSRC_SCENE]] * k; weights[nw] = scene_weights[y_src[nw][YSRC_SCENE]] * k;
if (Double.isNaN(weights[nw])) { if (Double.isNaN(weights[nw])) {
System.out.println("weights["+nw+"]=NaN"); System.out.println("weights["+nw+"]=NaN - 1");
} }
} else if (nw < y_vector.length) { // HF differences if exist } else if (nw < samples_pointers[SAMPLES_Y_AVG][0]) { // HF differences if exist
weights[nw] = scene_weights[y_src_hf[nw-y_src.length][YSRC_SCENE]] * k * hifreq_weight; weights[nw] = scene_weights[y_src_hf[nw-y_src.length][YSRC_SCENE]] * k * hifreq_weight;
if (Double.isNaN(weights[nw])) { if (Double.isNaN(weights[nw])) {
System.out.println("weights["+nw+"]=NaN"); System.out.println("weights["+nw+"]=NaN - 2");
}
} else if (nw < samples_pointers[SAMPLES_EXTRA][0]) { // y_wavg if exists
weights[nw] = k * terrain_correction;
if (Double.isNaN(weights[nw])) {
System.out.println("weights["+nw+"]=NaN - 3");
} }
} else { } else {
weights[nw] = reg_sample_weight; weights[nw] = reg_sample_weight;
if (Double.isNaN(weights[nw])) { if (Double.isNaN(weights[nw])) {
System.out.println("weights["+nw+"]=NaN"); System.out.println("weights["+nw+"]=NaN - 4");
} }
} }
} }
...@@ -4509,11 +4611,16 @@ public class VegetationLMA { ...@@ -4509,11 +4611,16 @@ public class VegetationLMA {
return; return;
} }
private void setupYVector() { private void setupYVector(
final int ds_length = y_src.length + ((y_src_hf != null)? y_src_hf.length : 0); boolean use_terr_corr,
double [] scene_weights) {
final int woi_length = woi.width*woi.height;
final int terr_start = y_src.length + ((y_src_hf != null)? y_src_hf.length : 0);
final int ds_length = terr_start + (use_terr_corr? woi_length: 0);
y_vector = new double [ds_length]; y_vector = new double [ds_length];
final Thread[] threads = ImageDtt.newThreadArray(QuadCLT.THREADS_MAX); final Thread[] threads = ImageDtt.newThreadArray(QuadCLT.THREADS_MAX);
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
final AtomicInteger ati = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
public void run() { public void run() {
...@@ -4548,10 +4655,112 @@ public class VegetationLMA { ...@@ -4548,10 +4655,112 @@ public class VegetationLMA {
} }
ImageDtt.startAndJoin(threads); ImageDtt.startAndJoin(threads);
} }
if (use_terr_corr) {
int dbg_windx = -142;
ai.set(0);
ati.set(0);
final double [][] y_wavg_threads = new double [threads.length][woi_length];
// y_wavg = new double[woi_length];
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
int nthread = ati.getAndIncrement();
public void run() {
for (int ny = ai.getAndIncrement(); ny < y_src.length; ny = ai.getAndIncrement()) {
int nscene = y_src[ny][YSRC_SCENE];
int indx = y_src[ny][YSRC_FINDEX];
int windx = getWindexFromFindex(indx);
double d =y_vector[ny] * scene_weights[nscene];
if (Double.isNaN(d)) {
System.out.println("y_vector["+ny+"]*scene_weights["+nscene+"]=NaN");
}
y_wavg_threads[nthread][windx] += d;
if (windx== dbg_windx) {
System.out.println("setupYVector(): nscene="+nscene+", nthread="+nthread+
" y_vector["+ny+"]="+y_vector[ny]+" scene_weights["+nscene+"]="+scene_weights[nscene]+" d="+d);
}
}
}
};
}
ImageDtt.startAndJoin(threads);
ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int wIndx = ai.getAndIncrement(); wIndx < woi_length; wIndx = ai.getAndIncrement()) {
double swy = 0;
if (wIndx== dbg_windx) {
System.out.println("setupYVector(): wIndx="+wIndx);
}
for (int nthread = 0; nthread < threads.length; nthread++) {
swy +=y_wavg_threads[nthread][wIndx];
}
if (Double.isNaN(swy)) {
System.out.println("y_vector["+(wIndx+terr_start)+"]=NaN");
}
y_vector[wIndx+terr_start] = swy; // /sw; (fX uses the same weights)
}
}
};
}
ImageDtt.startAndJoin(threads);
}
return; return;
} }
private int getWindexFromFindex(int findex) {
int wx = (findex % full.width) - woi.x;
int wy = (findex / full.width) - woi.y;
return wx + wy*woi.width;
}
/*
private void setupYWavg( double [] scene_weights) {
final int woi_length = woi.width*woi.height;
final Thread[] threads = ImageDtt.newThreadArray(QuadCLT.THREADS_MAX);
final AtomicInteger ai = new AtomicInteger(0);
final AtomicInteger ati = new AtomicInteger(0);
final double [][] y_wavg_threads = new double [threads.length][woi_length];
// final double [][] s_weights_threads = new double [threads.length][woi_length];
y_wavg = new double[woi_length];
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
int nthread = ati.getAndIncrement();
public void run() {
for (int ny = ai.getAndIncrement(); ny < y_src.length; ny = ai.getAndIncrement()) {
int nscene = y_src[ny][YSRC_SCENE];
int indx = y_src[ny][YSRC_FINDEX];
int windx = getWindexFromFindex(indx);
// double w = scene_weights[nscene];
// s_weights_threads [nthread][windx] += w;
y_wavg_threads[nthread][windx] += y_vector[ny] * scene_weights[nscene];
}
}
};
}
ImageDtt.startAndJoin(threads);
ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int wIndx = ai.getAndIncrement(); wIndx < woi_length; wIndx = ai.getAndIncrement()) {
double swy = 0;
// double sw = 0;
for (int nthread = 0; nthread < threads.length; nthread++) {
swy +=y_wavg_threads[nthread][wIndx];
// sw += s_weights_threads[nthread][wIndx];
}
// if (sw > 0) {
y_wavg[wIndx] = swy; // /sw; (fX uses the same weights)
// }
}
}
};
}
ImageDtt.startAndJoin(threads);
return;
}
*/
private int [][] getNeighbors( private int [][] getNeighbors(
final int tvao, // TVAO_VEGETATION_ALPHA final int tvao, // TVAO_VEGETATION_ALPHA
final int ind_samples, // ind_pars_vegetation_alpha final int ind_samples, // ind_pars_vegetation_alpha
...@@ -4822,7 +5031,8 @@ public class VegetationLMA { ...@@ -4822,7 +5031,8 @@ public class VegetationLMA {
return; return;
} }
private void setupYSrc (boolean use_hf) { private void setupYSrc (
boolean use_hf) {
final int woi_length = woi.width * woi.height; final int woi_length = woi.width * woi.height;
y_src_scene = new int [num_scenes][]; y_src_scene = new int [num_scenes][];
y_wsrc = new int [num_scenes][]; y_wsrc = new int [num_scenes][];
......
...@@ -1421,6 +1421,7 @@ public class VegetationModel { ...@@ -1421,6 +1421,7 @@ public class VegetationModel {
double boost_parallax = clt_parameters.imp.terr_boost_parallax; // 3.0; /// 1.0; /////// 5.0; /// 1.0; // 5; double boost_parallax = clt_parameters.imp.terr_boost_parallax; // 3.0; /// 1.0; /////// 5.0; /// 1.0; // 5;
double max_parallax = clt_parameters.imp.terr_max_parallax; // 10; double max_parallax = clt_parameters.imp.terr_max_parallax; // 10;
double hifreq_weight = clt_parameters.imp.terr_hifreq_weight; // 22.5; // 0 - do not use high-freq. Relative weight of laplacian components double reg_weights = 0.25; // fraction of the total weight used for regularization double hifreq_weight = clt_parameters.imp.terr_hifreq_weight; // 22.5; // 0 - do not use high-freq. Relative weight of laplacian components double reg_weights = 0.25; // fraction of the total weight used for regularization
double terrain_correction= clt_parameters.imp.terr_terr_corr;
boolean fit_terr = clt_parameters.imp.terr_fit_terr; // true; // adjust terrain pixels boolean fit_terr = clt_parameters.imp.terr_fit_terr; // true; // adjust terrain pixels
boolean fit_veget = clt_parameters.imp.terr_fit_veget; // true; // adjust vegetation pixels boolean fit_veget = clt_parameters.imp.terr_fit_veget; // true; // adjust vegetation pixels
...@@ -1936,8 +1937,9 @@ public class VegetationModel { ...@@ -1936,8 +1937,9 @@ public class VegetationModel {
terr_difference, // final double terr_difference, // pull vegetation to be this warmer terr_difference, // final double terr_difference, // pull vegetation to be this warmer
terr_pull_cold, // final double terr_pull_cold, // pull vegetations to warm, terrain to cold terr_pull_cold, // final double terr_pull_cold, // pull vegetations to warm, terrain to cold
elevation_radius, // final double elevation_radius, // Radius of elevation/vegetation influence. elevation_radius, // final double elevation_radius, // Radius of elevation/vegetation influence.
default_alpha, // final double default_alpha, default_alpha, // final double default_alpha,
hifreq_weight, //final double hifreq_weight, // 22.5 0 - do not use high-freq. Relative weight of laplacian components hifreq_weight, //final double hifreq_weight, // 22.5 0 - do not use high-freq. Relative weight of laplacian components
terrain_correction,// final double terrain_correction,
fit_terr, // final boolean adjust_terr, fit_terr, // final boolean adjust_terr,
fit_veget, // final boolean adjust_veget, fit_veget, // final boolean adjust_veget,
fit_alpha, // final boolean adjust_alpha, fit_alpha, // final boolean adjust_alpha,
......
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