blob: 692ece35ace3a8e78729de79dba880465ce1df6d [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>
cristy29f2c972015-07-28 13:37:46 +00008 <title>ImageMagick: Command-line Tools: Compare</title>
Cristy912a9222016-06-17 15:37:28 -04009 <meta charset="utf-8" />
10 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
11 <meta name="viewport" content="width=device-width, initial-scale=1" />
Cristy594d2772015-11-15 10:47:42 -050012 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
13 <meta name="application-name" content="ImageMagick"/>
14 <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."/>
15 <meta name="application-url" content="http://www.imagemagick.org"/>
16 <meta name="generator" content="PHP"/>
17 <meta name="keywords" content="command-line, tools:, compare, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
18 <meta name="rating" content="GENERAL"/>
19 <meta name="robots" content="INDEX, FOLLOW"/>
20 <meta name="generator" content="ImageMagick Studio LLC"/>
21 <meta name="author" content="ImageMagick Studio LLC"/>
22 <meta name="revisit-after" content="2 DAYS"/>
23 <meta name="resource-type" content="document"/>
Cristy912a9222016-06-17 15:37:28 -040024 <meta name="copyright" content="Copyright (c) 1999-2016 ImageMagick Studio LLC"/>
Cristy594d2772015-11-15 10:47:42 -050025 <meta name="distribution" content="Global"/>
26 <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
Cristy912a9222016-06-17 15:37:28 -040027 <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
Cristy594d2772015-11-15 10:47:42 -050028 <link rel="icon" href="../images/wand.png"/>
29 <link rel="shortcut icon" href="../images/wand.ico"/>
Cristy912a9222016-06-17 15:37:28 -040030 <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:900,400,400italic,700,700italic,300,300italic|Open+Sans:300italic,400italic,700italic,300,400,600,700">
Cristyce4a3552015-12-14 13:53:35 -050031 <link rel="stylesheet" href="css/magick.css"/>
cristyad41c0c2012-10-31 00:49:28 +000032</head>
cristyd2432012015-05-04 23:15:15 +000033<body>
cristyad41c0c2012-10-31 00:49:28 +000034<div class="main">
cristyd2432012015-05-04 23:15:15 +000035<div class="magick-masthead">
36 <div class="container">
Cristy594d2772015-11-15 10:47:42 -050037 <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle"
38 style="display:block"
39 data-ad-client="ca-pub-3129977114552745"
40 data-ad-slot="6345125851"
41 data-ad-format="auto"></ins>
cristy29f2c972015-07-28 13:37:46 +000042 <script>
Cristy542697a2015-10-12 20:10:32 -040043 (adsbygoogle = window.adsbygoogle || []).push({});
cristyd2432012015-05-04 23:15:15 +000044 </script>
cristyd2432012015-05-04 23:15:15 +000045 <nav class="magick-nav">
cristy44443b92015-05-05 00:06:07 +000046 <a class="magick-nav-item " href="../index.html">Home</a>
cristyea2793e2015-05-31 16:52:26 +000047 <a class="magick-nav-item " href="binary-releases.html">Download</a>
cristyd2432012015-05-04 23:15:15 +000048 <a class="magick-nav-item " href="command-line-tools.html">Tools</a>
Cristye93be682015-11-26 09:07:51 -050049 <a class="magick-nav-item " href="command-line-processing.html">Command-line</a>
cristyea2793e2015-05-31 16:52:26 +000050 <a class="magick-nav-item " href="resources.html">Resources</a>
51 <a class="magick-nav-item " href="api.html">Develop</a>
Cristy1f1f3a02016-06-01 07:25:42 -040052 <a class="magick-nav-item " href="http://www.imagemagick.org/script/search.php">Search</a>
Cristye09ed312016-03-06 08:07:39 -050053 <a class="magick-nav-item pull-right" href="https://www.imagemagick.org/discourse-server/">Community</a>
cristyd2432012015-05-04 23:15:15 +000054 </nav>
55 </div>
cristy3ed852e2009-09-05 21:47:34 +000056</div>
cristyd2432012015-05-04 23:15:15 +000057<div class="container">
58<div class="magick-header">
59<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 +000060
Cristyce4a3552015-12-14 13:53:35 -050061<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 +000062
63<h2 class="magick-header"><a id="usage"></a>Example Usage</h2>
cristy751980d2012-06-03 23:18:35 +000064
cristy8ee7f242013-06-20 16:08:44 +000065<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 +000066
cristyd2432012015-05-04 23:15:15 +000067<pre>
68convert rose.jpg -sharpen 0x1 reconstruct.jpg
69compare rose.jpg reconstruct.jpg difference.png
70compare -compose src rose.jpg reconstruct.jpg difference.png
71</pre>
72
73<ul>
Cristy594d2772015-11-15 10:47:42 -050074 <a href="../images/rose.jpg"><img src="../images/rose.jpg" width="70" height="46" alt="rose" /></a>
75 <a href="../images/reconstruct.jpg"><img src="../images/reconstruct.jpg" width="70" height="46" alt="rose" /></a>
76 <img style="margin:13px 0;" src="../images/right.gif" width="20" height="20" alt="==>" />
77 <a href="../images/difference.png"><img src="../images/difference.png" width="70" height="46" alt="rose" /></a>
cristyd2432012015-05-04 23:15:15 +000078</ul>
cristy3ed852e2009-09-05 21:47:34 +000079
80<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>
81
82<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>
83
cristyd2432012015-05-04 23:15:15 +000084<pre>
Cristy594d2772015-11-15 10:47:42 -050085-> compare -verbose -metric mae rose.jpg reconstruct.jpg difference.png
cristyd2432012015-05-04 23:15:15 +000086Image: rose.jpg
87 Channel distortion: MAE
88 red: 2282.91 (0.034835)
89 green: 1853.99 (0.0282901)
90 blue: 2008.67 (0.0306503)
91 all: 1536.39 (0.0234439)
92</pre>
93<p>Or, if you just want the red channel distortion, use this command:</p>
cristy3ed852e2009-09-05 21:47:34 +000094
cristyd2432012015-05-04 23:15:15 +000095<pre>
Cristy594d2772015-11-15 10:47:42 -050096-> compare -channel red -metric PSNR rose.jpg reconstruct.jpg difference.png
cristyd2432012015-05-04 23:15:15 +00009719.63
98</pre>
99
cristy3ed852e2009-09-05 21:47:34 +0000100<p>Or, if you just want the overall image distortion, use this command:</p>
101
cristyd2432012015-05-04 23:15:15 +0000102<pre>
Cristy594d2772015-11-15 10:47:42 -0500103-> compare -metric PSNR rose.jpg reconstruct.jpg difference.png
cristyd2432012015-05-04 23:15:15 +000010428.31
105</pre>
106
cristy3ed852e2009-09-05 21:47:34 +0000107<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>
108
cristyd2432012015-05-04 23:15:15 +0000109<pre>
Cristy594d2772015-11-15 10:47:42 -0500110-> compare -metric RMSE -subimage-search logo.png wizard.jpg similarity.gif
cristyd2432012015-05-04 23:15:15 +000011185.05 (0.00129778) @ 353,157
112</pre>
113
Cristyce4a3552015-12-14 13:53:35 -0500114<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 +0000115
116<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 +0000117
cristyd2432012015-05-04 23:15:15 +0000118<h2 class="magick-header"><a id="options"></a>Option Summary</h2>
cristy751980d2012-06-03 23:18:35 +0000119
cristy8ee7f242013-06-20 16:08:44 +0000120<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 +0000121
cristyd2432012015-05-04 23:15:15 +0000122<table class="table table-condensed table-striped">
cristy3ed852e2009-09-05 21:47:34 +0000123 <tbody>
124 <tr>
125 <th align="left">Option</th>
126 <th align="left">Description</th>
127 </tr>
128
129 <tr>
cristyd2432012015-05-04 23:15:15 +0000130 <td><a href="command-line-options.html#alpha">-alpha</a></td>
131 <td>on, activate, off, deactivate, set, opaque, copy",
cristy3ed852e2009-09-05 21:47:34 +0000132transparent, extract, background, or shape the alpha channel</td>
133 </tr>
134
135 <tr>
cristyd2432012015-05-04 23:15:15 +0000136 <td><a href="command-line-options.html#authenticate">-authenticate <var>value</var></a></td>
137 <td>decrypt image with this password</td>
cristy3ed852e2009-09-05 21:47:34 +0000138 </tr>
139
140 <tr>
cristyd2432012015-05-04 23:15:15 +0000141 <td><a href="command-line-options.html#channel">-channel <var>type</var></a></td>
142 <td>apply option to select image channels</td>
cristy3ed852e2009-09-05 21:47:34 +0000143 </tr>
144
145 <tr>
cristyd2432012015-05-04 23:15:15 +0000146 <td><a href="command-line-options.html#colorspace">-colorspace <var>type</var></a></td>
147 <td>set image colorspace</td>
cristy3ed852e2009-09-05 21:47:34 +0000148 </tr>
149
150 <tr>
cristyd2432012015-05-04 23:15:15 +0000151 <td><a href="command-line-options.html#compose">-compose <var>operator</var></a></td>
152 <td>set image composite operator</td>
cristy3ed852e2009-09-05 21:47:34 +0000153 </tr>
154
155 <tr>
cristyd2432012015-05-04 23:15:15 +0000156 <td><a href="command-line-options.html#decipher">-decipher <var>filename</var></a></td>
157 <td>convert cipher pixels to plain</td>
cristy3ed852e2009-09-05 21:47:34 +0000158 </tr>
159
160 <tr>
cristyd2432012015-05-04 23:15:15 +0000161 <td><a href="command-line-options.html#debug">-debug <var>events</var></a></td>
162 <td>display copious debugging information</td>
cristy3ed852e2009-09-05 21:47:34 +0000163 </tr>
164
165 <tr>
cristyd2432012015-05-04 23:15:15 +0000166 <td><a href="command-line-options.html#define">-define <var>format:option</var></a></td>
167 <td>define one or more image format options</td>
cristy3ed852e2009-09-05 21:47:34 +0000168 </tr>
169
170 <tr>
cristyd2432012015-05-04 23:15:15 +0000171 <td><a href="command-line-options.html#density">-density <var>geometry</var></a></td>
172 <td>horizontal and vertical density of the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000173 </tr>
174
175 <tr>
cristyd2432012015-05-04 23:15:15 +0000176 <td><a href="command-line-options.html#depth">-depth <var>value</var></a></td>
177 <td>image depth</td>
cristy3ed852e2009-09-05 21:47:34 +0000178 </tr>
179
180 <tr>
cristyd2432012015-05-04 23:15:15 +0000181 <td><a href="command-line-options.html#dissimilarity-threshold">-dissimilarity-threshold <var>value</var></a></td>
182 <td>maximum distortion for (sub)image match (default 0.2)</td>
cristy3ed852e2009-09-05 21:47:34 +0000183 </tr>
184
185 <tr>
cristyd2432012015-05-04 23:15:15 +0000186 <td><a href="command-line-options.html#encipher">-encipher <var>filename</var></a></td>
187 <td>convert plain pixels to cipher pixels</td>
cristy3ed852e2009-09-05 21:47:34 +0000188 </tr>
189
190 <tr>
cristyd2432012015-05-04 23:15:15 +0000191 <td><a href="command-line-options.html#extract">-extract <var>geometry</var></a></td>
192 <td>extract area from image</td>
cristy3ed852e2009-09-05 21:47:34 +0000193 </tr>
194
195 <tr>
cristyd2432012015-05-04 23:15:15 +0000196 <td><a href="command-line-options.html#fuzz">-fuzz <var>distance</var></a></td>
197 <td>colors within this distance are considered equal</td>
cristy3ed852e2009-09-05 21:47:34 +0000198 </tr>
199
200 <tr>
cristyd2432012015-05-04 23:15:15 +0000201 <td><a href="command-line-options.html#help">-help</a></td>
202 <td>print program options</td>
cristy3ed852e2009-09-05 21:47:34 +0000203 </tr>
204
205 <tr>
cristyd2432012015-05-04 23:15:15 +0000206 <td><a href="command-line-options.html#highlight-color">-highlight-color <var>color</var></a></td>
207 <td>emphasize pixel differences with this color</td>
cristy3ed852e2009-09-05 21:47:34 +0000208 </tr>
209
210 <tr>
cristyd2432012015-05-04 23:15:15 +0000211 <td><a href="command-line-options.html#identify">-identify</a></td>
212 <td>identify the format and characteristics of the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000213 </tr>
214
215 <tr>
cristyd2432012015-05-04 23:15:15 +0000216 <td><a href="command-line-options.html#interlace">-interlace <var>type</var></a></td>
217 <td>type of image interlacing scheme</td>
cristy3ed852e2009-09-05 21:47:34 +0000218 </tr>
219
220 <tr>
cristyd2432012015-05-04 23:15:15 +0000221 <td><a href="command-line-options.html#limit">-limit <var>type value</var></a></td>
222 <td>pixel cache resource limit</td>
cristy3ed852e2009-09-05 21:47:34 +0000223 </tr>
224
225 <tr>
cristyd2432012015-05-04 23:15:15 +0000226 <td><a href="command-line-options.html#log">-log <var>format</var></a></td>
227 <td>format of debugging information</td>
cristy3ed852e2009-09-05 21:47:34 +0000228 </tr>
229
230 <tr>
cristyd2432012015-05-04 23:15:15 +0000231 <td><a href="command-line-options.html#lowlight-color">-lowlight-color <var>color</var></a></td>
232 <td>de-emphasize pixel differences with this color</td>
cristy3ed852e2009-09-05 21:47:34 +0000233 </tr>
234
235 <tr>
cristyd2432012015-05-04 23:15:15 +0000236 <td><a href="command-line-options.html#metric">-metric <var>type</var></a></td>
237 <td>measure differences between images with this metric</td>
cristy3ed852e2009-09-05 21:47:34 +0000238 </tr>
239
240 <tr>
cristyd2432012015-05-04 23:15:15 +0000241 <td><a href="command-line-options.html#profile">-profile <var>filename</var></a></td>
242 <td>add, delete, or apply an image profile</td>
cristy3ed852e2009-09-05 21:47:34 +0000243 </tr>
244
245 <tr>
cristyd2432012015-05-04 23:15:15 +0000246 <td><a href="command-line-options.html#quality">-quality <var>value</var></a></td>
247 <td>JPEG/MIFF/PNG compression level</td>
cristy3ed852e2009-09-05 21:47:34 +0000248 </tr>
249
250 <tr>
cristyd2432012015-05-04 23:15:15 +0000251 <td><a href="command-line-options.html#quantize">-quantize <var>colorspace</var></a></td>
252 <td>reduce image colors in this colorspace</td>
cristy3ed852e2009-09-05 21:47:34 +0000253 </tr>
254
255 <tr>
cristyd2432012015-05-04 23:15:15 +0000256 <td><a href="command-line-options.html#quiet">-quiet</a></td>
257 <td>suppress all warning messages</td>
cristy3ed852e2009-09-05 21:47:34 +0000258 </tr>
259
260 <tr>
cristyd2432012015-05-04 23:15:15 +0000261 <td><a href="command-line-options.html#regard-warnings">-regard-warnings</a></td>
262 <td>pay attention to warning messages.</td>
cristy3ed852e2009-09-05 21:47:34 +0000263 </tr>
264
265 <tr>
cristyd2432012015-05-04 23:15:15 +0000266 <td><a href="command-line-options.html#respect-parentheses">-respect-parentheses</a></td>
267 <td>settings remain in effect until parenthesis boundary.</td>
cristy3ed852e2009-09-05 21:47:34 +0000268 </tr>
269
270 <tr>
cristyd2432012015-05-04 23:15:15 +0000271 <td><a href="command-line-options.html#sampling-factor">-sampling-factor <var>geometry</var></a></td>
272 <td>horizontal and vertical sampling factor</td>
cristy3ed852e2009-09-05 21:47:34 +0000273 </tr>
274
275 <tr>
cristyd2432012015-05-04 23:15:15 +0000276 <td><a href="command-line-options.html#seed">-seed <var>value</var></a></td>
277 <td>seed a new sequence of pseudo-random numbers</td>
cristy3ed852e2009-09-05 21:47:34 +0000278 </tr>
279
280 <tr>
cristyd2432012015-05-04 23:15:15 +0000281 <td><a href="command-line-options.html#set">-set <var>attribute value</var></a></td>
282 <td>set an image attribute</td>
cristy3ed852e2009-09-05 21:47:34 +0000283 </tr>
284
285 <tr>
cristyd2432012015-05-04 23:15:15 +0000286 <td><a href="command-line-options.html#similarity-threshold">-similarity-threshold <var>value</var></a></td>
287 <td>minimum distortion for (sub)image match (default 0.0)</td>
cristy8ee7f242013-06-20 16:08:44 +0000288 </tr>
289
290 <tr>
cristyd2432012015-05-04 23:15:15 +0000291 <td><a href="command-line-options.html#size">-size <var>geometry</var></a></td>
292 <td>width and height of image</td>
cristy3ed852e2009-09-05 21:47:34 +0000293 </tr>
294
295 <tr>
cristyd2432012015-05-04 23:15:15 +0000296 <td><a href="command-line-options.html#subimage-search">-subimage-search</a></td>
297 <td>search for subimage</td>
cristyae6203d2010-08-09 01:12:14 +0000298 </tr>
299
300 <tr>
cristyd2432012015-05-04 23:15:15 +0000301 <td><a href="command-line-options.html#synchronize">-synchronize</a></td>
302 <td>synchronize image to storage device</td>
cristy5063d812010-10-19 16:28:10 +0000303 </tr>
304
305 <tr>
cristyd2432012015-05-04 23:15:15 +0000306 <td><a href="command-line-options.html#taint">-taint</a></td>
307 <td>mark the image as modified</td>
cristy5063d812010-10-19 16:28:10 +0000308 </tr>
309
310 <tr>
cristyd2432012015-05-04 23:15:15 +0000311 <td><a href="command-line-options.html#transparent-color">-transparent-color <var>color</var></a></td>
312 <td>transparent color</td>
cristy3ed852e2009-09-05 21:47:34 +0000313 </tr>
314
315 <tr>
cristyd2432012015-05-04 23:15:15 +0000316 <td><a href="command-line-options.html#verbose">-verbose</a></td>
317 <td>print detailed information about the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000318 </tr>
319
320 <tr>
cristyd2432012015-05-04 23:15:15 +0000321 <td><a href="command-line-options.html#version">-version</a></td>
322 <td>print version information</td>
cristy3ed852e2009-09-05 21:47:34 +0000323 </tr>
324
325 <tr>
cristyd2432012015-05-04 23:15:15 +0000326 <td><a href="command-line-options.html#virtual-pixel">-virtual-pixel <var>method</var></a></td>
327 <td>access method for pixels outside the boundaries of the image</td>
cristy3ed852e2009-09-05 21:47:34 +0000328 </tr>
329
330 </tbody>
331</table>
cristy751980d2012-06-03 23:18:35 +0000332</div>
cristyd2432012015-05-04 23:15:15 +0000333 <footer class="magick-footer">
cristy29f2c972015-07-28 13:37:46 +0000334 <p><a href="support.html">Donate</a>
335 <a href="sitemap.html">Sitemap</a>
cristyd2432012015-05-04 23:15:15 +0000336 <a href="links.html">Related</a>
cristy29f2c972015-07-28 13:37:46 +0000337 <a href="architecture.html">Architecture</a>
cristyd2432012015-05-04 23:15:15 +0000338</p>
339 <p><a href="compare.html#">Back to top</a>
cristyea2793e2015-05-31 16:52:26 +0000340 <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a>
Cristy1f1f3a02016-06-01 07:25:42 -0400341 <a href="http://www.imagemagick.org/script/contact.php">Contact Us</a></p>
Cristyde27d762016-01-02 12:56:44 -0500342 <p><small>© 1999-2016 ImageMagick Studio LLC</small></p>
cristyd2432012015-05-04 23:15:15 +0000343 </footer>
344</div><!-- /.container -->
cristyad41c0c2012-10-31 00:49:28 +0000345
Cristy542697a2015-10-12 20:10:32 -0400346 <script src="https://localhost/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
Cristy1f1f3a02016-06-01 07:25:42 -0400347 <script src="../js/magick.html"></script>
cristyad41c0c2012-10-31 00:49:28 +0000348</div>
cristyad41c0c2012-10-31 00:49:28 +0000349</body>
cristy5a367e42015-05-05 12:39:18 +0000350</html>
Cristy912a9222016-06-17 15:37:28 -0400351<!-- Magick Cache 17th June 2016 14:42 -->