blob: 22e8420d81664d2e3b9d8cb76d1d4d5d06e405f4 [file] [log] [blame]
cristyd2432012015-05-04 23:15:15 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2<html lang="en">
cristyad41c0c2012-10-31 00:49:28 +00003<head>
cristyd2432012015-05-04 23:15:15 +00004 <meta charset="utf-8">
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <meta name="viewport" content="width=device-width, initial-scale=1">
cristyffb69ed2010-12-25 00:06:48 +00007 <title>ImageMagick: Command-line Tools: Compare</title>
cristyd2432012015-05-04 23:15:15 +00008 <meta http-equiv="content-language" content="en-US">
9 <meta http-equiv="content-type" content="text/html; charset=utf-8">
10 <meta http-equiv="reply-to" content="magick-users@imagemagick.org">
11 <meta name="application-name" content="ImageMagick">
12 <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.">
13 <meta name="application-url" content="http://www.imagemagick.org">
14 <meta name="generator" content="PHP">
15 <meta name="keywords" content="command-line, tools:, compare, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert">
16 <meta name="rating" content="GENERAL">
17 <meta name="robots" content="INDEX, FOLLOW">
18 <meta name="generator" content="ImageMagick Studio LLC">
19 <meta name="author" content="ImageMagick Studio LLC">
20 <meta name="revisit-after" content="2 DAYS">
21 <meta name="resource-type" content="document">
22 <meta name="copyright" content="Copyright (c) 1999-2012 ImageMagick Studio LLC">
23 <meta name="distribution" content="Global">
cristy44443b92015-05-05 00:06:07 +000024 <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1">
cristyd2432012015-05-04 23:15:15 +000025 <link rel="icon" href="../images/wand.png">
26 <link rel="shortcut icon" href="../images/wand.ico" type="images/x-icon">
cristy44443b92015-05-05 00:06:07 +000027 <link rel="stylesheet" href="css/bootstrap.min.css">
28 <link rel="stylesheet" href="css/magick.css">
cristyad41c0c2012-10-31 00:49:28 +000029</head>
30
cristyd2432012015-05-04 23:15:15 +000031<body>
cristyad41c0c2012-10-31 00:49:28 +000032<div class="main">
cristyd2432012015-05-04 23:15:15 +000033<div class="magick-masthead">
34 <div class="container">
35 <script type="text/javascript">
36 <!--
37 google_ad_client = "pub-3129977114552745";
38 google_ad_slot = "5439289906";
39 google_ad_width = 728;
40 google_ad_height = 90;
41 //-->
42 </script>
43 <center><script type="text/javascript" src="http://localhost/pagead/show_ads.js">
44 </script></center>
45 <nav class="magick-nav">
cristy44443b92015-05-05 00:06:07 +000046 <a class="magick-nav-item " href="../index.html">Home</a>
cristyd2432012015-05-04 23:15:15 +000047 <a class="magick-nav-item " href="binary-releases.html">Downloads</a>
48 <a class="magick-nav-item " href="command-line-tools.html">Tools</a>
49 <a class="magick-nav-item " href="command-line-options.html">Options</a>
50 <a class="magick-nav-item " href="api.html">Development</a>
cristy44443b92015-05-05 00:06:07 +000051 <a class="magick-nav-item" href="http://www.imagemagick.org/discourse-server/">Community</a>
cristyabed55c2015-05-06 17:07:00 +000052 <a class="magick-nav-item navbar-right " href="http://www.imagemagick.org/script/search.php">Search</a>
cristyd2432012015-05-04 23:15:15 +000053 </nav>
54 </div>
cristy3ed852e2009-09-05 21:47:34 +000055</div>
cristyd2432012015-05-04 23:15:15 +000056<div class="container">
57<div class="magick-header">
58<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 +000059
cristyd2432012015-05-04 23:15:15 +000060<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>
61
62<h2 class="magick-header"><a id="usage"></a>Example Usage</h2>
cristy751980d2012-06-03 23:18:35 +000063
cristy8ee7f242013-06-20 16:08:44 +000064<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 +000065
cristyd2432012015-05-04 23:15:15 +000066<pre>
67convert rose.jpg -sharpen 0x1 reconstruct.jpg
68compare rose.jpg reconstruct.jpg difference.png
69compare -compose src rose.jpg reconstruct.jpg difference.png
70</pre>
71
72<ul>
73 <a href="../images/rose.jpg"><img src="../images/rose.jpg" width="70" height="46" alt="rose"></a>
74 <a href="../images/reconstruct.jpg"><img src="../images/reconstruct.jpg" width="70" height="46" alt="rose"></a>
75 <img style="margin:13px 0;" src="../images/right.gif" width="20" height="20" alt="==&gt;">
76 <a href="../images/difference.png"><img src="../images/difference.png" width="70" height="46" alt="rose"></a>
77</ul>
cristy3ed852e2009-09-05 21:47:34 +000078
79<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>
80
81<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>
82
cristyd2432012015-05-04 23:15:15 +000083<pre>
84-&gt; compare -verbose -metric mae rose.jpg reconstruct.jpg difference.png
85Image: rose.jpg
86 Channel distortion: MAE
87 red: 2282.91 (0.034835)
88 green: 1853.99 (0.0282901)
89 blue: 2008.67 (0.0306503)
90 all: 1536.39 (0.0234439)
91</pre>
92<p>Or, if you just want the red channel distortion, use this command:</p>
cristy3ed852e2009-09-05 21:47:34 +000093
cristyd2432012015-05-04 23:15:15 +000094<pre>
95-&gt; compare -channel red -metric PSNR rose.jpg reconstruct.jpg difference.png
9619.63
97</pre>
98
cristy3ed852e2009-09-05 21:47:34 +000099<p>Or, if you just want the overall image distortion, use this command:</p>
100
cristyd2432012015-05-04 23:15:15 +0000101<pre>
102-&gt; compare -metric PSNR rose.jpg reconstruct.jpg difference.png
10328.31
104</pre>
105
cristy3ed852e2009-09-05 21:47:34 +0000106<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>
107
cristyd2432012015-05-04 23:15:15 +0000108<pre>
109-&gt; compare -metric RMSE -subimage-search logo.png wizard.jpg similarity.gif
11085.05 (0.00129778) @ 353,157
111</pre>
112
cristy91469932014-07-25 11:00:25 +0000113<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 +0000114
115<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 +0000116
cristyd2432012015-05-04 23:15:15 +0000117<h2 class="magick-header"><a id="options"></a>Option Summary</h2>
cristy751980d2012-06-03 23:18:35 +0000118
cristy8ee7f242013-06-20 16:08:44 +0000119<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 +0000120
cristyd2432012015-05-04 23:15:15 +0000121<table class="table table-condensed table-striped">
cristy3ed852e2009-09-05 21:47:34 +0000122 <tbody>
123 <tr>
124 <th align="left">Option</th>
125 <th align="left">Description</th>
126 </tr>
127
128 <tr>
cristyd2432012015-05-04 23:15:15 +0000129 <td><a href="command-line-options.html#alpha">-alpha</a></td>
130 <td>on, activate, off, deactivate, set, opaque, copy",
cristy3ed852e2009-09-05 21:47:34 +0000131transparent, extract, background, or shape the alpha channel</td>
132 </tr>
133
134 <tr>
cristyd2432012015-05-04 23:15:15 +0000135 <td><a href="command-line-options.html#authenticate">-authenticate <var>value</var></a></td>
136 <td>decrypt image with this password</td>
cristy3ed852e2009-09-05 21:47:34 +0000137 </tr>
138
139 <tr>
cristyd2432012015-05-04 23:15:15 +0000140 <td><a href="command-line-options.html#channel">-channel <var>type</var></a></td>
141 <td>apply option to select image channels</td>
cristy3ed852e2009-09-05 21:47:34 +0000142 </tr>
143
144 <tr>
cristyd2432012015-05-04 23:15:15 +0000145 <td><a href="command-line-options.html#colorspace">-colorspace <var>type</var></a></td>
146 <td>set image colorspace</td>
cristy3ed852e2009-09-05 21:47:34 +0000147 </tr>
148
149 <tr>
cristyd2432012015-05-04 23:15:15 +0000150 <td><a href="command-line-options.html#compose">-compose <var>operator</var></a></td>
151 <td>set image composite operator</td>
cristy3ed852e2009-09-05 21:47:34 +0000152 </tr>
153
154 <tr>
cristyd2432012015-05-04 23:15:15 +0000155 <td><a href="command-line-options.html#decipher">-decipher <var>filename</var></a></td>
156 <td>convert cipher pixels to plain</td>
cristy3ed852e2009-09-05 21:47:34 +0000157 </tr>
158
159 <tr>
cristyd2432012015-05-04 23:15:15 +0000160 <td><a href="command-line-options.html#debug">-debug <var>events</var></a></td>
161 <td>display copious debugging information</td>
cristy3ed852e2009-09-05 21:47:34 +0000162 </tr>
163
164 <tr>
cristyd2432012015-05-04 23:15:15 +0000165 <td><a href="command-line-options.html#define">-define <var>format:option</var></a></td>
166 <td>define one or more image format options</td>
cristy3ed852e2009-09-05 21:47:34 +0000167 </tr>
168
169 <tr>
cristyd2432012015-05-04 23:15:15 +0000170 <td><a href="command-line-options.html#density">-density <var>geometry</var></a></td>
171 <td>horizontal and vertical density of the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000172 </tr>
173
174 <tr>
cristyd2432012015-05-04 23:15:15 +0000175 <td><a href="command-line-options.html#depth">-depth <var>value</var></a></td>
176 <td>image depth</td>
cristy3ed852e2009-09-05 21:47:34 +0000177 </tr>
178
179 <tr>
cristyd2432012015-05-04 23:15:15 +0000180 <td><a href="command-line-options.html#dissimilarity-threshold">-dissimilarity-threshold <var>value</var></a></td>
181 <td>maximum distortion for (sub)image match (default 0.2)</td>
cristy3ed852e2009-09-05 21:47:34 +0000182 </tr>
183
184 <tr>
cristyd2432012015-05-04 23:15:15 +0000185 <td><a href="command-line-options.html#encipher">-encipher <var>filename</var></a></td>
186 <td>convert plain pixels to cipher pixels</td>
cristy3ed852e2009-09-05 21:47:34 +0000187 </tr>
188
189 <tr>
cristyd2432012015-05-04 23:15:15 +0000190 <td><a href="command-line-options.html#extract">-extract <var>geometry</var></a></td>
191 <td>extract area from image</td>
cristy3ed852e2009-09-05 21:47:34 +0000192 </tr>
193
194 <tr>
cristyd2432012015-05-04 23:15:15 +0000195 <td><a href="command-line-options.html#fuzz">-fuzz <var>distance</var></a></td>
196 <td>colors within this distance are considered equal</td>
cristy3ed852e2009-09-05 21:47:34 +0000197 </tr>
198
199 <tr>
cristyd2432012015-05-04 23:15:15 +0000200 <td><a href="command-line-options.html#help">-help</a></td>
201 <td>print program options</td>
cristy3ed852e2009-09-05 21:47:34 +0000202 </tr>
203
204 <tr>
cristyd2432012015-05-04 23:15:15 +0000205 <td><a href="command-line-options.html#highlight-color">-highlight-color <var>color</var></a></td>
206 <td>emphasize pixel differences with this color</td>
cristy3ed852e2009-09-05 21:47:34 +0000207 </tr>
208
209 <tr>
cristyd2432012015-05-04 23:15:15 +0000210 <td><a href="command-line-options.html#identify">-identify</a></td>
211 <td>identify the format and characteristics of the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000212 </tr>
213
214 <tr>
cristyd2432012015-05-04 23:15:15 +0000215 <td><a href="command-line-options.html#interlace">-interlace <var>type</var></a></td>
216 <td>type of image interlacing scheme</td>
cristy3ed852e2009-09-05 21:47:34 +0000217 </tr>
218
219 <tr>
cristyd2432012015-05-04 23:15:15 +0000220 <td><a href="command-line-options.html#limit">-limit <var>type value</var></a></td>
221 <td>pixel cache resource limit</td>
cristy3ed852e2009-09-05 21:47:34 +0000222 </tr>
223
224 <tr>
cristyd2432012015-05-04 23:15:15 +0000225 <td><a href="command-line-options.html#log">-log <var>format</var></a></td>
226 <td>format of debugging information</td>
cristy3ed852e2009-09-05 21:47:34 +0000227 </tr>
228
229 <tr>
cristyd2432012015-05-04 23:15:15 +0000230 <td><a href="command-line-options.html#lowlight-color">-lowlight-color <var>color</var></a></td>
231 <td>de-emphasize pixel differences with this color</td>
cristy3ed852e2009-09-05 21:47:34 +0000232 </tr>
233
234 <tr>
cristyd2432012015-05-04 23:15:15 +0000235 <td><a href="command-line-options.html#metric">-metric <var>type</var></a></td>
236 <td>measure differences between images with this metric</td>
cristy3ed852e2009-09-05 21:47:34 +0000237 </tr>
238
239 <tr>
cristyd2432012015-05-04 23:15:15 +0000240 <td><a href="command-line-options.html#profile">-profile <var>filename</var></a></td>
241 <td>add, delete, or apply an image profile</td>
cristy3ed852e2009-09-05 21:47:34 +0000242 </tr>
243
244 <tr>
cristyd2432012015-05-04 23:15:15 +0000245 <td><a href="command-line-options.html#quality">-quality <var>value</var></a></td>
246 <td>JPEG/MIFF/PNG compression level</td>
cristy3ed852e2009-09-05 21:47:34 +0000247 </tr>
248
249 <tr>
cristyd2432012015-05-04 23:15:15 +0000250 <td><a href="command-line-options.html#quantize">-quantize <var>colorspace</var></a></td>
251 <td>reduce image colors in this colorspace</td>
cristy3ed852e2009-09-05 21:47:34 +0000252 </tr>
253
254 <tr>
cristyd2432012015-05-04 23:15:15 +0000255 <td><a href="command-line-options.html#quiet">-quiet</a></td>
256 <td>suppress all warning messages</td>
cristy3ed852e2009-09-05 21:47:34 +0000257 </tr>
258
259 <tr>
cristyd2432012015-05-04 23:15:15 +0000260 <td><a href="command-line-options.html#regard-warnings">-regard-warnings</a></td>
261 <td>pay attention to warning messages.</td>
cristy3ed852e2009-09-05 21:47:34 +0000262 </tr>
263
264 <tr>
cristyd2432012015-05-04 23:15:15 +0000265 <td><a href="command-line-options.html#respect-parentheses">-respect-parentheses</a></td>
266 <td>settings remain in effect until parenthesis boundary.</td>
cristy3ed852e2009-09-05 21:47:34 +0000267 </tr>
268
269 <tr>
cristyd2432012015-05-04 23:15:15 +0000270 <td><a href="command-line-options.html#sampling-factor">-sampling-factor <var>geometry</var></a></td>
271 <td>horizontal and vertical sampling factor</td>
cristy3ed852e2009-09-05 21:47:34 +0000272 </tr>
273
274 <tr>
cristyd2432012015-05-04 23:15:15 +0000275 <td><a href="command-line-options.html#seed">-seed <var>value</var></a></td>
276 <td>seed a new sequence of pseudo-random numbers</td>
cristy3ed852e2009-09-05 21:47:34 +0000277 </tr>
278
279 <tr>
cristyd2432012015-05-04 23:15:15 +0000280 <td><a href="command-line-options.html#set">-set <var>attribute value</var></a></td>
281 <td>set an image attribute</td>
cristy3ed852e2009-09-05 21:47:34 +0000282 </tr>
283
284 <tr>
cristyd2432012015-05-04 23:15:15 +0000285 <td><a href="command-line-options.html#similarity-threshold">-similarity-threshold <var>value</var></a></td>
286 <td>minimum distortion for (sub)image match (default 0.0)</td>
cristy8ee7f242013-06-20 16:08:44 +0000287 </tr>
288
289 <tr>
cristyd2432012015-05-04 23:15:15 +0000290 <td><a href="command-line-options.html#size">-size <var>geometry</var></a></td>
291 <td>width and height of image</td>
cristy3ed852e2009-09-05 21:47:34 +0000292 </tr>
293
294 <tr>
cristyd2432012015-05-04 23:15:15 +0000295 <td><a href="command-line-options.html#subimage-search">-subimage-search</a></td>
296 <td>search for subimage</td>
cristyae6203d2010-08-09 01:12:14 +0000297 </tr>
298
299 <tr>
cristyd2432012015-05-04 23:15:15 +0000300 <td><a href="command-line-options.html#synchronize">-synchronize</a></td>
301 <td>synchronize image to storage device</td>
cristy5063d812010-10-19 16:28:10 +0000302 </tr>
303
304 <tr>
cristyd2432012015-05-04 23:15:15 +0000305 <td><a href="command-line-options.html#taint">-taint</a></td>
306 <td>mark the image as modified</td>
cristy5063d812010-10-19 16:28:10 +0000307 </tr>
308
309 <tr>
cristyd2432012015-05-04 23:15:15 +0000310 <td><a href="command-line-options.html#transparent-color">-transparent-color <var>color</var></a></td>
311 <td>transparent color</td>
cristy3ed852e2009-09-05 21:47:34 +0000312 </tr>
313
314 <tr>
cristyd2432012015-05-04 23:15:15 +0000315 <td><a href="command-line-options.html#verbose">-verbose</a></td>
316 <td>print detailed information about the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000317 </tr>
318
319 <tr>
cristyd2432012015-05-04 23:15:15 +0000320 <td><a href="command-line-options.html#version">-version</a></td>
321 <td>print version information</td>
cristy3ed852e2009-09-05 21:47:34 +0000322 </tr>
323
324 <tr>
cristyd2432012015-05-04 23:15:15 +0000325 <td><a href="command-line-options.html#virtual-pixel">-virtual-pixel <var>method</var></a></td>
326 <td>access method for pixels outside the boundaries of the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000327 </tr>
328
329 </tbody>
330</table>
cristy751980d2012-06-03 23:18:35 +0000331</div>
cristyd2432012015-05-04 23:15:15 +0000332 <footer class="magick-footer">
333 <div class="magick-nav-item navbar-left">
cristy85893d32015-05-06 13:44:09 +0000334 <a href="support.html">Donate</a>
cristyd2432012015-05-04 23:15:15 +0000335 </div>
336 <div class="magick-nav-item navbar-right">
cristy44443b92015-05-05 00:06:07 +0000337 <a class="FlattrButton" style="display:none;" rev="flattr;button:compact;" href="../index.html"></a>
cristyd2432012015-05-04 23:15:15 +0000338 <noscript>
339 <a href="http://flattr.com/thing/947300/Convert-Edit-And-Compose-Images" target="_blank">
340 <img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0"></a>
341 </noscript>
342 </div>
343 <p><a href="sitemap.html">Sitemap</a>
344 <a href="links.html">Related</a>
345 <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Image Studio</a>
346 <a href="http://jqmagick.imagemagick.org/">JqMagick</a>
347 <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a>
348</p>
349 <p><a href="compare.html#">Back to top</a>
cristy85893d32015-05-06 13:44:09 +0000350 <a href="http://www.imagemagick.org/script/contact.php">Contact Us</a></p>
cristyd2432012015-05-04 23:15:15 +0000351 </footer>
352</div><!-- /.container -->
cristyad41c0c2012-10-31 00:49:28 +0000353
cristyd2432012015-05-04 23:15:15 +0000354 <script src="https://localhost/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
355 <script src="../js/bootstrap.min.js"></script>
356 <script type="text/javascript">
357 /* */
358 (function() {
359 var s = document.createElement('offline-script'), t = document.getElementsByTagName('offline-script')[0];
360 s.type = 'text/javascript';
361 s.async = true;
362 s.src = 'http://api.flattr.com/js/0.6/load.js?mode=auto';
363 t.parentNode.insertBefore(s, t);
364 })();
365 /* */
366 </script>
cristyad41c0c2012-10-31 00:49:28 +0000367</div>
cristyad41c0c2012-10-31 00:49:28 +0000368</body>
cristy5a367e42015-05-05 12:39:18 +0000369</html>