Exemple #1
0
  public static void huMoments(String filename) {

    normalisedMoments(filename);
    Mat m = Imgcodecs.imread(filename, Imgcodecs.CV_LOAD_IMAGE_ANYCOLOR);

    double[] mo = Shape.huMoments(m, m);
    for (int i = 0; i < mo.length; i++) {
      System.out.println("hu" + (i + 1) + " = " + mo[i]);
    }
  }
Exemple #2
0
  public static void centralMoments(String filename) {
    Mat m = Imgcodecs.imread(filename, Imgcodecs.CV_LOAD_IMAGE_ANYCOLOR);

    //		System.out.println(m.get(9, 0)[0]);
    double u00 = Shape.getCentralMoment(m, m, 0, 0);
    double u10 = Shape.getCentralMoment(m, m, 1, 0);
    double u20 = Shape.getCentralMoment(m, m, 2, 0);
    double u30 = Shape.getCentralMoment(m, m, 3, 0);
    double u40 = Shape.getCentralMoment(m, m, 4, 0);
    double u50 = Shape.getCentralMoment(m, m, 5, 0);

    System.out.println("u00 = " + u00);
    System.out.println("u10 = " + u10);
    System.out.println("u20 = " + u20);
    System.out.println("u30 = " + u30);
    System.out.println("u40 = " + u40);
    System.out.println("u50 = " + u50);
    System.out.println();

    double u01 = Shape.getCentralMoment(m, m, 0, 1);
    double u11 = Shape.getCentralMoment(m, m, 1, 1);
    double u21 = Shape.getCentralMoment(m, m, 2, 1);
    double u31 = Shape.getCentralMoment(m, m, 3, 1);
    double u41 = Shape.getCentralMoment(m, m, 4, 1);
    double u51 = Shape.getCentralMoment(m, m, 5, 1);

    System.out.println("u01 = " + u01);
    System.out.println("u11 = " + u11);
    System.out.println("u21 = " + u21);
    System.out.println("u31 = " + u31);
    System.out.println("u41 = " + u41);
    System.out.println("u51 = " + u51);
    System.out.println();

    double u02 = Shape.getCentralMoment(m, m, 0, 2);
    double u12 = Shape.getCentralMoment(m, m, 1, 2);
    double u22 = Shape.getCentralMoment(m, m, 2, 2);
    double u32 = Shape.getCentralMoment(m, m, 3, 2);
    double u42 = Shape.getCentralMoment(m, m, 4, 2);
    double u52 = Shape.getCentralMoment(m, m, 5, 2);

    System.out.println("u02 = " + u02);
    System.out.println("u12 = " + u12);
    System.out.println("u22 = " + u22);
    System.out.println("u32 = " + u32);
    System.out.println("u42 = " + u42);
    System.out.println("u52 = " + u52);
    System.out.println();

    double u03 = Shape.getCentralMoment(m, m, 0, 3);
    double u13 = Shape.getCentralMoment(m, m, 1, 3);
    double u23 = Shape.getCentralMoment(m, m, 2, 3);
    double u33 = Shape.getCentralMoment(m, m, 3, 3);
    double u43 = Shape.getCentralMoment(m, m, 4, 3);
    double u53 = Shape.getCentralMoment(m, m, 5, 3);

    System.out.println("u03 = " + u03);
    System.out.println("u13 = " + u13);
    System.out.println("u23 = " + u23);
    System.out.println("u33 = " + u33);
    System.out.println("u43 = " + u43);
    System.out.println("u53 = " + u53);
    System.out.println();

    double u04 = Shape.getCentralMoment(m, m, 0, 4);
    double u14 = Shape.getCentralMoment(m, m, 1, 4);
    double u24 = Shape.getCentralMoment(m, m, 2, 4);
    double u34 = Shape.getCentralMoment(m, m, 3, 4);
    double u44 = Shape.getCentralMoment(m, m, 4, 4);
    double u54 = Shape.getCentralMoment(m, m, 5, 4);

    System.out.println("u04 = " + u04);
    System.out.println("u14 = " + u14);
    System.out.println("u24 = " + u24);
    System.out.println("u34 = " + u34);
    System.out.println("u44 = " + u44);
    System.out.println("u54 = " + u54);
    System.out.println();

    double u05 = Shape.getCentralMoment(m, m, 0, 5);
    double u15 = Shape.getCentralMoment(m, m, 1, 5);
    double u25 = Shape.getCentralMoment(m, m, 2, 5);
    double u35 = Shape.getCentralMoment(m, m, 3, 5);
    double u45 = Shape.getCentralMoment(m, m, 4, 5);
    double u55 = Shape.getCentralMoment(m, m, 5, 5);

    System.out.println("u05 = " + u05);
    System.out.println("u15 = " + u15);
    System.out.println("u25 = " + u25);
    System.out.println("u35 = " + u35);
    System.out.println("u45 = " + u45);
    System.out.println("u55 = " + u55);
    System.out.println();
  }