upstream/tools/image_processing/imagemagick/compare.xml
1<tool id="imagemagick_image_compare" name="Compare two images" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="23.1">
2 <description>with ImageMagick</description>
3 <macros>
4 <import>macros.xml</import>
5 </macros>
6 <expand macro="requirements" />
7 <stdio>
8 <exit_code range="1:1" level="warning" description="The images are different" />
9 </stdio>
10 <command>
11<![CDATA[
12 ln -s '${input1}' "1.${input1.element_identifier}.${input1.ext}" &&
13 ln -s '${input2}' "2.${input2.element_identifier}.${input2.ext}" &&
14
15 #if $difference.diff_type == "compare":
16 magick compare
17 -metric $difference.compare_metric.metric
18 #if $difference.color!='default':
19 -highlight-color $color
20 #end if
21 #if str($difference.compare_metric.metric) == 'AE' :
22 #if $difference.compare_metric.fuzz :
23 -fuzz ${difference.compare_metric.fuzz}%
24 #end if
25 #else if str($difference.compare_metric.metric) == 'RMSE' :
26 -dissimilarity-threshold $difference.compare_metric.dissimilarity
27 #end if
28 -verbose
29 #if $input_stats:
30 -identify
31 #end if
32 "1.${input1.element_identifier}.${input1.ext}"
33 "2.${input2.element_identifier}.${input2.ext}"
34 outfile.png
35 2> out.log
36 #if $input_stats:
37 1> stats_input.log
38 #end if
39
40 #else if $difference.diff_type == "composite":
41 magick composite
42 -compose difference
43 -verbose
44 #if $input_stats:
45 -identify
46 #end if
47 "1.${input1.element_identifier}.${input1.ext}"
48 "2.${input2.element_identifier}.${input2.ext}"
49 outfile.png
50 #if $input_stats:
51 1> stats_input.log
52 #end if
53
54 #if $difference.normalize:
55 &&
56 magick
57 outfile.png
58 -auto-level
59 outfile_normalised.png
60 #end if
61 #end if
62]]>
63 </command>
64 <inputs>
65 <param name="input1" format="jpg,png,bmp,gif,svg,eps,tiff" type="data" label="First image to compare" />
66 <param name="input2" format="jpg,png,bmp,gif,svg,eps,tiff" type="data" label="Second image to compare" />
67 <param name="input_stats" type="boolean" value="false" label="Output Statistics about input images." />
68 <conditional name="difference">
69 <param name="diff_type" type="select" value="compare" label="What method should be use to compare the images?">
70 <option value="composite" selected="true">Composite: Overlap the images</option>
71 <option value="compare" >Compare: Annotate the differences</option>
72 </param>
73 <when value="compare">
74 <conditional name="compare_metric">
75 <param name="metric" type="select" label="Comparison metric">
76 <option value="AE">absolute error count, number of different pixels (-fuzz affected)</option>
77 <option value="DPC">discrete phase correlation</option>
78 <option value="DSSIM">structural dissimilarity index</option>
79 <option value="FUZZ">mean color distance</option>
80 <option value="MAE" >mean absolute error (normalized), average channel error distance</option>
81 <option value="MEPP">mean error per pixel (normalized mean error, normalized peak error)</option>
82 <option value="MSE">mean error squared, average of the channel error squared</option>
83 <option value="NCC">normalized cross correlation</option>
84 <option value="PAE">peak absolute (normalized peak absolute)</option>
85 <option value="PHASE">phase correlation</option>
86 <option value="PSNR">peak signal to noise ration</option>
87 <option value="RMSE" selected="true">root mean squared (normalized root mean squared)</option>
88 <option value="SSIM">structural similarity index</option>
89 </param>
90 <when value="AE">
91 <param name="fuzz" type="integer" label="Fuzz in %" optional="true" help="Two images are considered similar if their difference according to the specified metric and fuzz value is 0, with the exception of the normalized cross correlation metric (NCC), where two images are considered similar when their normalized cross correlation is 1." />
92 </when>
93 <when value="MAE" />
94 <when value="DPC" />
95 <when value="DSSIM" />
96 <when value="FUZZ" />
97 <when value="MEPP" />
98 <when value="MEPP" />
99 <when value="MSE" />
100 <when value="NCC" />
101 <when value="PAE" />
102 <when value="PHASE" />
103 <when value="PSNR" />
104 <when value="RMSE">
105 <param name="dissimilarity" type="float" label="Dissimilarity threshold" value="0.2" help="Maximum RMSE for subimage match (default 0.2)" />
106 </when>
107 <when value="SSIM" />
108 </conditional>
109 <expand macro="color" />
110 </when>
111 <when value="composite">
112 <param name="normalize" type="boolean" value="false" label="Output normalized image" help= "Useful if the contrast is too low to see the differences."/>
113 </when>
114 </conditional>
115
116 </inputs>
117 <outputs>
118 <data name="output" format="png" from_work_dir="outfile.png"/>
119 <data name="log" format="txt" from_work_dir="out.log" label="${tool.name} on ${on_string}: Comparison Statistics">
120 <filter> difference['diff_type'] == 'compare' </filter>
121 </data>
122 <data name="output_norm" format="png" from_work_dir="outfile_normalised.png" label="${tool.name} on ${on_string}: Normalized" >
123 <filter> difference['diff_type'] == 'composite' and difference['normalize']</filter>
124 </data>
125 <data name="output_stats" format="txt" from_work_dir="stats_input.log" label="${tool.name} on ${on_string}: Input Statistics" >
126 <filter> input_stats </filter>
127 </data>
128
129 </outputs>
130 <tests>
131 <test expect_num_outputs="2">
132 <param name="input1" value="donald.jpg" />
133 <param name="input2" value="donald-palette.jpg" />
134 <conditional name="difference">
135 <param name="diff_type" value="compare" />
136 <conditional name="compare_metric">
137 <param name="metric" value="RMSE" />
138 </conditional>
139 </conditional>
140 <output name="output" file="result_image_compare01.png" compare="sim_size" delta="500" />
141 <output name="log" file="result_image_compare01.log" compare="contains"/>
142 </test>
143 <test expect_num_outputs="2">
144 <param name="input1" value="donald.jpg" />
145 <param name="input2" value="donald-palette.jpg" />
146 <conditional name="difference">
147 <param name="diff_type" value="compare" />
148 <conditional name="compare_metric">
149 <param name="metric" value="MAE" />
150 </conditional>
151 <param name="color" value="white" />
152 </conditional>
153 <output name="output" file="result_image_compare02.png" compare="sim_size" delta="500" />
154 <output name="log" file="result_image_compare02.log" compare="contains"/>
155 </test>
156 <test expect_num_outputs="2">
157 <param name="input1" value="donald.jpg" />
158 <param name="input2" value="donald-palette.jpg" />
159 <conditional name="difference">
160 <param name="diff_type" value="compare" />
161 <conditional name="compare_metric">
162 <param name="metric" value="AE" />
163 <param name="fuzz" value="3"/>
164 </conditional>
165 </conditional>
166 <output name="output" file="result_image_compare03.png" compare="sim_size" delta="500" />
167 <output name="log" file="result_image_compare03.log" compare="contains"/>
168 </test>
169 <test expect_num_outputs="2">
170 <param name="input1" value="donald.jpg" />
171 <param name="input2" value="donald-palette.jpg" />
172 <conditional name="difference">
173 <param name="diff_type" value="composite" />
174 <param name="normalize" value="true" />
175 </conditional>
176 <output name="output" file="result_image_composite01.png" compare="sim_size" delta="500" />
177 <output name="output_norm" file="result_image_composite01_norm.png" compare="sim_size" delta="500"/>
178 </test>
179 <test expect_num_outputs="2">
180 <param name="input1" value="donald.jpg" />
181 <param name="input2" value="donald-palette.jpg" />
182 <param name="input_stats" value="true" />
183 <conditional name="difference">
184 <param name="diff_type" value="composite" />
185 </conditional>
186 <output name="output" file="result_image_composite01.png" compare="sim_size" delta="500" />
187 <output name="output_stats" file="result_image_composite01_stats.txt" compare="contains"/>
188 </test>
189 </tests>
190 <help>
191<![CDATA[
192
193**What it does**
194
195This tool compares two images and provides a diff by pixels.
196
197Modes :
198- Compare: mathematically and visually annotate the difference between an image and its reconstruction.
199- Composite: overlap one image over another and highlight differences
200
201Metric parameter in compare mode:
202
203Output to STDERR a measure of the differences between images according to the type given metric.
204Control the 'AE', or absolute count of pixels that are different, with the -fuzz factor (ignore pixels which only changed by a small amount). Use 'PAE' to find the size of the -fuzz factor needed to make all pixels 'similar', while 'MAE' determines the factor needed for about half the pixels to be similar.
205The MEPP metric returns three different metrics ('MAE', 'MAE' normalized, and 'PAE' normalized) from a single comparison run.
206The SSIM and DSSIM metrics respect these defines: -define compare:ssim-radius, -define compare:ssim-sigma, -define compare:ssim-k1, and -define compare:ssim-k2.
207
208
209]]>
210 </help>
211 <expand macro="citations" />
212</tool>