0

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

  • 1
    Please post your actual images to some free hosting service and put the URLs here so we can see what the issue might be. You could try the java equivalent of `convert image1.jpg image2.jpg -compose difference -composite -auto-level diff.png` – fmw42 Oct 06 '20 at 17:32
  • Thannks @fmw42 i am unable to post images. i pasted code and it is working, here compare method results the change in contrast of original image and showing the difference.but i need the diff image to show only diff on image1 or image 2 – raghu veer Karumuri Oct 07 '20 at 04:03
  • i saw the below page https://stackoverflow.com/questions/57655453/imagemagick-to-compare-2-images-marked-with-2-different-color-on-the-output-ima the difference shows with underline, but for my usecase, i need those under lines to be shown by cloning one of the actual image. – raghu veer Karumuri Oct 07 '20 at 09:19
  • If your images are proprietary, can you post some representative image that show the kind of difference you have? Are the images of real world scenes or graphics? – fmw42 Oct 07 '20 at 17:20

0 Answers0