0

i have two images I-1 and I-2, i was able to compare these two images using im4java successfully. However now I-1 and I-2 has different size and therefore when i try to compare these two images it do not compare them and gives message

ex: org.im4java.core.CommandException: org.im4java.core.CommandException: compare.exe: image widths or heights differ `C:\Users\hp\workspace-getlinks-multipurpose\links_extractor/snapshots/actuals/id-dashboard.jpg' @ error/compare.c/CompareImageCommand/990.

Following is my code:

      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;

    }
}
Pawan
  • 153
  • 2
  • 3
  • 15
  • i have done some RnD and i could see something like subimage-search which can be used from imageMagik + cmd prompt **compare -metric rmse -subimage-search image2.png image1.png cmp.png** – Pawan Jun 24 '16 at 07:14

1 Answers1

0

Another option in addition to Pawan's is to use the phash metric: compare -metric phash image2.png image1.png cmp.png

AMichaud
  • 21
  • 2