0

I-1 と I-2 の 2 つの画像があり、im4java を使用してこれら 2 つの画像を比較することができました。ただし、I-1 と I-2 のサイズが異なるため、これら 2 つの画像を比較しようとすると、比較されず、メッセージが表示されます

例: org.im4java.core.CommandException: org.im4java.core.CommandException: compare.exe: 画像の幅または高さが異なります `C:\Users\hp\workspace-getlinks-multipurpose\links_extractor/snapshots/actuals/id-dashboard .jpg' @ error/compare.c/CompareImageCommand/990.

以下は私のコードです:

      public static boolean compareImages(String exp, String cur,String output) {


    // This instance wraps the compare command
    CompareCmd compare = new CompareCmd();

    // For metric-output
    //compare.setErrorConsumer(StandardStream.STDERR);

    IMOperation cmpOp = new IMOperation();
    // Set the compare metric
    cmpOp.metric("mae");


//  cmpOp.addSubOperation(subimageSearch());

    // Add the expected image
    cmpOp.addImage(exp);

    // Add the current image
    cmpOp.addImage(cur);

    // This stores the difference
    cmpOp.addImage(output); 

    try {
        // Do the compare
        compare.run(cmpOp);

        return true;

    } catch (Exception ex) {

        System.out.println("ex: "+ex);

        return false;

    }
}
4

1 に答える 1

0

Pawan の方法に加えて、phash メトリックを使用することもできます: compare -metric phash image2.png image1.png cmp.png

于 2016-11-10T15:37:51.880 に答える