In my
previous blog post, I have demonstrated the quickest way to identify whether 2
images are identical or different using C#. In this
blog post, I will show you how to check exactly the visual difference between 2
different images using Image Magick compare tool.
Hello.bmp – Standard
HelloWorld.bmp – Image for Comparison
Step 3: Open command prompt and then type the command following below syntax
Command line Image Comparison using Compare.exe
Syntax:
Compare.exe –metric type InputImageFullPath1 InputImageFullPath2 DifferenceImageFullPath
Ex: –metric AE - Here AE represents absolute error. This will report the standard error with the number of pixel counts that were actually masked in the difference output.
InputImageFullPath1 – Provide full path for the standard image.
InputImageFullPath2 – provide full path for the image which you want to compare with the standard image
DifferenceImageFullPath – Provide full path to save the difference output image.
DiffHelloWorld.bmp
Here in the
output image the difference is masked with red color.
ImageMagick
is a software suite to create, edit, compose, or convert bitmap images. Use
ImageMagick to resize, flip, mirror, rotate, distort, shear and transform
images, adjust image colors, apply various special effects, or draw text,
lines, polygons, ellipses and Bézier curves. Here, I am going to demonstrate
Compare utility of Image Magick.
Step 1: As
a first step install Image Magick software which you can find in below link.
This will
install the required compare.exe tool in below location
C:\Program
Files\ImageMagick-x.x.x-xxx
Step 2: As
a next step take 2 images which you want to compare. For example I have taken 2
bitmap images in which one has a text “Hello” and another one with “Hello World”.
Hello.bmp – Standard
HelloWorld.bmp – Image for Comparison
Step 3: Open command prompt and then type the command following below syntax
Command line Image Comparison using Compare.exe
Compare.exe –metric type InputImageFullPath1 InputImageFullPath2 DifferenceImageFullPath
Example:
C:\Program
Files\ImageMagick-6.7.3-Q16>compare.exe -metric AE "D:\ImageComparisonTest\Hello.bmp"
"D:\ImageComparisonTest\HelloWorld.bmp" "D:\ImageComparisonTest\DiffHelloWorld.bmp"
Where,
-metric {type} - measures the differences between
images with this metric.Ex: –metric AE - Here AE represents absolute error. This will report the standard error with the number of pixel counts that were actually masked in the difference output.
InputImageFullPath1 – Provide full path for the standard image.
InputImageFullPath2 – provide full path for the image which you want to compare with the standard image
DifferenceImageFullPath – Provide full path to save the difference output image.
Difference output:
7653 - Pixels
have been masked in generating below difference image.DiffHelloWorld.bmp
This
utility will be very much helpful in batch processing for comparing large set of
images. For more information on the usage of compare utility refer below link
http://www.imagemagick.org/Usage/compare/
No comments:
Post a Comment