Compare two images using imagemagic-im4java and show differences with original image

241 views Asked by At

I am trying to compare two jpg images using im4java and showing difference between them. i have successfully done that but the output of difference image contrast is decreased. but i need to show the differences on output image with original contrast. I need to get result as diff without changing the contrast

public static void compareImageswithdifferenceimage (String expected, String actual, String difference) throws Exception {
        try {
            String Ipath="jars\\ImageMagick-7.0.10-Q16-HDRI";
            ProcessStarter.setGlobalSearchPath(Ipath);
            CompareCmd compare = new CompareCmd();
            //compare.setErrorConsumer(StandardStream.STDERR);
            IMOperation compareoperation = new IMOperation();
            //compareoperation.addRawArgs("compare");
            compareoperation.addImage(expected);
            compareoperation.addImage(actual);
            
            compareoperation.fuzz(1.0);
            //compareoperation.channel("red");
            compareoperation.metric("AE");
            compareoperation.transparentColor("Black");
           // compareoperation.fill("rgba(255, 215, 0, 0.1");
            //compareoperation.opaque("red");
           compareoperation.addImage(difference);
            try {
                System.out.println ("*******Comparison has Started********");
                compare.run(compareoperation);
                System.out.println ("*******Comparison has Finished*******");
                }
                catch (Exception e) {
                     System.out.println ("##### Comparison has Failed #######");
                     e.printStackTrace();
                }
            }
            catch(Exception exc) {
                System.out.println("Exception while executing compareImageswithdifferenceimage function");
                exc.printStackTrace();
    
        }
    }

Note : I am unable to post images here

0

There are 0 answers