This project has moved and is read-only. For the latest updates, please go here.

Magick.Net Compare Difference Image

Jan 7, 2015 at 2:42 PM
Edited Jan 7, 2015 at 2:43 PM

I am using C# code to interpret the difference of images generated by an IP camera and I am looking for help with changes between Magick.Net v6.8.9.601-Q8-AnyCPU and v7.0.0.0008-Q8-AnyCPU. I am getting completely different output/comparison images and error counts out of the Compare functions even though I am using the same input images and ColorFuzz parameter.

I posted sample images to illustrate the change:

From left to right, images A and B are the originals to be compared, and images c6 and c7 are the difference images generated by A.Compare(B, Absolute Error, C) in versions 6 and 7.

Are there parameters I can use to get v7 to generate the same difference image and error count as v6? I have tried various Channels parameters with v7 Compare and can't figure it out. Does this go back to a difference in how v6 and v7 handle color spaces?

Thank you!
Jan 7, 2015 at 6:05 PM
This might be a bug in IM7. Can you make sure I can download your files without a Google+ account? Can you also i clude a small code sample that I can use to reproduce the issue?
Jan 7, 2015 at 7:35 PM
Thank you for responding! I made the image files public and you should be able to download them, but I cannot upload code to an image hosting site -- could you suggest an alternate file hosting site and I'll post the code and images there? Would Dropbox allow me to upload files that you could anonymously access? Or I could also just paste the code in here.

And also, thank you very much for Magick.Net -- it has made image processing so much faster than running ImageMagick through a command shell process!
Jan 7, 2015 at 8:38 PM
Edited Jan 7, 2015 at 8:40 PM
Here is the code (v6 is identical with the exception of Metric.AbsoluteError):
    static void Main(string[] args)
        double dblHits;

        using (MagickImage objMI_A = new MagickImage("D:\\A.jpg"))
            using (MagickImage objMI_B = new MagickImage("D:\\B.jpg"))
                using (MagickImage objMI_C = new MagickImage())
                    objMI_A.ColorFuzz = new Percentage(30);
                    dblHits = objMI_A.Compare(objMI_B, ErrorMetric.Absolute, objMI_C);
Jan 7, 2015 at 10:20 PM
You can share files anonymous with Dropbox. I can confirm this is a bug in ImageMagick 7. I will get back to you when I know more.
Jan 9, 2015 at 7:46 AM
It turns out that due to the design changes in ImageMagick 7 you will get a different value. I have fixed the creation of the difference image in our svn repository. You will get almost the same image in the next version of Magick.NET. You probably need to adjust the percentage a little bit. I have created one with 30% and 37%. You can view the output here:
Marked as answer by mhenry79 on 1/3/2016 at 5:31 AM
Jan 9, 2015 at 12:14 PM
OK, thank you!