Commit 47963228 authored by Andrey Filippov's avatar Andrey Filippov

working terrain-only mode

parent fa638d8f
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -1535,6 +1535,7 @@ public class VegetationModel {
double terr_lpf = clt_parameters.imp.terr_terr_lpf; // 0.1; // 0.15; /// 0.2; /// 0.1; // pull terrain to average of 4 neighbors (very small)
double veget_lpf = clt_parameters.imp.terr_veget_lpf; // 0.2; //0.15; /// 0.2; //// 0.01; /// 0.1; // pull vegetation to average of 4 neighbors (very small - maybe not needed)
double elevation_lpf = clt_parameters.imp.terr_elev_lpf;
double terr_elev_lpf = clt_parameters.imp.terr_terr_elev_lpf;
double terr_pull0 = clt_parameters.imp.terr_terr_pull0; // 0.1; //0.03; ////// 0.05; ///// 0.1; //// 0.01; /// 0.2; /// 0.1; //pull terrain to zero (makes sense with UM
double terr_pull_up = clt_parameters.imp.terr_terr_pull_up; // 0.2; // Terrain pixels pull to initial (pre-adjustment) values when it is colder than initial.
double terr_pull_avg = clt_parameters.imp.terr_terr_pull_avg; // 0.1; // Pull terrain to the initial offset by the average offset of all terrain pixels
......@@ -1543,7 +1544,10 @@ public class VegetationModel {
double veget_pull_low_alpha = clt_parameters.imp.terr_veget_pull_low_alpha; //10; // scale pull0 for low alpha (mostly terrain)
double elev_pull0 = clt_parameters.imp.terr_elev_pull0;
boolean elev_alpha_en= clt_parameters.imp.terr_elev_alpha_en; // false;// Enable loss for low vegetation with high opacity
double terr_elev_pull0 = clt_parameters.imp.terr_terr_elev_pull0;
boolean elev_alpha_en= clt_parameters.imp.terr_elev_alpha_en; // false;// Enable loss for low vegetation with high opacity
double elev_alpha = clt_parameters.imp.terr_elev_alpha; // 1.0; // multiply alpha by under-low elevation for loss
double elev_alpha_pwr = clt_parameters.imp.terr_elev_alpha_pwr; // 1.0; // multiply alpha by under-low elevation for loss
double low_veget = clt_parameters.imp.terr_low_veget; // 2.0; // (pix) Elevation considered low (lower loss for high alpha)
......@@ -1573,6 +1577,7 @@ public class VegetationModel {
boolean fit_scenes = clt_parameters.imp.terr_fit_scenes; // true; // adjust scene offsets (start from 0 always?)
boolean fit_elevations = clt_parameters.imp.terr_fit_elevations; // false; // adjust elevation pixels (not yet implemented)
boolean fit_terr_elev = clt_parameters.imp.terr_fit_terr_elev; // false; // adjust terrain elevation (common, maybe add per-pixel later)
boolean fit_terr_elev_pix = clt_parameters.imp.terr_fit_terr_elev_pix; // false; // adjust terrain elevation (common, maybe add per-pixel later)
// boolean [] fit_disable = clt_parameters.imp.terr_fit_disable.clone();
boolean [][] fits_disable = new boolean[clt_parameters.imp.terr_fits_disable.length][];
......@@ -1587,8 +1592,15 @@ public class VegetationModel {
double lambda_max = clt_parameters.imp.terr_lambda_max; // 1000;
double rms_diff = clt_parameters.imp.terr_rms_diff; // 1e-8; // 0.0001; virtually forever
int [] num_iters = clt_parameters.imp.terr_num_iters; // {25}; // 100;
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;
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]
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
if (terr_only_series < 0) terr_only_series = terr_only_num_iters.length - 1;
// Combine parameters
int border_width = clt_parameters.imp.terr_border_width; // 6;
boolean render_open = clt_parameters.imp.terr_render_open; // true; // render open areas (no vegetation offset)
......@@ -2111,6 +2123,7 @@ public class VegetationModel {
fit_scenes, // final boolean adjust_scenes,
fit_elevations, // final boolean adjust_elevations,
fit_terr_elev, // final boolean fit_terr_elev,
fit_terr_elev_pix, // final boolean fit_terr_elev_pix,
thisOrLast(step_restore, fits_disable), // fits_disables[0], // final boolean [] fit_disable,
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
......@@ -2133,12 +2146,15 @@ public class VegetationModel {
terr_lpf, // final double terr_lpf, // pull terrain to average of 4 neighbors (very small)
veget_lpf, // final double veget_lpf, // pull vegetation to average of 4 neighbors (very small - maybe not needed)
elevation_lpf, // final double elevation_lpf,
terr_elev_lpf, // final double terr_elev_lpf,
terr_pull0, // final double terr_pull0, // pull terrain to initial (pre-adjustment) values
terr_pull_up, // final double terr_pull_up, // Terrain pixels pull to initial (pre-adjustment) values when it is colder than initial.
terr_pull_avg, // final double terr_pull_avg, // pull terrain to the initial offset by the average offset of all terrain pixels
veget_pull0, // final double veget_pull0, // pull vegetation to initial (pre-adjustment) values
veget_pull_low_alpha, //final double veget_pull_low_alpha, // 10; // ()scale pull0 for low alpha (mostly terrain)
elev_pull0, // final double elev_pull0, // pull elevation to initial (pre-adjustment) values
terr_elev_pull0, // final double terr_elev_pull0, // pull terrain elevation to segment average
elev_alpha_en, // final boolean elev_alpha_en, // false; // Enable loss for low vegetation with high opacity
elev_alpha, // final double elev_alpha, // 1.0; // multiply alpha by under-low elevation for loss
elev_alpha_pwr, // final double elev_alpha_pwr, // 2.0; // raise alpha to this power (when alpha > 0)
......@@ -2155,10 +2171,11 @@ public class VegetationModel {
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_rem_rad, // final double ttop_rem_rad, // 0.25; // Relative (to the top height) remove transparency radius
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)
debugLevel, // final int debugLevel);
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]
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)
debugLevel, // final int debugLevel);
debug_path, // final String debug_path,
debug_save_improved, // final boolean debug_save_improved, // Save debug image after successful LMA step.");
debug_save_worsened);// final boolean debug_save_worsened) // Save debug image after unsuccessful LMA step.");
......@@ -2167,6 +2184,12 @@ public class VegetationModel {
System.out.println("Insufficient data in this segment, skipping it.");
continue;
}
/// Handle terrain-only tiles
if ((vegetationLMA.getWoiVeg() == null) && terr_only_special) {
last_series = terr_only_series;
num_iters = terr_only_num_iters;
}
if (save_par_files && skip_existing_woi) { // check that segment already exists
File[] segment_files = vegetationLMA.getSegmentFiles(segments_dir);
......
......@@ -9,7 +9,7 @@ import com.elphel.imagej.tileprocessor.ImageDtt;
import com.elphel.imagej.tileprocessor.QuadCLT;
public class VegetationSegment {
public Rectangle woi_veg;
public Rectangle woi_max;
public Rectangle woi;
public double [] scene_offsets;
public double [][] tva; // woi_veg
......@@ -19,7 +19,7 @@ public class VegetationSegment {
public String path;
public VegetationSegment(
String path,
Rectangle woi_veg,
Rectangle woi_max,
Rectangle woi,
double terrain_offset,
double [] scene_offsets, // has NaNs
......@@ -28,7 +28,7 @@ public class VegetationSegment {
boolean [] overlaid) {
this.path = path;
this.woi = woi;
this.woi_veg = woi_veg;
this.woi_max = woi_max;
this.scene_offsets = scene_offsets;
this.tva = tva;
this.terrain_offset = terrain_offset;
......@@ -43,7 +43,7 @@ public class VegetationSegment {
for (int windx = 0; windx < woi_length; windx++) {
int wx = windx % woi.width;
int wy = windx / woi.height;
int wvindx = (wx + woi.x - woi_veg.x) + (wy + woi.y - woi_veg.y) * woi_veg.width;
int wvindx = (wx + woi.x - woi_max.x) + (wy + woi.y - woi_max.y) * woi_max.width;
if (overlaid[windx]) {
tva[0][wvindx] += terrain_offset;
}
......@@ -56,7 +56,7 @@ public class VegetationSegment {
boolean use_veg) {
Rectangle bounds = null;
for (VegetationSegment segment:segments) {
Rectangle selected_woi = use_veg ?segment.woi_veg : segment.woi;
Rectangle selected_woi = use_veg ?segment.woi_max : segment.woi;
if (bounds == null) {
bounds = new Rectangle(selected_woi);
} else {
......@@ -92,12 +92,12 @@ public class VegetationSegment {
double min_sw = 1e-4;
int out_length = out_woi.width*out_woi.height;
int accum_indx = segments.length;
String [] top_titles = {"terrain","vegetation","alpha","elevation","confidence"};
String [] top_titles = {"terrain","vegetation","alpha","elevation","terrain_elevation","confidence"};
double [][][] preview_data = new double [top_titles.length][accum_indx+1][out_length];
String [] titles = new String[accum_indx+1];
for (int ns = 0; ns < segments.length; ns++) {
Rectangle woi = segments[ns].woi; // for confidence and limits for terrain
Rectangle woi_veg = segments[ns].woi_veg;
Rectangle woi_veg = segments[ns].woi_max;
titles[ns] = woi.toString();
int woi_length = woi.width * woi.height;
int woi_veg_length = woi_veg.width * woi_veg.height;
......@@ -121,7 +121,7 @@ public class VegetationSegment {
break;
case 1: // vegetation
case 2: // alpha
case 3: // vegetation
case 3: // elevation
for (int windx = 0; windx < woi_veg_length; windx++) {
int x = windx % woi_veg.width + woi_veg.x - out_woi.x;
int y = windx / woi_veg.width + woi_veg.y - out_woi.y;
......@@ -129,7 +129,15 @@ public class VegetationSegment {
preview_data[t][ns][indx] = woi_tva[t][windx];
}
break;
case 4: // confidence
case 4: // terrain elevation
for (int windx = 0; windx < woi_veg_length; windx++) {
int x = windx % woi_veg.width + woi_veg.x - out_woi.x;
int y = windx / woi_veg.width + woi_veg.y - out_woi.y;
int indx = x + y * out_woi.width;
preview_data[t][ns][indx] = woi_tva[t][windx]; // skipping terrain elevation average
}
break;
case 5: // confidence
for (int windx = 0; windx < woi_length; windx++) {
int x = windx % woi.width + woi_veg.x - out_woi.x;
int y = windx / woi.width + woi_veg.y - out_woi.y;
......
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