blob: 2743d3e6367266784235a22ecea94d38f022dc6e [file] [log] [blame]
Cristy594d2772015-11-15 10:47:42 -05001
2
3
4
cristy29dc8652015-05-12 16:26:21 +00005<!DOCTYPE html>
cristy44443b92015-05-05 00:06:07 +00006<html lang="en">
cristy06f63f22012-10-31 00:50:07 +00007<head>
Cristy72727872017-12-08 15:08:14 -05008 <meta charset="utf-8" >
9 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" >
10 <title>Command-line Tools: Compare @ ImageMagick</title>
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="https://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-2017 ImageMagick Studio LLC">
23 <meta name="distribution" content="Global">
24 <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1">
25 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
26 <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4">
27 <link href="../compare.html" rel="canonical">
28 <link href="../../images/wand.png" rel="icon">
29 <link href="../../images/wand.ico" rel="shortcut icon">
30 <link href="../assets/bootstrap.min.css" rel="stylesheet">
31 <link href="../assets/magick-template.css" rel="stylesheet">
cristy06f63f22012-10-31 00:50:07 +000032</head>
cristy44443b92015-05-05 00:06:07 +000033<body>
Cristy72727872017-12-08 15:08:14 -050034 <header>
35 <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
36 <a class="navbar-brand" href="https://www.imagemagick.org/#">ImageMagick</a>
37 <button class="navbar-toggler collapsed" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
38 <span class="navbar-toggler-icon"></span>
39 </button>
40
41 <div class="navbar-collapse collapse" id="navbarsExampleDefault" style="">
42 <ul class="navbar-nav mr-auto">
43 <li class="nav-item ">
44 <a class="nav-link" href="https://www.imagemagick.org/index.html">Home <span class="sr-only">(current)</span></a>
45 </li>
46 <li class="nav-item ">
47 <a class="nav-link" href="../download.html">Download</a>
48 </li>
49 <li class="nav-item ">
50 <a class="nav-link" href="../command-line-tools.html">Tools</a>
51 </li>
52 <li class="nav-item ">
53 <a class="nav-link" href="../command-line-processing.html">Command-line</a>
54 </li>
55 <li class="nav-item ">
56 <a class="nav-link" href="../resources.html">Resources</a>
57 </li>
58 <li class="nav-item ">
59 <a class="nav-link" href="../develop.html">Develop</a>
60 </li>
61 <li class="nav-item">
62 <a class="nav-link" href="https://www.imagemagick.org/discourse-server/">Community</a>
63 </li>
64 </ul>
65 <form class="form-inline my-2 my-lg-0" action="../search.html">
66 <!-- <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search"> -->
67 <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
68 </form>
69 </div>
70 </nav>
71 </header>
72 <main role="main" class="container">
73 <div class="magick-template">
cristy4e638cd2015-05-07 16:47:40 +000074<div class="magick-header">
Cristy72727872017-12-08 15:08:14 -050075<p class="text-center"><a href="compare.html#usage">Example Usage</a><a href="compare.html#options">Option Summary</a></p>
cristy06f63f22012-10-31 00:50:07 +000076
Cristy72727872017-12-08 15:08:14 -050077<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>
cristycecc9492015-06-09 16:53:50 +000078
Cristy72727872017-12-08 15:08:14 -050079<h2 class="magick-post-title"><a id="usage"></a>Example Usage</h2>
cristycecc9492015-06-09 16:53:50 +000080
Cristy72727872017-12-08 15:08:14 -050081<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>
cristycecc9492015-06-09 16:53:50 +000082
Cristy72727872017-12-08 15:08:14 -050083<pre class="highlight"><code>magick convert rose.jpg -sharpen 0x1 reconstruct.jpg
84magick compare rose.jpg reconstruct.jpg difference.png
85magick compare -compose src rose.jpg reconstruct.jpg difference.png
86</code></pre>
cristycecc9492015-06-09 16:53:50 +000087
Cristy72727872017-12-08 15:08:14 -050088<ul>
89 <a href="../../images/rose.jpg"><img src="../../images/rose.jpg" width="70" height="46" alt="rose" /></a>
90 <a href="../../images/reconstruct.jpg"><img src="../../images/reconstruct.jpg" width="70" height="46" alt="rose" /></a>
91 <img style="margin:13px 0;" src="../../images/right.gif" width="20" height="20" alt="==>" />
92 <a href="../../images/difference.png"><img src="../../images/difference.png" width="70" height="46" alt="rose" /></a>
93</ul>
cristycecc9492015-06-09 16:53:50 +000094
Cristy72727872017-12-08 15:08:14 -050095<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>
cristycecc9492015-06-09 16:53:50 +000096
Cristy72727872017-12-08 15:08:14 -050097<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>
cristycecc9492015-06-09 16:53:50 +000098
Cristy72727872017-12-08 15:08:14 -050099<pre class="highlight"><code>-> magick compare -verbose -metric mae rose.jpg reconstruct.jpg difference.png
100Image: rose.jpg
101 Channel distortion: MAE
102 red: 2282.91 (0.034835)
103 green: 1853.99 (0.0282901)
104 blue: 2008.67 (0.0306503)
105 all: 1536.39 (0.0234439)
106</code></pre>
107<p>Or, if you just want the red channel distortion, use this command:</p>
cristycecc9492015-06-09 16:53:50 +0000108
Cristy72727872017-12-08 15:08:14 -0500109<pre class="highlight"><code>-> magick compare -channel red -metric PSNR rose.jpg reconstruct.jpg difference.png
11019.63
111</code></pre>
cristycecc9492015-06-09 16:53:50 +0000112
Cristy72727872017-12-08 15:08:14 -0500113<p>Or, if you just want the overall image distortion, use this command:</p>
cristycecc9492015-06-09 16:53:50 +0000114
Cristy72727872017-12-08 15:08:14 -0500115<pre class="highlight"><code>-> magick compare -metric PSNR rose.jpg reconstruct.jpg difference.png
11628.31
117</code></pre>
cristycecc9492015-06-09 16:53:50 +0000118
Cristy72727872017-12-08 15:08:14 -0500119<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>
120
121<pre class="highlight"><code>-> magick compare -metric RMSE -subimage-search logo.png wizard.jpg similarity.gif
12285.05 (0.00129778) @ 353,157
123</code></pre>
124
125<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="https://www.imagemagick.org/Usage/">Examples of ImageMagick Usage</a>.</p>
126
127<p>The compare program returns 2 on error otherwise 0 if the images are similar or 1 if they are dissimilar.</p>
128
129<h2 class="magick-post-title"><a id="options"></a>Option Summary</h2>
130
131<p>The <code>compare</code> command recognizes these options. Click on an option to get more details about how that option works.</p>
132
133<table class="table table-sm table-striped">
134 <tbody>
135 <tr>
136 <th align="left">Option</th>
137 <th align="left">Description</th>
138 </tr>
139
140 <tr>
141 <td><a href="../command-line-options.html#alpha">-alpha</a></td>
142 <td>on, activate, off, deactivate, set, opaque, copy",
143transparent, extract, background, or shape the alpha channel</td>
144 </tr>
145
146 <tr>
147 <td><a href="../command-line-options.html#authenticate">-authenticate <var>value</var></a></td>
148 <td>decrypt image with this password</td>
149 </tr>
150
151 <tr>
152 <td><a href="../command-line-options.html#background">-background <var>color</var></a></td>
153 <td>background color</td>
154 </tr>
155
156 <tr>
157 <td><a href="../command-line-options.html#brightness-contrast">-brightness-contrast <var>geometry</var></a></td>
158 <td>improve brightness / contrast of the image</td>
159 </tr>
160
161 <tr>
162 <td><a href="../command-line-options.html#channel">-channel <var>type</var></a></td>
163 <td>apply option to select image channels</td>
164 </tr>
165
166 <tr>
167 <td><a href="../command-line-options.html#colorspace">-colorspace <var>type</var></a></td>
168 <td>set image colorspace</td>
169 </tr>
170
171 <tr>
172 <td><a href="../command-line-options.html#compose">-compose <var>operator</var></a></td>
173 <td>set image composite operator</td>
174 </tr>
175
176 <tr>
177 <td><a href="../command-line-options.html#crop">-crop <var>geometry</var></a></td>
178 <td>crop the image</td>
179 </tr>
180
181 <tr>
182 <td><a href="../command-line-options.html#decipher">-decipher <var>filename</var></a></td>
183 <td>convert cipher pixels to plain</td>
184 </tr>
185
186 <tr>
187 <td><a href="../command-line-options.html#debug">-debug <var>events</var></a></td>
188 <td>display copious debugging information</td>
189 </tr>
190
191 <tr>
192 <td><a href="../command-line-options.html#define">-define <var>format:option</var></a></td>
193 <td>define one or more image format options</td>
194 </tr>
195
196 <tr>
197 <td><a href="../command-line-options.html#density">-density <var>geometry</var></a></td>
198 <td>horizontal and vertical density of the image</td>
199 </tr>
200
201 <tr>
202 <td><a href="../command-line-options.html#depth">-depth <var>value</var></a></td>
203 <td>image depth</td>
204 </tr>
205
206 <tr>
207 <td><a href="../command-line-options.html#dissimilarity-threshold">-dissimilarity-threshold <var>value</var></a></td>
208 <td>maximum distortion for (sub)image match (default 0.2)</td>
209 </tr>
210
211 <tr>
212 <td><a href="../command-line-options.html#distort">-distort <var>type coefficients</var></a></td>
213 <td>distort image</td>
214 </tr>
215
216 <tr>
217 <td><a href="../command-line-options.html#encipher">-encipher <var>filename</var></a></td>
218 <td>convert plain pixels to cipher pixels</td>
219 </tr>
220
221 <tr>
222 <td><a href="../command-line-options.html#extract">-extract <var>geometry</var></a></td>
223 <td>extract area from image</td>
224 </tr>
225
226 <tr>
227 <td><a href="../command-line-options.html#fuzz">-fuzz <var>distance</var></a></td>
228 <td>colors within this distance are considered equal</td>
229 </tr>
230
231 <tr>
232 <td><a href="../command-line-options.html#gravity">-gravity <var>type</var></a></td>
233 <td>horizontal and vertical text placement</td>
234 </tr>
235
236 <tr>
237 <td><a href="../command-line-options.html#help">-help</a></td>
238 <td>print program options</td>
239 </tr>
240
241 <tr>
242 <td><a href="../command-line-options.html#highlight-color">-highlight-color <var>color</var></a></td>
243 <td>emphasize pixel differences with this color</td>
244 </tr>
245
246 <tr>
247 <td><a href="../command-line-options.html#identify">-identify</a></td>
248 <td>identify the format and characteristics of the image</td>
249 </tr>
250
251 <tr>
252 <td><a href="../command-line-options.html#interlace">-interlace <var>type</var></a></td>
253 <td>type of image interlacing scheme</td>
254 </tr>
255
256 <tr>
257 <td><a href="../command-line-options.html#level">-level <var>value</var></a></td>
258 <td>adjust the level of image contrast</td>
259 </tr>
260
261 <tr>
262 <td><a href="../command-line-options.html#limit">-limit <var>type value</var></a></td>
263 <td>pixel cache resource limit</td>
264 </tr>
265
266 <tr>
267 <td><a href="../command-line-options.html#log">-log <var>format</var></a></td>
268 <td>format of debugging information</td>
269 </tr>
270
271 <tr>
272 <td><a href="../command-line-options.html#lowlight-color">-lowlight-color <var>color</var></a></td>
273 <td>de-emphasize pixel differences with this color</td>
274 </tr>
275
276 <tr>
277 <td><a href="../command-line-options.html#metric">-metric <var>type</var></a></td>
278 <td>measure differences between images with this metric</td>
279 </tr>
280
281 <tr>
282 <td><a href="../command-line-options.html#negate">-negate</a></td>
283 <td>replace each pixel with its complementary color </td>
284 </tr>
285
286 <tr>
287 <td><a href="../command-line-options.html#profile">-profile <var>filename</var></a></td>
288 <td>add, delete, or apply an image profile</td>
289 </tr>
290
291 <tr>
292 <td><a href="../command-line-options.html#quality">-quality <var>value</var></a></td>
293 <td>JPEG/MIFF/PNG compression level</td>
294 </tr>
295
296 <tr>
297 <td><a href="../command-line-options.html#quantize">-quantize <var>colorspace</var></a></td>
298 <td>reduce image colors in this colorspace</td>
299 </tr>
300
301 <tr>
302 <td><a href="../command-line-options.html#quiet">-quiet</a></td>
303 <td>suppress all warning messages</td>
304 </tr>
305
306 <tr>
307 <td><a href="../command-line-options.html#read-mask">-read-mask <var>filename</var></a></td>
308 <td>associate a read mask with the image</td>
309 </tr>
310
311 <tr>
312 <td><a href="../command-line-options.html#regard-warnings">-regard-warnings</a></td>
313 <td>pay attention to warning messages.</td>
314 </tr>
315
316 <tr>
317 <td><a href="../command-line-options.html#repage">-repage <var>geometry</var></a></td>
318 <td>size and location of an image canvas</td>
319 </tr>
320
321 <tr>
322 <td><a href="../command-line-options.html#resize">-resize <var>geometry</var></a></td>
323 <td>resize the image</td>
324 </tr>
325
326 <tr>
327 <td><a href="../command-line-options.html#respect-parentheses">-respect-parentheses</a></td>
328 <td>settings remain in effect until parenthesis boundary.</td>
329 </tr>
330
331 <tr>
332 <td><a href="../command-line-options.html#rotate">-rotate <var>degrees</var></a></td>
333 <td>apply Paeth rotation to the image</td>
334 </tr>
335
336 <tr>
337 <td><a href="../command-line-options.html#sampling-factor">-sampling-factor <var>geometry</var></a></td>
338 <td>horizontal and vertical sampling factor</td>
339 </tr>
340
341 <tr>
342 <td><a href="../command-line-options.html#seed">-seed <var>value</var></a></td>
343 <td>seed a new sequence of pseudo-random numbers</td>
344 </tr>
345
346 <tr>
347 <td><a href="../command-line-options.html#separate">-separate</a></td>
348 <td>separate an image channel into a grayscale image</td>
349 </tr>
350
351 <tr>
352 <td><a href="../command-line-options.html#set">-set <var>attribute value</var></a></td>
353 <td>set an image attribute</td>
354 </tr>
355
356 <tr>
357 <td><a href="../command-line-options.html#sigmoidal">-sigmoidal-contrast <var>geometry</var></a></td>
358 <td>increase the contrast without saturating highlights or shadows</td>
359 </tr>
360
361 <tr>
362 <td><a href="../command-line-options.html#similarity-threshold">-similarity-threshold <var>value</var></a></td>
363 <td>minimum distortion for (sub)image match (default 0.0)</td>
364 </tr>
365
366 <tr>
367 <td><a href="../command-line-options.html#size">-size <var>geometry</var></a></td>
368 <td>width and height of image</td>
369 </tr>
370
371 <tr>
372 <td><a href="../command-line-options.html#subimage-search">-subimage-search</a></td>
373 <td>search for subimage</td>
374 </tr>
375
376 <tr>
377 <td><a href="../command-line-options.html#synchronize">-synchronize</a></td>
378 <td>synchronize image to storage device</td>
379 </tr>
380
381 <tr>
382 <td><a href="../command-line-options.html#taint">-taint</a></td>
383 <td>mark the image as modified</td>
384 </tr>
385
386 <tr>
387 <td><a href="../command-line-options.html#transparent-color">-transparent-color <var>color</var></a></td>
388 <td>transparent color</td>
389 </tr>
390
391 <tr>
392 <td><a href="../command-line-options.html#trim">-trim</a></td>
393 <td>trim image edges</td>
394 </tr>
395
396 <tr>
397 <td><a href="../command-line-options.html#verbose">-verbose</a></td>
398 <td>print detailed information about the image</td>
399 </tr>
400
401 <tr>
402 <td><a href="../command-line-options.html#version">-version</a></td>
403 <td>print version information</td>
404 </tr>
405
406 <tr>
407 <td><a href="../command-line-options.html#virtual-pixel">-virtual-pixel <var>method</var></a></td>
408 <td>access method for pixels outside the boundaries of the image</td>
409 </tr>
410
411 <tr>
412 <td><a href="../command-line-options.html#write-mask">-read-mask <var>filename</var></a></td>
413 <td>associate a write mask with the image</td>
414 </tr>
415
416 </tbody>
417</table>
cristy06f63f22012-10-31 00:50:07 +0000418</div>
Cristy72727872017-12-08 15:08:14 -0500419 </div>
420 </main><!-- /.container -->
cristy44443b92015-05-05 00:06:07 +0000421 <footer class="magick-footer">
Cristy72727872017-12-08 15:08:14 -0500422 <p><a href="../support.html">Donate</a>
423 <a href="../sitemap.html">Sitemap</a>
424 <a href="../links.html">Related</a>
425 <a href="../security-policy.html">Security</a>
426 <a href="../architecture.html">Architecture</a>
cristy44443b92015-05-05 00:06:07 +0000427</p>
428 <p><a href="compare.html#">Back to top</a>
cristyea2793e2015-05-31 16:52:26 +0000429 <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a>
Cristy72727872017-12-08 15:08:14 -0500430 <a href="../contact.html">Contact Us</a></p>
Cristy93b707b2017-12-06 07:05:51 -0500431 <p><small>© 1999-2018 ImageMagick Studio LLC</small></p>
cristy44443b92015-05-05 00:06:07 +0000432 </footer>
cristy06f63f22012-10-31 00:50:07 +0000433
Cristy72727872017-12-08 15:08:14 -0500434 <!-- Javascript assets -->
435 <script src="../assets/jquery-3.2.1.slim.min.js" crossorigin="anonymous"></script>
436 <script src="../assets/popper.min.js" crossorigin="anonymous"></script>
437 <script>window.jQuery || document.write('<script src="../assets/jquery.min.js"><\/script>')</script>
438 <script src="../assets/bootstrap.min.js"></script>
439
cristy06f63f22012-10-31 00:50:07 +0000440</body>
cristy5a367e42015-05-05 12:39:18 +0000441</html>
Cristy72727872017-12-08 15:08:14 -0500442<!-- Magick Cache 8th December 2017 14:39 -->