publicstaticfinalintDATA_SOURCE_CORN_VEGET=1;// [4]/null Z-shape 4 corners vegetation, either >= as parameter index or -1 - (x + image_width*y) of the unmodified full index
publicstaticfinalintDATA_SOURCE_CORN_ALPHA=2;// [4]/null Z-shape 4 corners vegetation alpha, either >= as parameter index or -1 - (x + image_width*y) of the unmodified full index
publicstaticfinalintDATA_SOURCE_NEIB=3;// [4]/null or 4 neighbors (CW), either y_vector index or -1 -(x + image_width*y) of the unmodified terrain
privateboolean[]valid_terrain=null;// [woi.width*woi.height] valid terrain and y_vector pixels
privateboolean[]valid_terrain=null;// [woi.width*woi.height] valid terrain and y_vector pixels
privateboolean[]overlaid=null;// [woi.width*woi.height] this valid terrain pixel is overlaid by vegetation (in all valid scenes)
privateboolean[]overlaid=null;// [woi.width*woi.height] this valid terrain pixel is overlaid by vegetation (in all valid scenes)
privateboolean[]valid_vegetation=null;
privateboolean[]valid_vegetation=null;
privatedouble[][][]warps=null;// measure of horizontal and vertical distances between the vegetation projections - use to filter scenes
privatedouble[][][]warps=null;// measure of horizontal and vertical distances between the vegetation projections - use to filter scenes
// private int [] used_scenes_indices;
privatefinaldouble[]scene_weights;
privatefinaldouble[]scene_weights;
privateboolean[]valid_scenes;
privateboolean[]valid_scenes;
...
@@ -167,66 +127,54 @@ public class VegetationLMA {
...
@@ -167,66 +127,54 @@ public class VegetationLMA {
// private double terrain_warmest = 90; // pull vegetations to warm, terrain to cold
// private double terrain_warmest = 90; // pull vegetations to warm, terrain to cold
// private double initial_split = 0.1; // pull vegetations to warm, terrain to cold
// private double initial_split = 0.1; // pull vegetations to warm, terrain to cold
// private double min_split_frac = 0.15; // minimal modality fraction to use split by temperature
// private double min_split_frac = 0.15; // minimal modality fraction to use split by temperature
privatedoubleterr_difference=100;// pull vegetation to be this warmer
// private double terr_difference = 100; // pull vegetation to be this warmer
@Deprecated
// @Deprecated
privatedoubleterr_pull_cold=0;// pull vegetations to warm, terrain to cold
// private double terr_pull_cold = 0; // pull vegetations to warm, terrain to cold
// next two just for saving?
privatedoublehifreq_weight;// 22.5 0 - do not use high-freq. Relative weight of laplacian components
// Parameters saved/resored in a file
privatedoublereg_weights;// fraction of the total weight used for regularization
privatefinalintnum_scenes;// (+)
privateRectanglewoi=null;// (+)
privateboolean[]fits;
privateRectanglewoi_veg=null;// (*) extended woi to include offset vegetation
privatedoublehifreq_weight;// (+) 22.5 0 - do not use high-freq. Relative weight of laplacian components
privatedoublealpha_initial_contrast=1.0;// >=1.0
privatedoublereg_weights;// (+) fraction of the total weight used for regularization
privatedoublealpha_loss=0;// not used with cosine alpha
privateboolean[]fits;// (+)
privatedoublealpha_offset=0;// if >0, start losses above 0.0 and below 1.0;
privatedoublealpha_loss=0;// (+) not used with cosine alpha
privatedoublealpha_lpf=0;
privatedoublealpha_offset=0;// (+) if >0, start losses above 0.0 and below 1.0;
privatebooleanalpha_piece_linear=true;
privatedoublealpha_lpf=0;// (+)
privatedoublealpha_scale_avg=1.0;// 1.1; // scale average alpha (around 0.5) when pulling to it
privatebooleanalpha_piece_linear=true;// (+)
privatedoublealpha_push=12.0;// push from alpha==0.5
privatedoublealpha_scale_avg=1.0;// (+) 1.1; // scale average alpha (around 0.5) when pulling to it
privatedoublealpha_push_neutral=0.8;// alpha point from which push (closer to opaque)
privatedoublealpha_push=12.0;// (+) push from alpha==0.5
privatedoublealpha_push_center=1.5;// weight of center alpha pixel relative to each of the 4 ortho ones
privatedoublealpha_push_neutral=0.8;// (+) alpha point from which push (closer to opaque)
privatedoublealpha_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
privatedoublealpha_push_center=1.5;// (+) weight of center alpha pixel relative to each of the 4 ortho ones
privatebooleanalpha_en_holes=true;// Search for small semi-transparent holes, disable diffusion of local alpha minimums
privatedoublealpha_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
privatedoublealpha_diff_hole=0.01;// minimal alpha difference between min and max neighbor to be considered a hole
privatebooleanalpha_en_holes=true;// (+) Search for small semi-transparent holes, disable diffusion of local alpha minimums
privatedoublealpha_diff_hole=0.01;// (+) minimal alpha difference between min and max neighbor to be considered a hole
privatedoublew_alpha_neib=0.7;// weight of each of the neighbors relative to the center when calculating average alpha
privatedoublew_alpha_neib=0.7;// (*) weight of each of the neighbors relative to the center when calculating average alpha
privatedoubleholes_pwr=2.0;// Raise alpha (0..1) to this power when replacing vegetation cold spots with holes
privatedoubleholes_pwr=2.0;// (*) Raise alpha (0..1) to this power when replacing vegetation cold spots with holes
privatedoubleterr_lpf=0;// (+)
privatebooleanfrom_file=false;
privatedoubleveget_lpf=0;// (+)
privatedoubleelevation_lpf=0;// (*)
privateboolean[]lpf_fixed={true,true,true,true,true};// (*) using Laplacian to lpf parameters, pull to fixed ones too
privatedoubleterr_lpf=0;
privatedoubleveget_lpf=0;
privatedoubleelevation_lpf=0;
privateboolean[]lpf_fixed={true,true,true,true,true};// using Laplacian to lpf parameters, pull to fixed ones too
// when unsharp mask is applied , pulling to 0 (when alpha is 0 (for vegetation) or 1.0 (for terrain) makes sense
// when unsharp mask is applied , pulling to 0 (when alpha is 0 (for vegetation) or 1.0 (for terrain) makes sense
privatedoubleterr_pull0=0;// now - pull to filled terrain - terrain_average
privatedoubleterr_pull0=0;// (+) now - pull to filled terrain - terrain_average
privatedoubleveget_pull0=0;// now - pull to vegetation_pull (extended vegetation)
privatedoubleveget_pull0=0;// (+) now - pull to vegetation_pull (extended vegetation)
publicdoubleelevation_pull0=0;// now - pull to initial elevation
publicdoubleelevation_pull0=0;// (*) now - pull to initial elevation
privatedoublescenes_pull0=0;// pull average scene offset to 0;
privatedoublescenes_pull0=0;// (*) pull average scene offset to 0;
privatebooleanuse_scenes_pull0=true;// derivative, set in setWeights
privatedoublescale_scenes_pull=0;// (*) used in getFxDerivs to scale scene offsets as their weight will be reg_weights / extra_samples
// private boolean use_y_avg = true; // derivative, set in setWeights
publicdoubleboost_parallax=1;// (+)
privatedoublescale_scenes_pull=0;// used in getFxDerivs to scale scene offsets as their weight will be reg_weights / extra_samples
publicdoubleboost_parallax=1;
publicdoubleum_sigma=0;// just use in debug image names
publicdoubleum_weight=0;
// data used to calculate lpf pull of the alpha pixel to average of four neighbors. Below similar (weaker pull) for terrain and vegetation
// 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.
// to smooth areas where there is no data from available images.
publicint[][]alpha_neibs;// corresponds to parameters for alpha (num_pars_vegetation_alpha), each has 4 ortho neibs, -1 - border, >= 0
publicint[][]alpha_neibs;// corresponds to parameters for alpha (num_pars_vegetation_alpha), each has 4 ortho neibs, -1 - border, >= 0
// - parameter index, <=-2 -2-full_pixel_index
publicint[][]terr_neibs;// corresponds to parameters for terrain, for smoothing undefined terrain, similar to alpha_neibs
publicint[][]terr_neibs;// corresponds to parameters for terrain, for smoothing undefined terrain, similar to alpha_neibs
publicint[][]veget_neibs;// corresponds to parameters for vegetation, for smoothing undefined vegetation, similar to alpha_neibs
publicint[][]veget_neibs;// corresponds to parameters for vegetation, for smoothing undefined vegetation, similar to alpha_neibs
publicint[][]elevation_neibs;// corresponds to parameters for elevation, for smoothing undefined elevations, similar to alpha_neibs
publicint[][]elevation_neibs;// corresponds to parameters for elevation, for smoothing undefined elevations, similar to alpha_neibs
publicint[][]neibs_neibs;
publicint[][]neibs_neibs;
publicdoubledelta=1e-5;// 7;
publicdoubledelta=1e-5;// 7;
privatebooleanfrom_file=false;
publicbooleanshow_extra=true;// show extra samples
publicbooleanshow_extra=true;// show extra samples
publicintdebug_index;
publicintdebug_index;
publicintdebug_iter;// LMA iteration for images
publicintdebug_iter;// LMA iteration for images
...
@@ -243,12 +191,6 @@ public class VegetationLMA {
...
@@ -243,12 +191,6 @@ public class VegetationLMA {
privatedouble[]last_ymfx=null;
privatedouble[]last_ymfx=null;
privatedouble[][]last_jt=null;
privatedouble[][]last_jt=null;
publicbooleanskip_ref_scene=false;
publicbooleandebug_deriv=true;
publicintdebug_width=12;
publicintdebug_decimals=9;
publicVegetationLMA(
publicVegetationLMA(
intwidth,
intwidth,
booleandiff_mode,
booleandiff_mode,
...
@@ -259,10 +201,10 @@ public class VegetationLMA {
...
@@ -259,10 +201,10 @@ public class VegetationLMA {
double[][]params_arr=restoreParametersFile(//FIXME: Not finished for real import !
path,// String path,
false,// boolean keep_settings,
null);// Rectangle [] file_wois); // if not null, should be Rectangle[2] {woi_veg,woi} - will return woi data and not input parameters to this instance
}
privatestaticdouble[][][]getScalesXY(
privatestaticdouble[][][]getScalesXY(
finaldouble[][][]scales_mag_dir){
finaldouble[][][]scales_mag_dir){
finalintnum_scenes=scales_mag_dir.length;
finalintnum_scenes=scales_mag_dir.length;
...
@@ -414,15 +390,6 @@ public class VegetationLMA {
...
@@ -414,15 +390,6 @@ public class VegetationLMA {
finalRectanglewoi,
finalRectanglewoi,
finaldoublemax_warp,// 1.8 - do not use scenes where distance between vegetation projection exceeds this
finaldoublemax_warp,// 1.8 - do not use scenes where distance between vegetation projection exceeds this
finalintmax_offset,// maximal "elevation" to consider
finalintmax_offset,// maximal "elevation" to consider
// final int min_total_scenes,
// final int min_samples_scene, // 10
// final int min_valid_pixels,
// final boolean start_warm_veget, // start with vegetation warmer than terrain -> USED now by vegetation_filtered
// final double terrain_warmest, // warmest terrain (above is initially vegetation) NOT USED
// final double initial_split, // initial alpha: terrain 0.0+, vegetation 1.0-. USED
// final double min_split_frac, // minimal modality fraction to use split by temperature NOT USED?
finaldoubleterr_difference,// pull vegetation to be this warmer
finaldoubleterr_pull_cold,// pull vegetation to warm, terrain to cold
finaldoubleelevation_radius,//Radius of elevation/vegetation influence.
finaldoubleelevation_radius,//Radius of elevation/vegetation influence.
finaldoubledefault_alpha,
finaldoubledefault_alpha,
finaldoublehifreq_weight,// 22.5 0 - do not use high-freq. Relative weight of laplacian components
finaldoublehifreq_weight,// 22.5 0 - do not use high-freq. Relative weight of laplacian components
// min_split_frac, // final double min_frac, // minimal modality fraction to use split by temperature
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
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
...
@@ -1988,6 +2032,19 @@ public class VegetationModel {
...
@@ -1988,6 +2032,19 @@ public class VegetationModel {
}
}
}
}
if(par_restore){
par_path=parameters_dir;
if(!par_path.endsWith(Prefs.getFileSeparator())){
par_path+=Prefs.getFileSeparator();
}
par_path+=parameters_file;
System.out.println("Restoring parameters from "+par_path);
vegetationLMA.restoreParametersFile(//FIXME: Not finished for real import !
par_path,// String path,
true,// boolean keep_settings,
null);// Rectangle [] file_wois); // if not null, should be Rectangle[2] {woi_veg,woi} - will return woi data and not input parameters to this instance
}
// old
if("RESTORE".equals(par_path)){
if("RESTORE".equals(par_path)){
System.out.println("Reading fitted parameters from file");
System.out.println("Reading fitted parameters from file");
if(save_par_files){
if(save_par_files){
...
@@ -2038,12 +2095,23 @@ public class VegetationModel {
...
@@ -2038,12 +2095,23 @@ public class VegetationModel {