publicbooleanterr_par_restore=false;// restore parameters from file
publicintterr_step_restore=2;// If restore, start with step after restored
// terrain/vegetation parameters
@Deprecated
publicbooleanterr_um_en=true;
publicdoubleterr_um_sigma=1.0;
publicdoubleterr_um_weight=0.8;
// @Deprecated
publicdoubleterr_um_sigma=1.0;// use for render
// @Deprecated
publicdoubleterr_um_weight=0.8;// use for render
@Deprecated
publicdoubleterr_nan_tolerance=0.001;// set undefined terrain (out of capture area) to nan, it is almost zero after UM. if !terr_um_en will be forced ==0.0
publicintterr_nan_grow=20;// grow undefined scenes terrain after detection
publicintterr_shrink_veget=20;// shrink accumulated vegetation for filling terrain
...
...
@@ -811,6 +815,7 @@ min_str_neib_fpn 0.35
publicdoubleterr_alpha_weight_center=1.5;// weight of center alpha pixel relative to each of the 4 ortho ones
publicbooleanterr_en_holes=true;// enable small holes // maybe second pass after good fit with vegetation and search for correct offset?
publicdoubleterr_alpha_mm_hole=0.1;// NaN to disable. Local "almost minimum" (lower than this fraction between min and max neighbor) is not subject to alpha_lpf
publicdoubleterr_alpha_diff_hole=0.01;// Minimal alpha difference between min and max neighbor to be considered a hole
publicdoubleterr_terr_lpf=0.1;// pull terrain to average of 4 neighbors
publicdoubleterr_veget_lpf=10.0;// pull vegetation to average of 4 neighbors
publicdoubleterr_elev_lpf=50.0;// pull elevation to average of 4 neighbors
...
...
@@ -2137,6 +2142,7 @@ min_str_neib_fpn 0.35
gd.addNumericField("Alpha center weight",terr_alpha_weight_center,5,7,"","Weight of center alpha pixel relative to each of the 4 ortho ones.");
gd.addCheckbox("Hole search enable",terr_en_holes,"Search for small semi-transparent holes, disable diffusion of local alpha minimums.");
gd.addNumericField("Alpha MM fraction",terr_alpha_mm_hole,5,7,"","Disable diffusion for local \"almost minimum\" (lower than this fraction between min and max neighbors).");
gd.addNumericField("Alpha hole difference",terr_alpha_diff_hole,5,7,"","Minimal alpha difference between min and max neighbor to be considered a hole.");
gd.addNumericField("Terrain diffusion",terr_terr_lpf,5,7,"","LPF for terrain pixels (diffusion to 4 neighbors).");
gd.addNumericField("Vegetation diffusion",terr_veget_lpf,5,7,"","LPF for vegetation pixels (diffusion to 4 neighbors).");
gd.addNumericField("Elevation diffusion",terr_elev_lpf,5,7,"","LPF for elevation pixels (diffusion to 4 neighbors).");
privatedoublealpha_loss_lin=0.5;// (+) linear loss
privatedoublealpha_offset=0;// (+) if >0, start losses above 0.0 and below 1.0;
...
...
@@ -198,6 +198,10 @@ public class VegetationLMA {
privatedoublescenes_pull0=0;// (*) pull average scene offset to 0;
privatedoublescale_scenes_pull=0;// (*) used in getFxDerivs to scale scene offsets as their weight will be reg_weights / extra_samples
publicdoubleboost_parallax=1;// (+)
publicdoublemax_parallax=10;// (+)
publicdoublemax_warp=3.8;// 1.8 - do not use scenes where distance between vegetation projection exceeds this
publicintmax_elevation=22;// maximal "elevation" to consider
publicdoubleelevation_radius=1.5;// Radius of elevation/vegetation influence.
// data used to calculate lpf pull of the alpha pixel to average of four neighbors. Below similar (weaker pull) for terrain and vegetation
// to smooth areas where there is no data from available images.
...
...
@@ -232,7 +236,19 @@ public class VegetationLMA {
privatedouble[]last_ymfx=null;
privatedouble[][]last_jt=null;
publicdoubleterrain_offset=Double.NaN;// average offset from the initial
publicRectanglegetFull(){
returnfull;
}
publicRectanglegetWoi(){
returnwoi;
}
publicRectanglegetWoiVeg(){
returnwoi_veg;
}
publicVegetationModelgetModel(){
returnvegetationModel;
}
publicVegetationLMA(
intwidth,
booleandiff_mode,
...
...
@@ -490,9 +506,8 @@ public class VegetationLMA {
finalbooleankeep_parameters,
finalRectanglewoi,
finaldoublemax_warp,// 1.8 - do not use scenes where distance between vegetation projection exceeds this
finalintmax_offset,// maximal "elevation" to consider
finalintmax_elevation,// maximal "elevation" to consider
finaldoubleelevation_radius,//Radius of elevation/vegetation influence.
finaldoubledefault_alpha,
finaldoublehifreq_weight,// 22.5 0 - do not use high-freq. Relative weight of laplacian components
finaldoubleterrain_correction,
finalbooleanfit_terr,
...
...
@@ -513,7 +528,8 @@ public class VegetationLMA {
finaldoublealpha_push_neutral,// = 0.8; // alpha point from which push (closer to opaque)
finaldoublealpha_push_center,// 1.5; // weight of center alpha pixel relative to each of the 4 ortho ones
finalbooleanalpha_en_holes,// Search for small semi-transparent holes, disable diffusion of local alpha minimums
finaldoublealpha_mm_hole,// = 0.1; // NaN to disable. Local "almost minimum" (lower than this fraction between min and max neighbor) is not subject to alpha_lpf
finaldoublealpha_mm_hole,// = 0.1; // NaN to disable. Local "almost minimum" (lower than this fraction between min and max neighbor) is not subject to alpha_lpf
finaldoublealpha_diff_hole,// 0.01; // Minimal alpha difference between min and max neighbor to be considered a hole
finaldoubleterr_lpf,// pull terrain to average of 4 neighbors (very small)
finaldoubleveget_lpf,// pull vegetation to average of 4 neighbors (very small - maybe not needed)
finaldoubleelevation_lpf,
...
...
@@ -529,16 +545,16 @@ public class VegetationLMA {
finaldoublescenes_pull0,
finaldoubleboost_parallax,// increase weight of scene with maximal parallax relative to the reference scene
finaldoublemax_parallax,// do not consider maximal parallax above this (consider it a glitch)
finaldoubleum_sigma,// just use in debug image names
finaldoubleum_weight,
Stringparameters_read_path,
// final double um_sigma, // just use in debug image names
// final double um_weight,
// String parameters_read_path,
finalintdebugLevel,
finalbooleandebug_save_improved,// Save debug image after successful LMA step.");
finalbooleandebug_save_worsened){// Save debug image after unsuccessful LMA step.");
this.woi=woi;
this.hifreq_weight=hifreq_weight;// 22.5 0 - do not use high-freq. Relative weight of laplacian components
this.terrain_correction=terrain_correction;
fits=newboolean[TVAO_TYPES];
// fits = new boolean[TVAO_TYPES];
fits[TVAO_TERRAIN]=fit_terr;
fits[TVAO_VEGETATION]=fit_veget;
fits[TVAO_ALPHA]=fit_alpha;
...
...
@@ -572,8 +588,15 @@ public class VegetationLMA {
this.low_veget=low_veget;
this.scenes_pull0=scenes_pull0;
this.boost_parallax=boost_parallax;
this.debug_save_improved=debug_save_improved;
this.max_parallax=max_parallax;// parallax limit when evaluating boost parallax
this.max_warp=max_warp;
this.max_elevation=max_elevation;
this.elevation_radius=elevation_radius;
this.debug_save_improved=debug_save_improved;
this.debug_save_worsened=debug_save_worsened;
this.elev_sum_weights=null;// calculate elevations on next getFxDErivsrun
// this.um_sigma = um_sigma; // just use in debug image names
// this.um_weight = um_weight;
...
...
@@ -608,7 +631,7 @@ public class VegetationLMA {
warps,// final double[][][] warps,
max_warp,// final double max_warp,
valid_pixels_in,// final boolean [] valid_pixels_in, // should be initialized to woi, normally set to all true
max_offset,// final int max_offset,
max_elevation,// final int max_offset,
elev_radius,// final double [] elev_radius, // this.elevation_radius
getProperty(imp_pars,"MAX_WARP",max_warp),// final double max_warp, // 1.8 - do not use scenes where distance between vegetation projection exceeds this
getProperty(imp_pars,"MAX_ELEVATION",max_elevation),// final int max_offset, // maximal "elevation" to consider
getProperty(imp_pars,"ELEVATION_RADIUS",elevation_radius),// final double elevation_radius, // Radius of elevation/vegetation influence.
getProperty(imp_pars,"HIGHFREQ_WEIGHT",hifreq_weight),// final double hifreq_weight, // 22.5 0 - do not use high-freq. Relative weight of laplacian components
getProperty(imp_pars,"TERRAIN_CORRECTION",terrain_correction),// final double terrain_correction,
getProperty(imp_pars,"FIT_TERRAIN",fits[TVAO_TERRAIN]),// final boolean adjust_terr,
getProperty(imp_pars,"FIT_VEGETATION",fits[TVAO_VEGETATION]),// final boolean adjust_veget,
getProperty(imp_pars,"FIT_ALPHA",fits[TVAO_ALPHA]),// final boolean adjust_alpha,
getProperty(imp_pars,"FIT_SCENE_OFFSET",fits[TVAO_SCENE_OFFSET]),// final boolean adjust_scenes,
getProperty(imp_pars,"FIT_ELEVATION",fits[TVAO_ELEVATION]),// final boolean adjust_elevations,
getProperty(imp_pars,disable_names,fits_disable),// final boolean [] fit_disable,
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_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_OFFSET",alpha_offset),// final double alpha_offset, // quadratic loss when alpha reaches -1.0 or 2.0
getProperty(imp_pars,"ALPHA_MIN_VEG",alpha_min_veg),// final double alpha_min_veg, // 0.5; // if (alpha-alpha_offset)/(1-2*alpha_offset) < alpha_min_veg, pull down to lpha_offset
getProperty(imp_pars,"ALPHA_LPF",alpha_lpf),// final double alpha_lpf, // pull to average of 4 neighbors
getProperty(imp_pars,"ALPHA_SCALE_AVG",alpha_scale_avg),// final double alpha_scale_avg, // = 1.2; // scale average alpha (around 0.5) when pulling to it
getProperty(imp_pars,"ALPHA_PUSH",alpha_push),// final double alpha_push, // 5.0; // push from alpha==0.5
getProperty(imp_pars,"ALPHA_PUSH_NEUTRAL",alpha_push_neutral),// double alpha_push_neutral = 0.8; // alpha point from which push (closer to opaque)
getProperty(imp_pars,"ALPHA_PUSH_CENTER",alpha_push_center),// final double alpha_push_center,// 1.5; // weight of center alpha pixel relative to each of the 4 ortho ones
getProperty(imp_pars,"ALPHA_EN_HOLES",alpha_en_holes),// final boolean alpha_en_holes, // Search for small semi-transparent holes, disable diffusion of local alpha minimums
getProperty(imp_pars,"ALPHA_MM_HOLE",alpha_mm_hole),// double alpha_mm_hole = 0.1; // NaN to disable. Local "almost minimum" (lower than this fraction between min and max neighbor) is not subject to alpha_lpf
getProperty(imp_pars,"ALPHA_DIFF_HOLE",alpha_diff_hole),// final double alpha_diff_hole, // 0.01; // Minimal alpha difference between min and max neighbor to be considered a hole
getProperty(imp_pars,"TERR_LPF",terr_lpf),// final double terr_lpf, // pull terrain to average of 4 neighbors (very small)
getProperty(imp_pars,"VEGET_LPF",veget_lpf),// final double veget_lpf, // pull vegetation to average of 4 neighbors (very small - maybe not needed)
getProperty(imp_pars,"ELEVATION_LPF",elevation_lpf),// final double elevation_lpf,
getProperty(imp_pars,"TERR_PULL0",terr_pull0),// final double terr_pull0, // pull terrain to initial (pre-adjustment) values
getProperty(imp_pars,"TERR_PULL_UP",terr_pull_up),// final double terr_pull_up, // Terrain pixels pull to initial (pre-adjustment) values when it is colder than initial.
getProperty(imp_pars,"TERR_PULL_AVG",terr_pull_avg),// final double terr_pull_avg, // pull terrain to the initial offset by the average offset of all terrain pixels
getProperty(imp_pars,"VEGET_PULL0",veget_pull0),// final double veget_pull0, // pull vegetation to initial (pre-adjustment) values
getProperty(imp_pars,"ELEVATION_PULL0",elevation_pull0),// final double elev_pull0, // pull elevation to initial (pre-adjustment) values
getProperty(imp_pars,"ELEV_ALPHA_EN",elev_alpha_en),// final boolean elev_alpha_en, // false; // Enable loss for low vegetation with high opacity
getProperty(imp_pars,"ELEV_ALPHA",elev_alpha),// final double elev_alpha, // 1.0; // multiply alpha by under-low elevation for loss
getProperty(imp_pars,"ELEV_ALPHA_PWR",elev_alpha_pwr),// final double elev_alpha_pwr, // 2.0; // raise alpha to this power (when alpha > 0)
getProperty(imp_pars,"ELEV_LOW_VEGET",low_veget),// final double low_veget, // 2.0; // (pix) Elevation considered low (lower loss for high alpha)
getProperty(imp_pars,"SCENES_PULL0",scenes_pull0),// final double scenes_pull0,
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)
debugLevel,// final int debugLevel);
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.");
doublealpha_loss=clt_parameters.imp.terr_alpha_loss;//100.0; // alpha quadratic growing loss for when out of [0,1] range
doublealpha_loss_lin=clt_parameters.imp.terr_alpha_loss_lin;// alpha linear growing loss for when out of [0,1] range and below minimal vegetation alpha
doublealpha_offset=clt_parameters.imp.terr_alpha_offset;// 0.0; // 0.02; // 0.03; // if >0, start losses above 0.0 and below 1.0;
...
...
@@ -1499,6 +1523,8 @@ public class VegetationModel {
doublealpha_push_center=clt_parameters.imp.terr_alpha_weight_center;// 1.5; // weight of center alpha pixel relative to each of the 4 ortho ones
doublealpha_mm_hole=clt_parameters.imp.terr_alpha_mm_hole;// 0.1; // NaN to disable. Local "almost minimum" (lower than this fraction between min and max neighbor) is not subject to alpha_lpf
doublealpha_diff_hole=clt_parameters.imp.terr_alpha_diff_hole;// 0.01; Minimal alpha difference between min and max neighbor to be considered a hole
doubleterr_lpf=clt_parameters.imp.terr_terr_lpf;// 0.1; // 0.15; /// 0.2; /// 0.1; // pull terrain to average of 4 neighbors (very small)
doubleveget_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)
@@ -2073,7 +2119,6 @@ public class VegetationModel {
max_warp,// final double max_warp, // 1.8 - do not use scenes where distance between vegetation projection exceeds this
max_offset,// final int max_offset, // maximal "elevation" to consider
elevation_radius,// final double elevation_radius, // Radius of elevation/vegetation influence.
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
terrain_correction,// final double terrain_correction,
fit_terr,// final boolean adjust_terr,
...
...
@@ -2095,6 +2140,7 @@ public class VegetationModel {
alpha_push_center,// final double alpha_push_center,// 1.5; // weight of center alpha pixel relative to each of the 4 ortho ones
alpha_en_holes,// final boolean alpha_en_holes, // Search for small semi-transparent holes, disable diffusion of local alpha minimums
alpha_mm_hole,// double alpha_mm_hole = 0.1; // NaN to disable. Local "almost minimum" (lower than this fraction between min and max neighbor) is not subject to alpha_lpf
alpha_diff_hole,//final double alpha_diff_hole, // 0.01; // Minimal alpha difference between min and max neighbor to be considered a hole
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,
...
...
@@ -2110,9 +2156,9 @@ public class VegetationModel {
scenes_pull0,// final double scenes_pull0,
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)
um_sigma,// final double um_sigma, // just use in debug image names
(um_en?um_weight:0.0),// final double um_weight,
par_path,// final String parameters_read_path,
// um_sigma, // final double um_sigma, // just use in debug image names
// (um_en? um_weight: 0.0), // final double um_weight,
// par_path, // final String parameters_read_path,
debugLevel,// final int debugLevel);
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.");
...
...
@@ -2137,7 +2183,7 @@ public class VegetationModel {
}
intnum_iter=num_iters[step_restore];//
if(par_restore){// always use last number of iterations - not anymore
par_path=parameters_dir;
Stringpar_path=parameters_dir;
if(!par_path.endsWith(Prefs.getFileSeparator())){
par_path+=Prefs.getFileSeparator();
}
...
...
@@ -2167,6 +2213,7 @@ public class VegetationModel {
//num_iters.length
}
// old
/*
if ("RESTORE".equals(par_path)) {
System.out.println("Reading fitted parameters from file");
if (save_par_files) {
...
...
@@ -2179,7 +2226,7 @@ public class VegetationModel {