imageimage-processingimagemagickjmagickmagick.net

Compare images with metric PSNR in ImageMagick using Java API (JMagick) or C# API (Magick.Net)


Could you help me to implement image comparison with metric PSNR in ImageMagick using Java API (JMagick) or C# API (Magick.Net).

The command is:

convert image1.jpg -resize WidthxHeight image2.jpg -metric PSNR -format "%[distortion]" -compare info:

I've tried to find something in documentation about JMagick here: http://www.jmagick.org/jmagick-doc/ and about Magick.NET here: http://magick.codeplex.com/documentation without result.

Thanks for your help.


Solution

  • I am the author of the Magick.NET API so I can only help you with the Magick.NET part.

    Magick.NET

    using (MagickImage image1 = new MagickImage("image1.jpg"))
    {
      using (MagickImage image2 = new MagickImage("image2.jpg"))
      {
        double distortion = image1.Compare(image2, ErrorMetric.PeakSignalToNoiseRatio);
      }
    }
    

    Feel free to edit my answer and add an example for JMagick.