Commit 4fefd6d1 authored by Andrey Filippov's avatar Andrey Filippov

Next working snapshot

parent e8c48eba
...@@ -1011,22 +1011,46 @@ public class VegetationLMA { ...@@ -1011,22 +1011,46 @@ public class VegetationLMA {
} }
avg /= nn; // average avg /= nn; // average
if (alpha_push > 0) { if (alpha_push > 0) {
/*
* p = alpha_push
* n = alpha_push_neutral
* a0 = p/(2 * n)
* a1 = p/(2 * (1 - n))
* f1(x) = p/(2 * n)* x * (1 - x/(2*n))
* f2(x) = p * (x - 2*n + 1) * (1 - x) / (4 * (1-n)*(1-n)
* df1(x)/dx = p/(2 * n^2 )*( n - x)
* df2(x)/dx = p* (n-x)/(2*(1-n)^2)
*/
// average including center: // average including center:
double sum_w = (nn + alpha_push_center); double sum_w = (nn + alpha_push_center);
double avg_c = (avg * nn + vector[np] * alpha_push_center) / sum_w; double avg_c = (avg * nn + vector[np] * alpha_push_center) / sum_w;
double one_minus_n = 1.0 - alpha_push_neutral;
double one_minus_p = 1.0 - alpha_push;
double x_minus_p = avg_c - alpha_push;
if ((avg_c > 0) || (avg_c < 1.0)) { if ((avg_c > 0) || (avg_c < 1.0)) {
fX[nx] += alpha_push * avg_c * (1.0 - avg_c); // fX[nx] += alpha_push * avg_c * (1.0 - avg_c);
} if (avg_c <= alpha_push_neutral) {
if (jt != null) { fX[nx] += alpha_push / (2 * alpha_push_neutral) * avg_c * (1 - avg_c / (2 * alpha_push_neutral));
double dd = alpha_push / sum_w * (1 - 2 * avg_c); } else {
jt[np][nx] += dd * alpha_push_center; // 2 * alpha_loss * d; // d/dalpha[i] fX[nx] += alpha_push * (avg_c - 2 * alpha_push_neutral + 1) * (1 - avg_c) / (4 *one_minus_n*one_minus_n);
for (int i = 0; i < alpha_neibs[n].length; i++) { // now 4, may be increased
int di = alpha_neibs[n][i];
if (di >= 0) {
jt[di][nx] += dd; // 2 * alpha_loss * d; // d/dalpha[i]
}
} }
} if (jt != null) {
// double dd = alpha_push / sum_w * (1 - 2 * avg_c);
double dd;
if (avg_c <= alpha_push_neutral) {
dd = alpha_push / (sum_w * 2 * alpha_push_neutral * alpha_push_neutral ) * (alpha_push_neutral - avg_c);
} else {
dd = alpha_push / (sum_w * 2 * one_minus_n * one_minus_n) * (alpha_push_neutral - avg_c);
}
jt[np][nx] += dd * alpha_push_center; // 2 * alpha_loss * d; // d/dalpha[i]
for (int i = 0; i < alpha_neibs[n].length; i++) { // now 4, may be increased
int di = alpha_neibs[n][i];
if (di >= 0) {
jt[di][nx] += dd; // 2 * alpha_loss * d; // d/dalpha[i]
}
}
}
}
} }
} }
} }
......
...@@ -679,6 +679,7 @@ public class VegetationModel { ...@@ -679,6 +679,7 @@ public class VegetationModel {
boolean diff_mode = true; boolean diff_mode = true;
// Rectangle woi50 = new Rectangle(143,317,35,35); // Rectangle woi50 = new Rectangle(143,317,35,35);
Rectangle woi50 = new Rectangle(160,317,35,35); // X+17 Rectangle woi50 = new Rectangle(160,317,35,35); // X+17
// Rectangle woi50 = new Rectangle(177,317,35,35); // X+34
/* Bad, pull terr lower, so it all shifts to terrain /* Bad, pull terr lower, so it all shifts to terrain
int min_scenes = 10; int min_scenes = 10;
double default_alpha = 0.8; double default_alpha = 0.8;
...@@ -708,11 +709,11 @@ public class VegetationModel { ...@@ -708,11 +709,11 @@ public class VegetationModel {
double reg_weights = 0.25; // fraction of the total weight used for regularization double reg_weights = 0.25; // fraction of the total weight used for regularization
double alpha_loss = 100.0; // 10.0; /// 100.0; // 10.0; // 10000.0; // 1000.0; // 100.; // 10.0; // quadratic loss when alpha reaches -1.0 or 2.0 double alpha_loss = 100.0; // 10.0; /// 100.0; // 10.0; // 10000.0; // 1000.0; // 100.; // 10.0; // quadratic loss when alpha reaches -1.0 or 2.0
double alpha_offset = 0.0; // 0.02; // 0.03; // if >0, start losses above 0.0 and below 1.0; double alpha_offset = 0.0; // 0.02; // 0.03; // if >0, start losses above 0.0 and below 1.0;
double alpha_lpf = 5; /// 10; /// 15; // 10.0; // 5.0; // 10.0; // 3; // 10; // 20; // 6.0; // 3.0; // 2.0; // 1.5; // 5.0; // 0.5; // pull to average of 4 neighbors double alpha_lpf = 2; // 5; /// 10; /// 15; // 10.0; // 5.0; // 10.0; // 3; // 10; // 20; // 6.0; // 3.0; // 2.0; // 1.5; // 5.0; // 0.5; // pull to average of 4 neighbors
boolean alpha_piece_linear = true; // false; // true; boolean alpha_piece_linear = true; // false; // true;
double alpha_scale_avg = 1.0; // 1.1; // 0.9; // 2.0; // 1.5; // scale average alpha (around 0.5) when pulling to it double alpha_scale_avg = 1.0; // 1.1; // 0.9; // 2.0; // 1.5; // scale average alpha (around 0.5) when pulling to it
double alpha_push = 12; // 10.0; // 15.0; // push from alpha==0.5 double alpha_push = 12; // 10.0; // 15.0; // push from alpha==0.5
double alpha_push_neutral = 0.8; // alpha point from which push (closer to opaque) double alpha_push_neutral = 0.5; // 0.6; // 0.8; // alpha point from which push (closer to opaque)
double alpha_push_center = 1.5; // weight of center alpha pixel relative to each of the 4 ortho ones double alpha_push_center = 1.5; // weight of center alpha pixel relative to each of the 4 ortho ones
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 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
...@@ -857,7 +858,7 @@ public class VegetationModel { ...@@ -857,7 +858,7 @@ public class VegetationModel {
double lambda_max = 1000; double lambda_max = 1000;
boolean last_run = false; boolean last_run = false;
double rms_diff = 1e-8; // 0.0001; virtually forever double rms_diff = 1e-8; // 0.0001; virtually forever
int num_iter = 100; int num_iter = 30; // 100;
vegetationLMA.debug_index = 0; vegetationLMA.debug_index = 0;
vegetationLMA.debug_image = new double [num_iter][]; vegetationLMA.debug_image = new double [num_iter][];
......
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