blob: 9ac2a6a371d790e1b1218907c1ef397052e80c1d [file] [log] [blame]
Cristy594d2772015-11-15 10:47:42 -05001
2
3
4
cristy29dc8652015-05-12 16:26:21 +00005<!DOCTYPE html>
cristyd2432012015-05-04 23:15:15 +00006<html lang="en">
cristyad41c0c2012-10-31 00:49:28 +00007<head>
Cristy594d2772015-11-15 10:47:42 -05008 <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
cristy29f2c972015-07-28 13:37:46 +00009 <title>ImageMagick: Command-line Tools: Compare</title>
Cristy594d2772015-11-15 10:47:42 -050010 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
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"/>
Cristyce4a3552015-12-14 13:53:35 -050022 <meta name="copyright" content="Copyright (c) 1999-2015 ImageMagick Studio LLC"/>
Cristy594d2772015-11-15 10:47:42 -050023 <meta name="distribution" content="Global"/>
24 <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
25 <link rel="icon" href="../images/wand.png"/>
26 <link rel="shortcut icon" href="../images/wand.ico"/>
Cristyce4a3552015-12-14 13:53:35 -050027 <link rel="stylesheet" href="css/magick.css"/>
cristyad41c0c2012-10-31 00:49:28 +000028</head>
cristyd2432012015-05-04 23:15:15 +000029<body>
cristyad41c0c2012-10-31 00:49:28 +000030<div class="main">
cristyd2432012015-05-04 23:15:15 +000031<div class="magick-masthead">
32 <div class="container">
Cristy594d2772015-11-15 10:47:42 -050033 <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle"
34 style="display:block"
35 data-ad-client="ca-pub-3129977114552745"
36 data-ad-slot="6345125851"
37 data-ad-format="auto"></ins>
cristy29f2c972015-07-28 13:37:46 +000038 <script>
Cristy542697a2015-10-12 20:10:32 -040039 (adsbygoogle = window.adsbygoogle || []).push({});
cristyd2432012015-05-04 23:15:15 +000040 </script>
cristyd2432012015-05-04 23:15:15 +000041 <nav class="magick-nav">
cristy44443b92015-05-05 00:06:07 +000042 <a class="magick-nav-item " href="../index.html">Home</a>
cristyea2793e2015-05-31 16:52:26 +000043 <a class="magick-nav-item " href="binary-releases.html">Download</a>
cristyd2432012015-05-04 23:15:15 +000044 <a class="magick-nav-item " href="command-line-tools.html">Tools</a>
Cristye93be682015-11-26 09:07:51 -050045 <a class="magick-nav-item " href="command-line-processing.html">Command-line</a>
cristyea2793e2015-05-31 16:52:26 +000046 <a class="magick-nav-item " href="resources.html">Resources</a>
47 <a class="magick-nav-item " href="api.html">Develop</a>
cristy5b8fe762015-06-09 16:24:03 +000048 <a class="magick-nav-item " href="http://nextgen.imagemagick.org/script/search.php">Search</a>
cristya1890f02015-05-15 23:32:44 +000049 <a class="magick-nav-item pull-right" href="http://www.imagemagick.org/discourse-server/">Community</a>
cristyd2432012015-05-04 23:15:15 +000050 </nav>
51 </div>
cristy3ed852e2009-09-05 21:47:34 +000052</div>
cristyd2432012015-05-04 23:15:15 +000053<div class="container">
54<div class="magick-header">
55<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 +000056
Cristyce4a3552015-12-14 13:53:35 -050057<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>
cristyd2432012015-05-04 23:15:15 +000058
59<h2 class="magick-header"><a id="usage"></a>Example Usage</h2>
cristy751980d2012-06-03 23:18:35 +000060
cristy8ee7f242013-06-20 16:08:44 +000061<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 +000062
cristyd2432012015-05-04 23:15:15 +000063<pre>
64convert rose.jpg -sharpen 0x1 reconstruct.jpg
65compare rose.jpg reconstruct.jpg difference.png
66compare -compose src rose.jpg reconstruct.jpg difference.png
67</pre>
68
69<ul>
Cristy594d2772015-11-15 10:47:42 -050070 <a href="../images/rose.jpg"><img src="../images/rose.jpg" width="70" height="46" alt="rose" /></a>
71 <a href="../images/reconstruct.jpg"><img src="../images/reconstruct.jpg" width="70" height="46" alt="rose" /></a>
72 <img style="margin:13px 0;" src="../images/right.gif" width="20" height="20" alt="==>" />
73 <a href="../images/difference.png"><img src="../images/difference.png" width="70" height="46" alt="rose" /></a>
cristyd2432012015-05-04 23:15:15 +000074</ul>
cristy3ed852e2009-09-05 21:47:34 +000075
76<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>
77
78<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>
79
cristyd2432012015-05-04 23:15:15 +000080<pre>
Cristy594d2772015-11-15 10:47:42 -050081-> compare -verbose -metric mae rose.jpg reconstruct.jpg difference.png
cristyd2432012015-05-04 23:15:15 +000082Image: rose.jpg
83 Channel distortion: MAE
84 red: 2282.91 (0.034835)
85 green: 1853.99 (0.0282901)
86 blue: 2008.67 (0.0306503)
87 all: 1536.39 (0.0234439)
88</pre>
89<p>Or, if you just want the red channel distortion, use this command:</p>
cristy3ed852e2009-09-05 21:47:34 +000090
cristyd2432012015-05-04 23:15:15 +000091<pre>
Cristy594d2772015-11-15 10:47:42 -050092-> compare -channel red -metric PSNR rose.jpg reconstruct.jpg difference.png
cristyd2432012015-05-04 23:15:15 +00009319.63
94</pre>
95
cristy3ed852e2009-09-05 21:47:34 +000096<p>Or, if you just want the overall image distortion, use this command:</p>
97
cristyd2432012015-05-04 23:15:15 +000098<pre>
Cristy594d2772015-11-15 10:47:42 -050099-> compare -metric PSNR rose.jpg reconstruct.jpg difference.png
cristyd2432012015-05-04 23:15:15 +000010028.31
101</pre>
102
cristy3ed852e2009-09-05 21:47:34 +0000103<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>
104
cristyd2432012015-05-04 23:15:15 +0000105<pre>
Cristy594d2772015-11-15 10:47:42 -0500106-> compare -metric RMSE -subimage-search logo.png wizard.jpg similarity.gif
cristyd2432012015-05-04 23:15:15 +000010785.05 (0.00129778) @ 353,157
108</pre>
109
Cristyce4a3552015-12-14 13:53:35 -0500110<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 +0000111
112<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 +0000113
cristyd2432012015-05-04 23:15:15 +0000114<h2 class="magick-header"><a id="options"></a>Option Summary</h2>
cristy751980d2012-06-03 23:18:35 +0000115
cristy8ee7f242013-06-20 16:08:44 +0000116<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 +0000117
cristyd2432012015-05-04 23:15:15 +0000118<table class="table table-condensed table-striped">
cristy3ed852e2009-09-05 21:47:34 +0000119 <tbody>
120 <tr>
121 <th align="left">Option</th>
122 <th align="left">Description</th>
123 </tr>
124
125 <tr>
cristyd2432012015-05-04 23:15:15 +0000126 <td><a href="command-line-options.html#alpha">-alpha</a></td>
127 <td>on, activate, off, deactivate, set, opaque, copy",
cristy3ed852e2009-09-05 21:47:34 +0000128transparent, extract, background, or shape the alpha channel</td>
129 </tr>
130
131 <tr>
cristyd2432012015-05-04 23:15:15 +0000132 <td><a href="command-line-options.html#authenticate">-authenticate <var>value</var></a></td>
133 <td>decrypt image with this password</td>
cristy3ed852e2009-09-05 21:47:34 +0000134 </tr>
135
136 <tr>
cristyd2432012015-05-04 23:15:15 +0000137 <td><a href="command-line-options.html#channel">-channel <var>type</var></a></td>
138 <td>apply option to select image channels</td>
cristy3ed852e2009-09-05 21:47:34 +0000139 </tr>
140
141 <tr>
cristyd2432012015-05-04 23:15:15 +0000142 <td><a href="command-line-options.html#colorspace">-colorspace <var>type</var></a></td>
143 <td>set image colorspace</td>
cristy3ed852e2009-09-05 21:47:34 +0000144 </tr>
145
146 <tr>
cristyd2432012015-05-04 23:15:15 +0000147 <td><a href="command-line-options.html#compose">-compose <var>operator</var></a></td>
148 <td>set image composite operator</td>
cristy3ed852e2009-09-05 21:47:34 +0000149 </tr>
150
151 <tr>
cristyd2432012015-05-04 23:15:15 +0000152 <td><a href="command-line-options.html#decipher">-decipher <var>filename</var></a></td>
153 <td>convert cipher pixels to plain</td>
cristy3ed852e2009-09-05 21:47:34 +0000154 </tr>
155
156 <tr>
cristyd2432012015-05-04 23:15:15 +0000157 <td><a href="command-line-options.html#debug">-debug <var>events</var></a></td>
158 <td>display copious debugging information</td>
cristy3ed852e2009-09-05 21:47:34 +0000159 </tr>
160
161 <tr>
cristyd2432012015-05-04 23:15:15 +0000162 <td><a href="command-line-options.html#define">-define <var>format:option</var></a></td>
163 <td>define one or more image format options</td>
cristy3ed852e2009-09-05 21:47:34 +0000164 </tr>
165
166 <tr>
cristyd2432012015-05-04 23:15:15 +0000167 <td><a href="command-line-options.html#density">-density <var>geometry</var></a></td>
168 <td>horizontal and vertical density of the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000169 </tr>
170
171 <tr>
cristyd2432012015-05-04 23:15:15 +0000172 <td><a href="command-line-options.html#depth">-depth <var>value</var></a></td>
173 <td>image depth</td>
cristy3ed852e2009-09-05 21:47:34 +0000174 </tr>
175
176 <tr>
cristyd2432012015-05-04 23:15:15 +0000177 <td><a href="command-line-options.html#dissimilarity-threshold">-dissimilarity-threshold <var>value</var></a></td>
178 <td>maximum distortion for (sub)image match (default 0.2)</td>
cristy3ed852e2009-09-05 21:47:34 +0000179 </tr>
180
181 <tr>
cristyd2432012015-05-04 23:15:15 +0000182 <td><a href="command-line-options.html#encipher">-encipher <var>filename</var></a></td>
183 <td>convert plain pixels to cipher pixels</td>
cristy3ed852e2009-09-05 21:47:34 +0000184 </tr>
185
186 <tr>
cristyd2432012015-05-04 23:15:15 +0000187 <td><a href="command-line-options.html#extract">-extract <var>geometry</var></a></td>
188 <td>extract area from image</td>
cristy3ed852e2009-09-05 21:47:34 +0000189 </tr>
190
191 <tr>
cristyd2432012015-05-04 23:15:15 +0000192 <td><a href="command-line-options.html#fuzz">-fuzz <var>distance</var></a></td>
193 <td>colors within this distance are considered equal</td>
cristy3ed852e2009-09-05 21:47:34 +0000194 </tr>
195
196 <tr>
cristyd2432012015-05-04 23:15:15 +0000197 <td><a href="command-line-options.html#help">-help</a></td>
198 <td>print program options</td>
cristy3ed852e2009-09-05 21:47:34 +0000199 </tr>
200
201 <tr>
cristyd2432012015-05-04 23:15:15 +0000202 <td><a href="command-line-options.html#highlight-color">-highlight-color <var>color</var></a></td>
203 <td>emphasize pixel differences with this color</td>
cristy3ed852e2009-09-05 21:47:34 +0000204 </tr>
205
206 <tr>
cristyd2432012015-05-04 23:15:15 +0000207 <td><a href="command-line-options.html#identify">-identify</a></td>
208 <td>identify the format and characteristics of the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000209 </tr>
210
211 <tr>
cristyd2432012015-05-04 23:15:15 +0000212 <td><a href="command-line-options.html#interlace">-interlace <var>type</var></a></td>
213 <td>type of image interlacing scheme</td>
cristy3ed852e2009-09-05 21:47:34 +0000214 </tr>
215
216 <tr>
cristyd2432012015-05-04 23:15:15 +0000217 <td><a href="command-line-options.html#limit">-limit <var>type value</var></a></td>
218 <td>pixel cache resource limit</td>
cristy3ed852e2009-09-05 21:47:34 +0000219 </tr>
220
221 <tr>
cristyd2432012015-05-04 23:15:15 +0000222 <td><a href="command-line-options.html#log">-log <var>format</var></a></td>
223 <td>format of debugging information</td>
cristy3ed852e2009-09-05 21:47:34 +0000224 </tr>
225
226 <tr>
cristyd2432012015-05-04 23:15:15 +0000227 <td><a href="command-line-options.html#lowlight-color">-lowlight-color <var>color</var></a></td>
228 <td>de-emphasize pixel differences with this color</td>
cristy3ed852e2009-09-05 21:47:34 +0000229 </tr>
230
231 <tr>
cristyd2432012015-05-04 23:15:15 +0000232 <td><a href="command-line-options.html#metric">-metric <var>type</var></a></td>
233 <td>measure differences between images with this metric</td>
cristy3ed852e2009-09-05 21:47:34 +0000234 </tr>
235
236 <tr>
cristyd2432012015-05-04 23:15:15 +0000237 <td><a href="command-line-options.html#profile">-profile <var>filename</var></a></td>
238 <td>add, delete, or apply an image profile</td>
cristy3ed852e2009-09-05 21:47:34 +0000239 </tr>
240
241 <tr>
cristyd2432012015-05-04 23:15:15 +0000242 <td><a href="command-line-options.html#quality">-quality <var>value</var></a></td>
243 <td>JPEG/MIFF/PNG compression level</td>
cristy3ed852e2009-09-05 21:47:34 +0000244 </tr>
245
246 <tr>
cristyd2432012015-05-04 23:15:15 +0000247 <td><a href="command-line-options.html#quantize">-quantize <var>colorspace</var></a></td>
248 <td>reduce image colors in this colorspace</td>
cristy3ed852e2009-09-05 21:47:34 +0000249 </tr>
250
251 <tr>
cristyd2432012015-05-04 23:15:15 +0000252 <td><a href="command-line-options.html#quiet">-quiet</a></td>
253 <td>suppress all warning messages</td>
cristy3ed852e2009-09-05 21:47:34 +0000254 </tr>
255
256 <tr>
cristyd2432012015-05-04 23:15:15 +0000257 <td><a href="command-line-options.html#regard-warnings">-regard-warnings</a></td>
258 <td>pay attention to warning messages.</td>
cristy3ed852e2009-09-05 21:47:34 +0000259 </tr>
260
261 <tr>
cristyd2432012015-05-04 23:15:15 +0000262 <td><a href="command-line-options.html#respect-parentheses">-respect-parentheses</a></td>
263 <td>settings remain in effect until parenthesis boundary.</td>
cristy3ed852e2009-09-05 21:47:34 +0000264 </tr>
265
266 <tr>
cristyd2432012015-05-04 23:15:15 +0000267 <td><a href="command-line-options.html#sampling-factor">-sampling-factor <var>geometry</var></a></td>
268 <td>horizontal and vertical sampling factor</td>
cristy3ed852e2009-09-05 21:47:34 +0000269 </tr>
270
271 <tr>
cristyd2432012015-05-04 23:15:15 +0000272 <td><a href="command-line-options.html#seed">-seed <var>value</var></a></td>
273 <td>seed a new sequence of pseudo-random numbers</td>
cristy3ed852e2009-09-05 21:47:34 +0000274 </tr>
275
276 <tr>
cristyd2432012015-05-04 23:15:15 +0000277 <td><a href="command-line-options.html#set">-set <var>attribute value</var></a></td>
278 <td>set an image attribute</td>
cristy3ed852e2009-09-05 21:47:34 +0000279 </tr>
280
281 <tr>
cristyd2432012015-05-04 23:15:15 +0000282 <td><a href="command-line-options.html#similarity-threshold">-similarity-threshold <var>value</var></a></td>
283 <td>minimum distortion for (sub)image match (default 0.0)</td>
cristy8ee7f242013-06-20 16:08:44 +0000284 </tr>
285
286 <tr>
cristyd2432012015-05-04 23:15:15 +0000287 <td><a href="command-line-options.html#size">-size <var>geometry</var></a></td>
288 <td>width and height of image</td>
cristy3ed852e2009-09-05 21:47:34 +0000289 </tr>
290
291 <tr>
cristyd2432012015-05-04 23:15:15 +0000292 <td><a href="command-line-options.html#subimage-search">-subimage-search</a></td>
293 <td>search for subimage</td>
cristyae6203d2010-08-09 01:12:14 +0000294 </tr>
295
296 <tr>
cristyd2432012015-05-04 23:15:15 +0000297 <td><a href="command-line-options.html#synchronize">-synchronize</a></td>
298 <td>synchronize image to storage device</td>
cristy5063d812010-10-19 16:28:10 +0000299 </tr>
300
301 <tr>
cristyd2432012015-05-04 23:15:15 +0000302 <td><a href="command-line-options.html#taint">-taint</a></td>
303 <td>mark the image as modified</td>
cristy5063d812010-10-19 16:28:10 +0000304 </tr>
305
306 <tr>
cristyd2432012015-05-04 23:15:15 +0000307 <td><a href="command-line-options.html#transparent-color">-transparent-color <var>color</var></a></td>
308 <td>transparent color</td>
cristy3ed852e2009-09-05 21:47:34 +0000309 </tr>
310
311 <tr>
cristyd2432012015-05-04 23:15:15 +0000312 <td><a href="command-line-options.html#verbose">-verbose</a></td>
313 <td>print detailed information about the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000314 </tr>
315
316 <tr>
cristyd2432012015-05-04 23:15:15 +0000317 <td><a href="command-line-options.html#version">-version</a></td>
318 <td>print version information</td>
cristy3ed852e2009-09-05 21:47:34 +0000319 </tr>
320
321 <tr>
cristyd2432012015-05-04 23:15:15 +0000322 <td><a href="command-line-options.html#virtual-pixel">-virtual-pixel <var>method</var></a></td>
323 <td>access method for pixels outside the boundaries of the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000324 </tr>
325
326 </tbody>
327</table>
cristy751980d2012-06-03 23:18:35 +0000328</div>
cristyd2432012015-05-04 23:15:15 +0000329 <footer class="magick-footer">
cristy29f2c972015-07-28 13:37:46 +0000330 <p><a href="support.html">Donate</a>
331 <a href="sitemap.html">Sitemap</a>
cristyd2432012015-05-04 23:15:15 +0000332 <a href="links.html">Related</a>
cristy29f2c972015-07-28 13:37:46 +0000333 <a href="architecture.html">Architecture</a>
cristyd2432012015-05-04 23:15:15 +0000334</p>
335 <p><a href="compare.html#">Back to top</a>
cristyea2793e2015-05-31 16:52:26 +0000336 <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a>
cristy5b8fe762015-06-09 16:24:03 +0000337 <a href="http://nextgen.imagemagick.org/script/contact.php">Contact Us</a></p>
Cristyde27d762016-01-02 12:56:44 -0500338 <p><small>© 1999-2016 ImageMagick Studio LLC</small></p>
cristyd2432012015-05-04 23:15:15 +0000339 </footer>
340</div><!-- /.container -->
cristyad41c0c2012-10-31 00:49:28 +0000341
Cristy542697a2015-10-12 20:10:32 -0400342 <script src="https://localhost/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
cristy29f2c972015-07-28 13:37:46 +0000343 <script src="http://nextgen.imagemagick.org/js/magick.html"></script>
cristyad41c0c2012-10-31 00:49:28 +0000344</div>
cristyad41c0c2012-10-31 00:49:28 +0000345</body>
cristy5a367e42015-05-05 12:39:18 +0000346</html>