Example #1
0
  /**
   * Gets mappings computed from specified slopes and planarities.
   *
   * @param s1 sampling of 1st dimension.
   * @param s2 sampling of 2nd dimension.
   * @param p2 array of slopes of image features.
   * @param ep array of planarities of image features.
   */
  public Mappings getMappingsFromSlopes(
      Sampling s1, Sampling s2, Sampling s3, float[][][] p2, float[][][] p3, float[][][] ep) {
    // Sampling parameters.
    final int n1 = s1.getCount();
    final int n2 = s2.getCount();
    final int n3 = s3.getCount();
    float d1 = (float) s1.getDelta();
    float d2 = (float) s2.getDelta();
    float d3 = (float) s3.getDelta();
    float f1 = (float) s1.getFirst();

    // If necessary, convert units for slopes to samples per sample.
    if (d1 != d2) p2 = mul(d2 / d1, p2);
    if (d1 != d3) p3 = mul(d3 / d1, p3);

    // Compute shifts r(x1,x2,x3), in samples.
    float[][][] b = new float[n3][n2][n1]; // right-hand side
    float[][][] r = new float[n3][n2][n1]; // shifts, in samples
    VecArrayFloat3 vb = new VecArrayFloat3(b);
    VecArrayFloat3 vr = new VecArrayFloat3(r);
    Smoother3 smoother3 = new Smoother3(n1, n2, n3, _sigma1, _sigma2, _sigma3, ep);
    A3 a3 = new A3(smoother3, _weight1, ep, p2, p3);
    CgSolver cs = new CgSolver(_small, _niter);
    makeRhs(ep, p2, p3, b);
    smoother3.applyTranspose(b);
    cs.solve(a3, vb, vr);
    smoother3.apply(r);
    cleanShifts(r);

    // Compute u1(x1,x2,x3).
    final float[][][] u1 = r;
    for (int i3 = 0; i3 < n3; ++i3) {
      for (int i2 = 0; i2 < n2; ++i2) {
        for (int i1 = 0; i1 < n1; ++i1) {
          float x1i = f1 + i1 * d1;
          u1[i3][i2][i1] = x1i + r[i3][i2][i1] * d1;
        }
      }
    }

    // Compute x1(u1,u2).
    final float[][][] x1 = b;
    final InverseInterpolator ii = new InverseInterpolator(s1, s1);
    Parallel.loop(
        n3,
        new Parallel.LoopInt() {
          public void compute(int i3) {
            for (int i2 = 0; i2 < n2; ++i2) ii.invert(u1[i3][i2], x1[i3][i2]);
          }
        });

    return new Mappings(s1, s2, s3, u1, x1);
  }
Example #2
0
 private static float[] getValues(Sampling s) {
   int n = s.getCount();
   double f = s.getFirst();
   double d = s.getDelta();
   float[] x = new float[n];
   for (int i = 0; i < n; i++) x[i] = (float) (f + i * d);
   return x;
 }
Example #3
0
 /**
  * Gets the flattening shifts s(u1,u2,u3) = u1 - x1(u1,u2,u3).
  *
  * @return the flattening shifts.
  */
 public float[][][] getShiftsS() {
   int n1 = s1.getCount();
   int n2 = s2.getCount();
   int n3 = s3.getCount();
   float[][][] s = new float[n3][n2][n1];
   float d1 = (float) s1.getDelta();
   float f1 = (float) s1.getFirst();
   for (int i3 = 0; i3 < n3; ++i3) {
     for (int i2 = 0; i2 < n2; ++i2) {
       for (int i1 = 0; i1 < n1; ++i1) {
         float u1i = f1 + i1 * d1;
         s[i3][i2][i1] = u1i - x1[i3][i2][i1];
       }
     }
   }
   return s;
 }
Example #4
0
 private float[][][] apply(final float[][][] ux, final float[][][] f) {
   final int n1 = s1.getCount();
   final int n2 = s2.getCount();
   final int n3 = s3.getCount();
   final double d1 = s1.getDelta();
   final double f1 = s1.getFirst();
   final SincInterpolator si = new SincInterpolator();
   final float[][][] g = new float[n3][n2][n1];
   Parallel.loop(
       n3,
       new Parallel.LoopInt() {
         public void compute(int i3) {
           for (int i2 = 0; i2 < n2; ++i2)
             si.interpolate(n1, d1, f1, f[i3][i2], n1, ux[i3][i2], g[i3][i2]);
         }
       });
   return g;
 }
Example #5
0
 /**
  * Computes gammaS, a measure of the time delay between two split shear waves, from shifts between
  * PP-PS2 {@code u2} and PS1-PS2 {@code uS}.
  *
  * @param sf PP time Sampling.
  * @param u2 shifts between PP-PS2 in PP time.
  * @param uS shifts between PS1-PS2 in PP time.
  * @return gammaS
  */
 public static float[] gammaSu2S(Sampling sf, float[] u2, float[] uS) {
   int n1 = u2.length;
   Check.argument(n1 == sf.getCount(), "u2 consistent with sampling");
   Check.argument(n1 == uS.length, "u2.length==uS.length");
   float[] du2 = firstDerivative(sf, u2);
   float[] duS = firstDerivative(sf, uS);
   float[] gs = new float[n1];
   for (int i1 = 0; i1 < n1; i1++) gs[i1] = (2.0f * duS[i1]) / (1.0f + 2.0f * (du2[i1] - duS[i1]));
   return gs;
 }