【问题标题】:How to compare images of different sizes using im4java如何使用 im4java 比较不同大小的图像
【发布时间】:2016-06-24 07:11:30
【问题描述】:

我有两个图像 I-1 和 I-2,我能够成功地使用 im4java 比较这两个图像。但是现在 I-1 和 I-2 的大小不同,因此当我尝试比较这两个图像时,它不会比较它们并给出消息

ex: 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;

    }
}

【问题讨论】:

  • 我做了一些 RnD,我可以看到类似 subimage-search 的东西,可以从 imageMagik + cmd 提示符 compare -metric rmse -subimage-search image2.png image1.png cmp 中使用。 png

标签: java imagemagick im4java


【解决方案1】:

除了 Pawan 的另一个选项是使用 phash 度量:compare -metric phash image2.png image1.png cmp.png

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多