blob: 833b16826e9c7638fd60fd85f85a01158b544c73 [file] [log] [blame]
cristy29dc8652015-05-12 16:26:21 +00001<!DOCTYPE html>
cristyd2432012015-05-04 23:15:15 +00002<html lang="en">
cristyad41c0c2012-10-31 00:49:28 +00003<head>
cristy29f2c972015-07-28 13:37:46 +00004 <title>ImageMagick: Command-line Tools: Compare</title>
cristyd2432012015-05-04 23:15:15 +00005 <meta http-equiv="content-type" content="text/html; charset=utf-8">
cristyd2432012015-05-04 23:15:15 +00006 <meta name="application-name" content="ImageMagick">
7 <meta name="description" content="ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, JPEG-2000, GIF, WebP, Postscript, PDF, and SVG. 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.">
8 <meta name="application-url" content="http://www.imagemagick.org">
9 <meta name="generator" content="PHP">
10 <meta name="keywords" content="command-line, tools:, compare, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert">
11 <meta name="rating" content="GENERAL">
12 <meta name="robots" content="INDEX, FOLLOW">
13 <meta name="generator" content="ImageMagick Studio LLC">
14 <meta name="author" content="ImageMagick Studio LLC">
15 <meta name="revisit-after" content="2 DAYS">
16 <meta name="resource-type" content="document">
cristy2f563d42015-05-06 23:36:51 +000017 <meta name="copyright" content="Copyright (c) 1999-2015 ImageMagick Studio LLC">
cristyd2432012015-05-04 23:15:15 +000018 <meta name="distribution" content="Global">
cristy44443b92015-05-05 00:06:07 +000019 <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1">
cristy29f2c972015-07-28 13:37:46 +000020 <link href="../images/wand.png" rel="icon">
21 <link href="../images/wand.ico" type="images/x-icon" rel="shortcut icon">
22 <link href="../css/magick.html" rel="stylesheet">
cristyad41c0c2012-10-31 00:49:28 +000023</head>
cristyd2432012015-05-04 23:15:15 +000024<body>
cristyad41c0c2012-10-31 00:49:28 +000025<div class="main">
cristyd2432012015-05-04 23:15:15 +000026<div class="magick-masthead">
27 <div class="container">
cristy29f2c972015-07-28 13:37:46 +000028 <script async src="http://localhost/pagead/js/adsbygoogle.js"></script>
29 <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3129977114552745" data-ad-slot="6345125851" data-ad-format="auto"></ins>
30 <script>
31 (adsbygoogle = window.adsbygoogle || []).push({});
cristyd2432012015-05-04 23:15:15 +000032 </script>
cristyd2432012015-05-04 23:15:15 +000033 <nav class="magick-nav">
cristy44443b92015-05-05 00:06:07 +000034 <a class="magick-nav-item " href="../index.html">Home</a>
cristyea2793e2015-05-31 16:52:26 +000035 <a class="magick-nav-item " href="binary-releases.html">Download</a>
cristyd2432012015-05-04 23:15:15 +000036 <a class="magick-nav-item " href="command-line-tools.html">Tools</a>
37 <a class="magick-nav-item " href="command-line-options.html">Options</a>
cristyea2793e2015-05-31 16:52:26 +000038 <a class="magick-nav-item " href="resources.html">Resources</a>
39 <a class="magick-nav-item " href="api.html">Develop</a>
cristy5b8fe762015-06-09 16:24:03 +000040 <a class="magick-nav-item " href="http://nextgen.imagemagick.org/script/search.php">Search</a>
cristya1890f02015-05-15 23:32:44 +000041 <a class="magick-nav-item pull-right" href="http://www.imagemagick.org/discourse-server/">Community</a>
cristyd2432012015-05-04 23:15:15 +000042 </nav>
43 </div>
cristy3ed852e2009-09-05 21:47:34 +000044</div>
cristyd2432012015-05-04 23:15:15 +000045<div class="container">
46<div class="magick-header">
47<p class="text-center"><a href="compare.html#usage">Example Usage</a><a href="compare.html#options">Option Summary</a></p>
cristy3ed852e2009-09-05 21:47:34 +000048
cristyd2432012015-05-04 23:15:15 +000049<p class="lead magick-description">Use the <code>compare</code> program to mathematically and visually annotate the difference between an image and its reconstruction. See <a href="command-line-processing.html">Command Line Processing</a> for advice on how to structure your <code>compare</code> command or see below for example usages of the command.</p>
50
51<h2 class="magick-header"><a id="usage"></a>Example Usage</h2>
cristy751980d2012-06-03 23:18:35 +000052
cristy8ee7f242013-06-20 16:08:44 +000053<p>We list a few examples of the <code>compare</code> command here to illustrate its usefulness and ease of use. To get started, lets compare an image to one thats been sharpened:</p>
cristy3ed852e2009-09-05 21:47:34 +000054
cristyd2432012015-05-04 23:15:15 +000055<pre>
56convert rose.jpg -sharpen 0x1 reconstruct.jpg
57compare rose.jpg reconstruct.jpg difference.png
58compare -compose src rose.jpg reconstruct.jpg difference.png
59</pre>
60
61<ul>
62 <a href="../images/rose.jpg"><img src="../images/rose.jpg" width="70" height="46" alt="rose"></a>
63 <a href="../images/reconstruct.jpg"><img src="../images/reconstruct.jpg" width="70" height="46" alt="rose"></a>
64 <img style="margin:13px 0;" src="../images/right.gif" width="20" height="20" alt="==&gt;">
65 <a href="../images/difference.png"><img src="../images/difference.png" width="70" height="46" alt="rose"></a>
66</ul>
cristy3ed852e2009-09-05 21:47:34 +000067
68<p>The red areas of the difference image emphasizes (highlight) pixels that are affected by the image sharpening, whereas white de-emphasizes (lowlight) pixels that are untouched by the sharpening process.</p>
69
70<p>In addition to the visual interpretation of the difference in an image and its reconstruction, we report a mathematical measure of the difference:</p>
71
cristyd2432012015-05-04 23:15:15 +000072<pre>
73-&gt; compare -verbose -metric mae rose.jpg reconstruct.jpg difference.png
74Image: rose.jpg
75 Channel distortion: MAE
76 red: 2282.91 (0.034835)
77 green: 1853.99 (0.0282901)
78 blue: 2008.67 (0.0306503)
79 all: 1536.39 (0.0234439)
80</pre>
81<p>Or, if you just want the red channel distortion, use this command:</p>
cristy3ed852e2009-09-05 21:47:34 +000082
cristyd2432012015-05-04 23:15:15 +000083<pre>
84-&gt; compare -channel red -metric PSNR rose.jpg reconstruct.jpg difference.png
8519.63
86</pre>
87
cristy3ed852e2009-09-05 21:47:34 +000088<p>Or, if you just want the overall image distortion, use this command:</p>
89
cristyd2432012015-05-04 23:15:15 +000090<pre>
91-&gt; compare -metric PSNR rose.jpg reconstruct.jpg difference.png
9228.31
93</pre>
94
cristy3ed852e2009-09-05 21:47:34 +000095<p>If the reconstructed image is a subimage of the image, the compare program returns the best match offset. In addition, it returns a similarity image such that an exact match location is completely white and if none of the pixels match, black, otherwise some gray level in-between:</p>
96
cristyd2432012015-05-04 23:15:15 +000097<pre>
98-&gt; compare -metric RMSE -subimage-search logo.png wizard.jpg similarity.gif
9985.05 (0.00129778) @ 353,157
100</pre>
101
cristy91469932014-07-25 11:00:25 +0000102<p>You can find additional examples of using <code>compare</code> in <a href="http://www.ibm.com/developerworks/library/l-graf/?ca=dnt-428">Graphics from the Command Line</a>. Further discussion is available in <a href="http://www.ibm.com/developerworks/library/l-graf2/?ca=dgr-lnxw15GraphicsLine">More Graphics from the Command Line</a> and <a href="http://www.imagemagick.org/Usage/">Examples of ImageMagick Usage</a>.</p>
cristyf1b8a092014-02-20 15:46:11 +0000103
104<p>The compare program returns 2 on error otherwise 0 if the images are similar or 1 if they are dissimilar.</p>
cristy3ed852e2009-09-05 21:47:34 +0000105
cristyd2432012015-05-04 23:15:15 +0000106<h2 class="magick-header"><a id="options"></a>Option Summary</h2>
cristy751980d2012-06-03 23:18:35 +0000107
cristy8ee7f242013-06-20 16:08:44 +0000108<p>The <code>compare</code> command recognizes these options. Click on an option to get more details about how that option works.</p>
cristy3ed852e2009-09-05 21:47:34 +0000109
cristyd2432012015-05-04 23:15:15 +0000110<table class="table table-condensed table-striped">
cristy3ed852e2009-09-05 21:47:34 +0000111 <tbody>
112 <tr>
113 <th align="left">Option</th>
114 <th align="left">Description</th>
115 </tr>
116
117 <tr>
cristyd2432012015-05-04 23:15:15 +0000118 <td><a href="command-line-options.html#alpha">-alpha</a></td>
119 <td>on, activate, off, deactivate, set, opaque, copy",
cristy3ed852e2009-09-05 21:47:34 +0000120transparent, extract, background, or shape the alpha channel</td>
121 </tr>
122
123 <tr>
cristyd2432012015-05-04 23:15:15 +0000124 <td><a href="command-line-options.html#authenticate">-authenticate <var>value</var></a></td>
125 <td>decrypt image with this password</td>
cristy3ed852e2009-09-05 21:47:34 +0000126 </tr>
127
128 <tr>
cristyd2432012015-05-04 23:15:15 +0000129 <td><a href="command-line-options.html#channel">-channel <var>type</var></a></td>
130 <td>apply option to select image channels</td>
cristy3ed852e2009-09-05 21:47:34 +0000131 </tr>
132
133 <tr>
cristyd2432012015-05-04 23:15:15 +0000134 <td><a href="command-line-options.html#colorspace">-colorspace <var>type</var></a></td>
135 <td>set image colorspace</td>
cristy3ed852e2009-09-05 21:47:34 +0000136 </tr>
137
138 <tr>
cristyd2432012015-05-04 23:15:15 +0000139 <td><a href="command-line-options.html#compose">-compose <var>operator</var></a></td>
140 <td>set image composite operator</td>
cristy3ed852e2009-09-05 21:47:34 +0000141 </tr>
142
143 <tr>
cristyd2432012015-05-04 23:15:15 +0000144 <td><a href="command-line-options.html#decipher">-decipher <var>filename</var></a></td>
145 <td>convert cipher pixels to plain</td>
cristy3ed852e2009-09-05 21:47:34 +0000146 </tr>
147
148 <tr>
cristyd2432012015-05-04 23:15:15 +0000149 <td><a href="command-line-options.html#debug">-debug <var>events</var></a></td>
150 <td>display copious debugging information</td>
cristy3ed852e2009-09-05 21:47:34 +0000151 </tr>
152
153 <tr>
cristyd2432012015-05-04 23:15:15 +0000154 <td><a href="command-line-options.html#define">-define <var>format:option</var></a></td>
155 <td>define one or more image format options</td>
cristy3ed852e2009-09-05 21:47:34 +0000156 </tr>
157
158 <tr>
cristyd2432012015-05-04 23:15:15 +0000159 <td><a href="command-line-options.html#density">-density <var>geometry</var></a></td>
160 <td>horizontal and vertical density of the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000161 </tr>
162
163 <tr>
cristyd2432012015-05-04 23:15:15 +0000164 <td><a href="command-line-options.html#depth">-depth <var>value</var></a></td>
165 <td>image depth</td>
cristy3ed852e2009-09-05 21:47:34 +0000166 </tr>
167
168 <tr>
cristyd2432012015-05-04 23:15:15 +0000169 <td><a href="command-line-options.html#dissimilarity-threshold">-dissimilarity-threshold <var>value</var></a></td>
170 <td>maximum distortion for (sub)image match (default 0.2)</td>
cristy3ed852e2009-09-05 21:47:34 +0000171 </tr>
172
173 <tr>
cristyd2432012015-05-04 23:15:15 +0000174 <td><a href="command-line-options.html#encipher">-encipher <var>filename</var></a></td>
175 <td>convert plain pixels to cipher pixels</td>
cristy3ed852e2009-09-05 21:47:34 +0000176 </tr>
177
178 <tr>
cristyd2432012015-05-04 23:15:15 +0000179 <td><a href="command-line-options.html#extract">-extract <var>geometry</var></a></td>
180 <td>extract area from image</td>
cristy3ed852e2009-09-05 21:47:34 +0000181 </tr>
182
183 <tr>
cristyd2432012015-05-04 23:15:15 +0000184 <td><a href="command-line-options.html#fuzz">-fuzz <var>distance</var></a></td>
185 <td>colors within this distance are considered equal</td>
cristy3ed852e2009-09-05 21:47:34 +0000186 </tr>
187
188 <tr>
cristyd2432012015-05-04 23:15:15 +0000189 <td><a href="command-line-options.html#help">-help</a></td>
190 <td>print program options</td>
cristy3ed852e2009-09-05 21:47:34 +0000191 </tr>
192
193 <tr>
cristyd2432012015-05-04 23:15:15 +0000194 <td><a href="command-line-options.html#highlight-color">-highlight-color <var>color</var></a></td>
195 <td>emphasize pixel differences with this color</td>
cristy3ed852e2009-09-05 21:47:34 +0000196 </tr>
197
198 <tr>
cristyd2432012015-05-04 23:15:15 +0000199 <td><a href="command-line-options.html#identify">-identify</a></td>
200 <td>identify the format and characteristics of the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000201 </tr>
202
203 <tr>
cristyd2432012015-05-04 23:15:15 +0000204 <td><a href="command-line-options.html#interlace">-interlace <var>type</var></a></td>
205 <td>type of image interlacing scheme</td>
cristy3ed852e2009-09-05 21:47:34 +0000206 </tr>
207
208 <tr>
cristyd2432012015-05-04 23:15:15 +0000209 <td><a href="command-line-options.html#limit">-limit <var>type value</var></a></td>
210 <td>pixel cache resource limit</td>
cristy3ed852e2009-09-05 21:47:34 +0000211 </tr>
212
213 <tr>
cristyd2432012015-05-04 23:15:15 +0000214 <td><a href="command-line-options.html#log">-log <var>format</var></a></td>
215 <td>format of debugging information</td>
cristy3ed852e2009-09-05 21:47:34 +0000216 </tr>
217
218 <tr>
cristyd2432012015-05-04 23:15:15 +0000219 <td><a href="command-line-options.html#lowlight-color">-lowlight-color <var>color</var></a></td>
220 <td>de-emphasize pixel differences with this color</td>
cristy3ed852e2009-09-05 21:47:34 +0000221 </tr>
222
223 <tr>
cristyd2432012015-05-04 23:15:15 +0000224 <td><a href="command-line-options.html#metric">-metric <var>type</var></a></td>
225 <td>measure differences between images with this metric</td>
cristy3ed852e2009-09-05 21:47:34 +0000226 </tr>
227
228 <tr>
cristyd2432012015-05-04 23:15:15 +0000229 <td><a href="command-line-options.html#profile">-profile <var>filename</var></a></td>
230 <td>add, delete, or apply an image profile</td>
cristy3ed852e2009-09-05 21:47:34 +0000231 </tr>
232
233 <tr>
cristyd2432012015-05-04 23:15:15 +0000234 <td><a href="command-line-options.html#quality">-quality <var>value</var></a></td>
235 <td>JPEG/MIFF/PNG compression level</td>
cristy3ed852e2009-09-05 21:47:34 +0000236 </tr>
237
238 <tr>
cristyd2432012015-05-04 23:15:15 +0000239 <td><a href="command-line-options.html#quantize">-quantize <var>colorspace</var></a></td>
240 <td>reduce image colors in this colorspace</td>
cristy3ed852e2009-09-05 21:47:34 +0000241 </tr>
242
243 <tr>
cristyd2432012015-05-04 23:15:15 +0000244 <td><a href="command-line-options.html#quiet">-quiet</a></td>
245 <td>suppress all warning messages</td>
cristy3ed852e2009-09-05 21:47:34 +0000246 </tr>
247
248 <tr>
cristyd2432012015-05-04 23:15:15 +0000249 <td><a href="command-line-options.html#regard-warnings">-regard-warnings</a></td>
250 <td>pay attention to warning messages.</td>
cristy3ed852e2009-09-05 21:47:34 +0000251 </tr>
252
253 <tr>
cristyd2432012015-05-04 23:15:15 +0000254 <td><a href="command-line-options.html#respect-parentheses">-respect-parentheses</a></td>
255 <td>settings remain in effect until parenthesis boundary.</td>
cristy3ed852e2009-09-05 21:47:34 +0000256 </tr>
257
258 <tr>
cristyd2432012015-05-04 23:15:15 +0000259 <td><a href="command-line-options.html#sampling-factor">-sampling-factor <var>geometry</var></a></td>
260 <td>horizontal and vertical sampling factor</td>
cristy3ed852e2009-09-05 21:47:34 +0000261 </tr>
262
263 <tr>
cristyd2432012015-05-04 23:15:15 +0000264 <td><a href="command-line-options.html#seed">-seed <var>value</var></a></td>
265 <td>seed a new sequence of pseudo-random numbers</td>
cristy3ed852e2009-09-05 21:47:34 +0000266 </tr>
267
268 <tr>
cristyd2432012015-05-04 23:15:15 +0000269 <td><a href="command-line-options.html#set">-set <var>attribute value</var></a></td>
270 <td>set an image attribute</td>
cristy3ed852e2009-09-05 21:47:34 +0000271 </tr>
272
273 <tr>
cristyd2432012015-05-04 23:15:15 +0000274 <td><a href="command-line-options.html#similarity-threshold">-similarity-threshold <var>value</var></a></td>
275 <td>minimum distortion for (sub)image match (default 0.0)</td>
cristy8ee7f242013-06-20 16:08:44 +0000276 </tr>
277
278 <tr>
cristyd2432012015-05-04 23:15:15 +0000279 <td><a href="command-line-options.html#size">-size <var>geometry</var></a></td>
280 <td>width and height of image</td>
cristy3ed852e2009-09-05 21:47:34 +0000281 </tr>
282
283 <tr>
cristyd2432012015-05-04 23:15:15 +0000284 <td><a href="command-line-options.html#subimage-search">-subimage-search</a></td>
285 <td>search for subimage</td>
cristyae6203d2010-08-09 01:12:14 +0000286 </tr>
287
288 <tr>
cristyd2432012015-05-04 23:15:15 +0000289 <td><a href="command-line-options.html#synchronize">-synchronize</a></td>
290 <td>synchronize image to storage device</td>
cristy5063d812010-10-19 16:28:10 +0000291 </tr>
292
293 <tr>
cristyd2432012015-05-04 23:15:15 +0000294 <td><a href="command-line-options.html#taint">-taint</a></td>
295 <td>mark the image as modified</td>
cristy5063d812010-10-19 16:28:10 +0000296 </tr>
297
298 <tr>
cristyd2432012015-05-04 23:15:15 +0000299 <td><a href="command-line-options.html#transparent-color">-transparent-color <var>color</var></a></td>
300 <td>transparent color</td>
cristy3ed852e2009-09-05 21:47:34 +0000301 </tr>
302
303 <tr>
cristyd2432012015-05-04 23:15:15 +0000304 <td><a href="command-line-options.html#verbose">-verbose</a></td>
305 <td>print detailed information about the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000306 </tr>
307
308 <tr>
cristyd2432012015-05-04 23:15:15 +0000309 <td><a href="command-line-options.html#version">-version</a></td>
310 <td>print version information</td>
cristy3ed852e2009-09-05 21:47:34 +0000311 </tr>
312
313 <tr>
cristyd2432012015-05-04 23:15:15 +0000314 <td><a href="command-line-options.html#virtual-pixel">-virtual-pixel <var>method</var></a></td>
315 <td>access method for pixels outside the boundaries of the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000316 </tr>
317
318 </tbody>
319</table>
cristy751980d2012-06-03 23:18:35 +0000320</div>
cristyd2432012015-05-04 23:15:15 +0000321 <footer class="magick-footer">
cristy29f2c972015-07-28 13:37:46 +0000322 <p><a href="support.html">Donate</a>
323 <a href="sitemap.html">Sitemap</a>
cristyd2432012015-05-04 23:15:15 +0000324 <a href="links.html">Related</a>
cristy29f2c972015-07-28 13:37:46 +0000325 <a href="architecture.html">Architecture</a>
cristyd2432012015-05-04 23:15:15 +0000326</p>
327 <p><a href="compare.html#">Back to top</a>
cristyea2793e2015-05-31 16:52:26 +0000328 <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a>
cristy5b8fe762015-06-09 16:24:03 +0000329 <a href="http://nextgen.imagemagick.org/script/contact.php">Contact Us</a></p>
cristya1890f02015-05-15 23:32:44 +0000330 <p><small>© 1999-2015 ImageMagick Studio LLC</small></p>
cristyd2432012015-05-04 23:15:15 +0000331 </footer>
332</div><!-- /.container -->
cristyad41c0c2012-10-31 00:49:28 +0000333
cristyd2432012015-05-04 23:15:15 +0000334 <script src="https://localhost/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
cristy29f2c972015-07-28 13:37:46 +0000335 <script src="http://nextgen.imagemagick.org/js/magick.html"></script>
cristyad41c0c2012-10-31 00:49:28 +0000336</div>
cristyad41c0c2012-10-31 00:49:28 +0000337</body>
cristy5a367e42015-05-05 12:39:18 +0000338</html>