Commit 16931433 by Andrey Filippov

### bug fixes, NaNs in eigen, blanking individual tiles with fpn

parent 388be26d
 ... @@ -2753,15 +2753,21 @@ public class Correlation2d { ... @@ -2753,15 +2753,21 @@ public class Correlation2d { } } x0 += sx / s0; // relative to top-left x0 += sx / s0; // relative to top-left y0 += sy / s0; y0 += sy / s0; //https://users.cs.utah.edu/~tch/CS4640/resources/A%20geometric%20interpretation%20of%20the%20covariance%20matrix.pdf //https://users.cs.utah.edu/~tch/CS4640/resources/A%20geometric%20interpretation%20of%20the%20covariance%20matrix.pdf double cxx = sx2 - sx * sx / s0, cyy= sy2 - sy * sy / s0, cxy = sxy - sx * sy / s0; double cxx = sx2 - sx * sx / s0, cyy= sy2 - sy * sy / s0, cxy = sxy - sx * sy / s0; if ((sx2 == 0) ||(sy2 == 0) || (cxx == 0) || (cyy == 0)){ return null; } double [][] acovar = {{cxx, cxy},{cxy,cyy}}; double [][] acovar = {{cxx, cxy},{cxy,cyy}}; // TODO: calculate for 2x2 faster? // TODO: calculate for 2x2 faster? double [] xy = {x0-center_xy, y0-center_xy}; // relative to the center double [] xy = {x0-center_xy, y0-center_xy}; // relative to the center double [] rslt; double [] rslt; if (eig_fast2x2) { if (eig_fast2x2) { double [] eig = getEigen2x2(acovar); double [] eig = getEigen2x2(acovar); if (eig == null) { return null; } rslt = new double[] { rslt = new double[] { xy[0], // x0 - center_xy, xy[0], // x0 - center_xy, xy[1], // y0 - center_xy, xy[1], // y0 - center_xy, ... @@ -2787,13 +2793,19 @@ public class Correlation2d { ... @@ -2787,13 +2793,19 @@ public class Correlation2d { eigval[1-eig_indx]}; eigval[1-eig_indx]}; if (debug){ if (debug){ double [] r = getEigen2x2(acovar); double [] r = getEigen2x2(acovar); System.out.println(String.format("%10f %10f", rslt[3], r[0])); if (r!= null) { System.out.println(String.format("%10f %10f", rslt[4], r[1])); System.out.println(String.format("%10f %10f", rslt[3], r[0])); System.out.println(String.format("%10f %10f", rslt[5], r[2])); System.out.println(String.format("%10f %10f", rslt[4], r[1])); System.out.println(String.format("%10f %10f", rslt[6], r[3])); System.out.println(String.format("%10f %10f", rslt[5], r[2])); System.out.println(String.format("%10f %10f", rslt[6], r[3])); } else { System.out.println("Got null from getEigen2x2()"); } } } } } if (Double.isNaN(rslt[3])) { System.out.println("getMaxXYCmEig(): Got NaN"); } if (debug){ if (debug){ System.out.println("getMaxXYCm() -> "+rslt[0]+":"+rslt[1]+" ("+rslt[2]+ System.out.println("getMaxXYCm() -> "+rslt[0]+":"+rslt[1]+" ("+rslt[2]+ ... @@ -2882,10 +2894,18 @@ public class Correlation2d { ... @@ -2882,10 +2894,18 @@ public class Correlation2d { } } double [] lambda = {hapd-d, hapd+d}; double [] lambda = {hapd-d, hapd+d}; double [] v0 = {A[0][0] - lambda[1], A[1][0]}; double [] v0 = {A[0][0] - lambda[1], A[1][0]}; double k = 1.0/Math.sqrt(v0[0]*v0[0] + v0[1]*v0[1]); double l = Math.sqrt(v0[0]*v0[0] + v0[1]*v0[1]); if (l==0) { return null; } double k = 1.0/l; if (v0[0] < 0) { // to be compatible with standard? if (v0[0] < 0) { // to be compatible with standard? k = -k; k = -k; } } if (Double.isNaN(k) || Double.isNaN(v0[0])) { System.out.println("getEigen2x2(): Got NaN"); } return new double [] {k*v0[0], k*v0[1], lambda[0], lambda[1]}; return new double [] {k*v0[0], k*v0[1], lambda[0], lambda[1]}; } } ... ...