Ejemplo n.º 1
0
  /**
   * Sum of absolute difference (SAD) score
   *
   * @param a First descriptor
   * @param b Second descriptor
   * @return SAD score
   */
  public static double sad(TupleDesc_F64 a, TupleDesc_F64 b) {

    double total = 0;
    for (int i = 0; i < a.value.length; i++) {
      total += Math.abs(a.value[i] - b.value[i]);
    }
    return total;
  }
Ejemplo n.º 2
0
  /**
   * Sum of absolute difference (SAD) score
   *
   * @param a First descriptor
   * @param b Second descriptor
   * @return SAD score
   */
  public static int sad(TupleDesc_S8 a, TupleDesc_S8 b) {

    int total = 0;
    for (int i = 0; i < a.value.length; i++) {
      total += Math.abs(a.value[i] - b.value[i]);
    }
    return total;
  }
Ejemplo n.º 3
0
  /**
   * Sum of absolute difference (SAD) score
   *
   * @param a First descriptor
   * @param b Second descriptor
   * @return SAD score
   */
  public static float sad(TupleDesc_F32 a, TupleDesc_F32 b) {

    float total = 0;
    for (int i = 0; i < a.value.length; i++) {
      total += Math.abs(a.value[i] - b.value[i]);
    }
    return total;
  }
Ejemplo n.º 4
0
  /**
   * Sum of absolute difference (SAD) score
   *
   * @param a First descriptor
   * @param b Second descriptor
   * @return SAD score
   */
  public static int sad(TupleDesc_U8 a, TupleDesc_U8 b) {

    int total = 0;
    for (int i = 0; i < a.value.length; i++) {
      total += Math.abs((a.value[i] & 0xFF) - (b.value[i] & 0xFF));
    }
    return total;
  }
Ejemplo n.º 5
0
  /**
   * Returns the Euclidean distance (L2-norm) between the two descriptors.
   *
   * @param a First descriptor
   * @param b Second descriptor
   * @return Euclidean distance
   */
  public static double euclidean(TupleDesc_F64 a, TupleDesc_F64 b) {
    final int N = a.value.length;
    double total = 0;
    for (int i = 0; i < N; i++) {
      double d = a.value[i] - b.value[i];
      total += d * d;
    }

    return Math.sqrt(total);
  }