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_terr_lpf=0.1;// pull terrain to average of 4 neighbors (very small)
publicdoubleterr_veget_lpf=0.2;// pull vegetation to average of 4 neighbors (very small - maybe not needed)
publicdoubleterr_elev_lpf=0.1;// pull elevation to average of 4 neighbors (very small - maybe not needed)
publicdoubleterr_terr_pull0=0.05;// pull terrain to zero (makes sense with UM
publicdoubleterr_veget_pull0=0.05;// pull vegetation to zero (makes sense with UM
publicdoubleterr_scenes_pull0=1.0;// pull average scene offset to zero
...
...
@@ -2040,6 +2041,7 @@ min_str_neib_fpn 0.35
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("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).");
gd.addNumericField("Terrain pull zero",terr_terr_pull0,5,7,"","Terrain pixels pull to 0 (makes sense with UM).");
gd.addNumericField("Vegetation pull zero",terr_veget_pull0,5,7,"","Vegetation pixels pull to 0 (makes sense with UM).");
gd.addNumericField("Pull scene offset",terr_scenes_pull0,5,7,"","Pull average scene offset to zero.");
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
...
...
@@ -49,6 +55,9 @@ public class VegetationLMA {
publicfinalintimage_length;
publicfinalintnum_scenes;
publicRectanglewoi=null;
publicRectanglewoi_veg=null;// extended woi to include offset vegetation
publicint[]used_veg=null;// corresponds to woi_veg - number of scene that use each pixel in woi_veg
// should be non-null everywhere where elevation is defined?
publicdouble[]vegetation_average;// full image average vegetation (with nulls)
publicdouble[]vegetation_filtered;// same as vegetation_average, but has more NaN to be used to select initial terrain
publicdouble[]vegetation_pull;// have nan far from vegetation, use to pull LMA to this
// 1: [4]/null Z-shape 4 corners vegetation, either >= as parameter index or -1 - (x + image_width*y) of the unmodified full index
...
...
@@ -100,7 +104,7 @@ public class VegetationLMA {
privateboolean[]used_scenes;// encode unused as NaN
// private int [] used_scenes_indices;
publicfinaldouble[]scene_weights;
publicboolean[]valid_scenes;
privatedouble[]parameters_vector=null;
privatedouble[]y_vector=null;
...
...
@@ -145,6 +149,7 @@ public class VegetationLMA {
publicdoubleterr_lpf=0;
publicdoubleveget_lpf=0;
publicdoubleelevation_lpf=0;
// when unsharp mask is applied , pulling to 0 (when alpha is 0 (for vegetation) or 1.0 (for terrain) makes sense
publicdoubleterr_pull0=0;// now - pull to filled terrain - terrain_average
...
...
@@ -164,6 +169,7 @@ public class VegetationLMA {
// - parameter index, <=-2 -2-full_pixel_index
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[][]elevation_neibs;// corresponds to parameters for elevation, for smoothing undefined elevations, similar to alpha_neibs
publicdoubledelta=1e-5;// 7;
...
...
@@ -356,7 +362,8 @@ public class VegetationLMA {
publicintprepareLMA(
finalbooleankeep_parameters,
finalRectanglewoi,
finalintmin_scenes,// minimal number of scenes (inside woi) vegetation pixel must influence
finalintmin_dependent_scenes,// minimal number of scenes (inside woi) vegetation pixel must influence
finalintmax_offset,// maximal "elevation" to consider
finalintmin_total_scenes,
finalintmin_samples_scene,// 10
finalintmin_valid_pixels,
...
...
@@ -388,6 +395,7 @@ public class VegetationLMA {
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
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,
finaldoubleterr_pull0,// pull terrain to zero (makes sense with UM
finaldoubleveget_pull0,// pull vegetation to zero (makes sense with UM
finaldoublescenes_pull0,
...
...
@@ -398,6 +406,8 @@ public class VegetationLMA {
Stringparameters_read_path,
finalintdebugLevel){
this.woi=woi;
this.min_dependent_scenes=min_dependent_scenes;
this.max_offset=max_offset;
doublealpha_contrast=1.0;
this.start_warm_veget=start_warm_veget;
this.terrain_warmest=terrain_warmest;
...
...
@@ -427,6 +437,7 @@ public class VegetationLMA {
this.alpha_mm_hole=alpha_mm_hole;
this.terr_lpf=terr_lpf;
this.veget_lpf=veget_lpf;
this.elevation_lpf=elevation_lpf;
this.terr_pull0=terr_pull0;
this.veget_pull0=veget_pull0;
this.scenes_pull0=scenes_pull0;
...
...
@@ -434,6 +445,31 @@ public class VegetationLMA {
this.um_sigma=um_sigma;// just use in debug image names
this.um_weight=um_weight;
valid_scenes=getValidScenes(max_offset);// final int max_offset)
woi_veg=newRectangle();
used_veg=vegetationWoi(
valid_scenes,// final boolean [] valid_scenes,
max_offset,// final int max_offset,
woi_veg);//final Rectangle woi_veg // should be initialized, will be modified
@@ -1407,6 +1407,7 @@ public class VegetationModel {
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
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)
doubleelevation_lpf=0;
doubleterr_pull0=clt_parameters.imp.terr_terr_pull0;// 0.05; //0.03; ////// 0.05; ///// 0.1; //// 0.01; /// 0.2; /// 0.1; //pull terrain to zero (makes sense with UM
doubleveget_pull0=clt_parameters.imp.terr_veget_pull0;// 0.05; //0.1; // 0.03; ////// 0.05; ///// 0.1; //// 0.01; /// 0.1; // pull vegetation to zero (makes sense with UM
@@ -1914,10 +1915,12 @@ public class VegetationModel {
}else{
System.out.println("===== Will process a single WOI ("+woi.x+", "+woi.y+", "+woi.width+", "+woi.height+").");
}
finalintmax_offset=22;// maximal "elevation" to consider
intnum_samples=vegetationLMA.prepareLMA(
false,// final boolean keep_parameters,
woi,// final Rectangle woi,
min_scenes,// final int min_scenes, // minimal number of scenes (inside woi) vegetation pixel must influence
min_scenes,// final int min_dependent_scenes, // minimal number of scenes (inside woi) vegetation pixel must influence
max_offset,// final int max_offset, // maximal "elevation" to consider
min_total_scenes,// final int min_total_scenes,
min_samples_scene,//final int min_samples_scene, // 10
min_pixels,// final int min_pixels,
...
...
@@ -1947,6 +1950,7 @@ public class VegetationModel {
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
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_pull0,// final double terr_pull0, // pull terrain to zero (makes sense with UM
veget_pull0,// final double veget_pull0, // pull vegetation to zero (makes sense with UM