コード例 #1
0
 @Test
 public void testSimilarityImageHashFromColorDeviation() throws Exception {
   assertTrue(
       HashSimilarity.getSimilarityFromHash(
               ImageSimilarity.getImageHashFromColorDeviation(similar1b),
               ImageSimilarity.getImageHashFromColorDeviation(similar1a))
           > .75);
   assertTrue(
       HashSimilarity.getSimilarityFromHash(
               ImageSimilarity.getImageHashFromColorDeviation(similar3b),
               ImageSimilarity.getImageHashFromColorDeviation(similar3a))
           > .75);
   assertTrue(
       HashSimilarity.getSimilarityFromHash(
               ImageSimilarity.getImageHashFromColorDeviation(similar3b),
               ImageSimilarity.getImageHashFromColorDeviation(different))
           < .75);
   assertEquals(
       HashSimilarity.getSimilarityFromHash(
           ImageSimilarity.getImageHashFromColorDeviation(different),
           ImageSimilarity.getImageHashFromColorDeviation(different)),
       1,
       0.0001);
 }
コード例 #2
0
  @Test
  public void testSimilarityImageHashFromSignature() throws Exception {
    if (similar1a != null
        && similar1b != null
        && different != null
        && similar2b != null
        && similar2a != null) {

      assertTrue(
          HashSimilarity.getSimilarityFromHash(
                  ImageSimilarity.getImageHashFromSignature(similar1a),
                  ImageSimilarity.getImageHashFromSignature(similar1b))
              >= .75);
      assertTrue(
          HashSimilarity.getSimilarityFromHash(
                  ImageSimilarity.getImageHashFromSignature(similar2a),
                  ImageSimilarity.getImageHashFromSignature(similar2b))
              >= .75);
      assertTrue(
          HashSimilarity.getSimilarityFromHash(
                  ImageSimilarity.getImageHashFromSignature(similar3a),
                  ImageSimilarity.getImageHashFromSignature(similar3b))
              >= .75);
      assertTrue(
          HashSimilarity.getSimilarityFromHash(
                  ImageSimilarity.getImageHashFromSignature(different),
                  ImageSimilarity.getImageHashFromSignature(different))
              >= .75);

      assertTrue(
          HashSimilarity.getSimilarityFromHash(
                  ImageSimilarity.getImageHashFromSignature(similar1a),
                  ImageSimilarity.getImageHashFromSignature(different))
              < .75);
      assertTrue(
          HashSimilarity.getSimilarityFromHash(
                  ImageSimilarity.getImageHashFromSignature(similar1a),
                  ImageSimilarity.getImageHashFromSignature(different))
              < .75);
      assertTrue(
          HashSimilarity.getSimilarityFromHash(
                  ImageSimilarity.getImageHashFromSignature(similar1a),
                  ImageSimilarity.getImageHashFromSignature(different))
              < .75);

      /* System.out.println("1a:1b "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromColorDeviation(similar1a),ImageSimilarity.getImageHashFromColorDeviation(similar1b)));
                  System.out.println("3a:3b "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromColorDeviation(similar3a),ImageSimilarity.getImageHashFromColorDeviation(similar3b)));
                  System.out.println("2a:2b "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromColorDeviation(similar2a),ImageSimilarity.getImageHashFromColorDeviation(similar2b))+"\n");
                  System.out.println("1a:2a "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromColorDeviation(similar1a),ImageSimilarity.getImageHashFromColorDeviation(similar2a)));
                  System.out.println("3a:2b "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromColorDeviation(similar3a),ImageSimilarity.getImageHashFromColorDeviation(similar2b)));
                  System.out.println("3b:1a "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromColorDeviation(similar3b),ImageSimilarity.getImageHashFromColorDeviation(similar1a)));
                  System.out.println("1b:2b "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromColorDeviation(similar1b),ImageSimilarity.getImageHashFromColorDeviation(similar2b))+"\n");


                  System.out.println("1a:d "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromColorDeviation(similar1a),ImageSimilarity.getImageHashFromColorDeviation(different)));
                  System.out.println("1a:d "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromColorDeviation(similar1a),ImageSimilarity.getImageHashFromColorDeviation(different)));
                  System.out.println("2a:d "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromColorDeviation(similar2a),ImageSimilarity.getImageHashFromColorDeviation(different)));
                  System.out.println("2b:d "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromColorDeviation(similar2b),ImageSimilarity.getImageHashFromColorDeviation(different))+"\n\n");

                  System.out.println("1a:1b "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromSignature(similar1a),ImageSimilarity.getImageHashFromSignature(similar1b)));
                  System.out.println("3a:3b "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromSignature(similar3a),ImageSimilarity.getImageHashFromSignature(similar3b)));
                  System.out.println("2a:2b "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromSignature(similar2a),ImageSimilarity.getImageHashFromSignature(similar2b))+"\n");
                  System.out.println("1a:2a "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromSignature(similar1a),ImageSimilarity.getImageHashFromSignature(similar2a)));
                  System.out.println("3a:2b "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromSignature(similar3a),ImageSimilarity.getImageHashFromSignature(similar2b)));
                  System.out.println("3b:1a "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromSignature(similar3b),ImageSimilarity.getImageHashFromSignature(similar1a)));
                  System.out.println("1b:2b "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromSignature(similar1b),ImageSimilarity.getImageHashFromSignature(similar2b))+"\n");


                  System.out.println("1a:d "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromSignature(similar1a),ImageSimilarity.getImageHashFromSignature(different)));
                  System.out.println("1a:d "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromSignature(similar1a),ImageSimilarity.getImageHashFromSignature(different)));
                  System.out.println("2a:d "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromSignature(similar2a),ImageSimilarity.getImageHashFromSignature(different)));
                  System.out.println("2b:d "+HashSimilarity.getSimilarityFromHash(ImageSimilarity.getImageHashFromSignature(similar2b),ImageSimilarity.getImageHashFromSignature(different)));

      */

    }
  }