1

I need to do a "fuzzy" image comparison in c# - I have used ImageMagick.NET for stuff in the past and know it's good for the job.

There is a compare command in Image Magick: http://www.imagemagick.org/script/compare.php

And there is a Compare(Image reference) method in ImageMagick.NET however it seems that it's be hugely simplified so there is no way of getting at the verbose output.

I need to be able to get at that so I can match the images using a threshold. Am I missing something - is there a way to get this stuff into ImageMagick.NET if there isn't already? (I'm no C++ dev by a long shot) or am I barking up the wrong tree?

Bo Persson
  • 90,663
  • 31
  • 146
  • 203

1 Answers1

2

Pardon me if I don't get your question, but won't IsImagesEqual or SimilarityImage work?

IsImagesEqual returns "The normalized maximum quantization error for any single pixel in the image. This distance measure is normalized to a range between 0 and 1. It is independent of the range of red, green, and blue values in your image.

A small normalized mean square error, accessed as image->normalized_mean_error, suggests the images are very similar in spatial layout and color."

The corresponding method in the .NET bindings is Image.Compare which takes an image and returns a bool. However, if the result is false - the mean error (according to the metric above) is set on the current instance's meanErrorPerPixel, normalizedMaxError, and normalizedMeanError.

Aren't these three metrics enough to give you the result of your "fuzzy" compare?

Ian Kemp
  • 28,293
  • 19
  • 112
  • 138
Ani
  • 10,826
  • 3
  • 27
  • 46
  • where did you learn about this? also, Image doesn't have those properties? meanErrorPerPixel, normalizedMaxError, and normalizedMeanError - where do I fond them? –  May 15 '12 at 07:18
  • I looked those up from the C/C++ API, but you're right - those properties have not been exposed, as the code (Image.h) shows here http://imagemagick.codeplex.com/SourceControl/changeset/view/34174#489191. You will need to add the appropriate code to these bindings in order to use this feature or request the maintainer to do it for you. It should be a fairly simple addition, though. Follow the same pattern as the Rows and Height property defined toward the end of that file. – Ani May 15 '12 at 14:50
  • And if you did implement it yourself, please provide a patch so the maintainer can add that feature ;-) – tobsen May 15 '12 at 17:03
  • 3
    Here you go, here's a patch with the properties added (http://pastebin.com/Rbb8L5RC). Download the sources using Subversion, also get the binary download (this includes the headers). Copy include8 and include16 inside the ImageMagickNET folder that's alongside the sln, then simply apply the supplied patch to Image.h and build. I'll contribute this to the maintainer as well. – Ani May 15 '12 at 18:07