upstream/tools/image_processing/imagej2/imagej2_math.xml
1<tool id="imagej2_math" name="Operate on pixels" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="23.0">
2 <description>with ImageJ2</description>
3 <macros>
4 <import>imagej2_macros.xml</import>
5 </macros>
6 <edam_operations>
7 <edam_operation>operation_3443</edam_operation>
8 </edam_operations>
9 <xrefs>
10 <xref type="bio.tools">imagej</xref>
11 <xref type="biii">imagej2</xref>
12 </xrefs>
13 <expand macro="fiji_requirements"/>
14 <command detect_errors="exit_code"><![CDATA[
15#import os
16#set input_sans_ext = $os.path.splitext($os.path.basename($input.file_name))[0]
17#set input_with_ext = './' + '.'.join([input_sans_ext, $input.ext])
18ln -s '$input.file_name' '$input_with_ext' &&
19#set output_filename = '.'.join(['output', $input.ext])
20touch '$output_filename' &&
21ImageJ --ij2 --headless --debug
22--jython '$__tool_directory__/imagej2_math_jython_script.py'
23'$input_with_ext'
24'$operation_cond.operation'
25#if str($operation_cond.operation) == 'Macro':
26 '$operation_cond.expression'
27#else:
28 'None'
29#end if
30#if str($operation_cond.operation) in ['AND', 'OR', 'XOR']:
31 $operation_cond.bin_constant
32#else:
33 'None'
34#end if
35#if str($operation_cond.operation) not in ['Macro', 'AND', 'OR', 'XOR', 'Log', 'Exp', 'Square', 'Square_Root', 'Abs', 'Reciprocal']:
36 $operation_cond.float_constant
37#else:
38 'None'
39#end if
40'$output_filename'
41'$input.ext'
42&& mv '$output_filename' '$output'
43]]></command>
44 <inputs>
45 <expand macro="param_input"/>
46 <!--
47 NOTE: The NaN Background option is not included here because it only works with 32-bit
48 thresholded images, and incorporating the functionality from the Adjust threshold tool
49 here for this option would be too messy.
50 -->
51 <conditional name="operation_cond">
52 <param name="operation" type="select" label="Operation">
53 <option value="Add">Add</option>
54 <option value="Subtract">Subtract</option>
55 <option value="Multiply">Multiply</option>
56 <option value="Divide">Divide</option>
57 <option value="AND">AND</option>
58 <option value="OR">OR</option>
59 <option value="XOR">XOR</option>
60 <option value="Min">Min</option>
61 <option value="Max">Max</option>
62 <option value="Gamma">Gamma</option>
63 <option value="Set">Set</option>
64 <option value="Log">Log</option>
65 <option value="Exp">Exp</option>
66 <option value="Square">Square</option>
67 <option value="Square_Root">Square Root</option>
68 <option value="Abs">Abs</option>
69 <option value="Reciprocal">Reciprocal</option>
70 <option value="Macro">Macro</option>
71 </param>
72 <when value="Add">
73 <param name="float_constant" type="float" value="25.0" label="Value" help="Value is a floating point number"/>
74 </when>
75 <when value="Subtract">
76 <param name="float_constant" type="float" value="25.0" label="Value" help="Value is a floating point number"/>
77 </when>
78 <when value="Multiply">
79 <param name="float_constant" type="float" value="1.250" label="Value" help="Value is a floating point number"/>
80 </when>
81 <when value="Divide">
82 <param name="float_constant" type="float" value="1.250" label="Value" help="Value is a floating point number"/>
83 </when>
84 <when value="AND">
85 <param name="bin_constant" type="integer" value="11110000" label="Value (binary)" help="Value is a binary number"/>
86 </when>
87 <when value="OR">
88 <param name="bin_constant" type="integer" value="11110000" label="Value (binary)" help="Value is a binary number"/>
89 </when>
90 <when value="XOR">
91 <param name="bin_constant" type="integer" value="11110000" label="Value (binary)" help="Value is a binary number"/>
92 </when>
93 <when value="Min">
94 <param name="float_constant" type="float" value="0" label="Value" help="Value is a floating point number"/>
95 </when>
96 <when value="Max">
97 <param name="float_constant" type="float" value="255" label="Value" help="Value is a floating point number"/>
98 </when>
99 <when value="Gamma">
100 <param name="float_constant" type="float" value="0.50" label="Value" help="Value is a floating point number"/>
101 </when>
102 <when value="Set">
103 <param name="float_constant" type="float" value="25" label="Value" help="Value is a floating point number"/>
104 </when>
105 <when value="Log"/>
106 <when value="Exp"/>
107 <when value="Square"/>
108 <when value="Square_Root"/>
109 <when value="Abs"/>
110 <when value="Reciprocal"/>
111 <when value="Macro">
112 <param name="expression" type="text" value="v=v+50*sin(d/17)" label="Code" help="v=pixel value, x,y and z=pixel coordinates, w=image width, h=image height, a=angle, d=distance from center"/>
113 </when>
114 </conditional>
115 </inputs>
116 <outputs>
117 <data name="output" format_source="input"/>
118 </outputs>
119 <tests>
120 <test>
121 <param name="input" value="blobs.gif"/>
122 <conditional name="operation_cond">
123 <param name="operation" value="Multiply"/>
124 </conditional>
125 <output name="output" file="blobs_multiply.gif" compare="image_diff"/>
126 </test>
127 <test>
128 <param name="input" value="blobs.gif"/>
129 <conditional name="operation_cond">
130 <param name="operation" value="Min"/>
131 <param name="float_constant" value="255"/>
132 </conditional>
133 <output name="output" file="blobs_min.gif" compare="image_diff"/>
134 </test>
135 <test>
136 <param name="input" value="blobs.gif"/>
137 <conditional name="operation_cond">
138 <param name="operation" value="Log"/>
139 </conditional>
140 <output name="output" file="blobs_log.gif" compare="image_diff"/>
141 </test>
142 <test>
143 <param name="input" value="blobs.gif"/>
144 <conditional name="operation_cond">
145 <param name="operation" value="Square"/>
146 </conditional>
147 <output name="output" file="blobs_square.gif" compare="image_diff"/>
148 </test>
149 <test>
150 <param name="input" value="blobs.gif"/>
151 <conditional name="operation_cond">
152 <param name="operation" value="Macro"/>
153 </conditional>
154 <output name="output" file="blobs_macro.gif" compare="image_diff"/>
155 </test>
156 </tests>
157 <help>
158
159**What it does**
160
161<![CDATA[
162
163Applies a mathematical expression (add, subtract, multiply, etc.) to each pixel in the image. When the
164resulting pixel value overflows/underflows the legal range of the image's data type, the value is reset
165to the maximum/minimum value.
166
167- **Add** - Adds a value to each pixel in the image. With 8-bit images, results greater than 255 are set to 255. nWith 16-bit signed images, results greater than 65,535 are set to 65,535.
168- **Subtract** - Subtracts a value from each pixel in the image. With 8-bit and 16-bit images, results less than 0 are set to 0.
169- **Multiply** - Multiplies each pixel in the image by a value. With 8-bit images, results greater than 255 are set to 255. With 16-bit signed images, results greater than 65,535 are set to 65,535.
170- **Divide** - Divides each pixel in the image by a value. Except for 32-bit (float) images, attempts to divide by zero are ignored. With 32-bit images, dividing by zero results in either NaN (0/0) or Infinity.
171- **AND** - Performs a bitwise AND of each pixel in the image with the value.
172- **OR** - Performs a bitwise OR of each pixel in the image with the value.
173- **XOR** - Performs a bitwise XOR of each pixel in the image with the value.
174- **Min** - Pixels in the image less than the value are replaced by the value.
175- **Max** - Pixels in the image greater than the value are replaced by the value.
176- **Gamma** - Applies the function f(p) = (p/255)^gamma*255 to each pixel (p) in the image, where 0.1 <= gamma <= 5.0. For RGB images, this function is applied to all three color channels. For 16-bit images, the image min and max are used for scaling instead of 255.
177- **Set** - Fills the image with the value.
178- **Log** - For 8-bit images, applies the function f(p) = log(p) * 255/log(255) to each pixel (p) in the image. For RGB images, this function is applied to all three color channels. For 16-bit images, the image min and max are used for scaling instead of 255. For float images, no scaling is done. To calculate log10 of the image, multiply the result of this operation by 0.4343 (1/log(10).
179- **Exp** - Performs an exponential transform on the image.
180- **Square** - Performs a square transform on the image.
181- **Square Root** - Performs a square root transform on the image.
182- **Abs** - Performs an absolute value transformation on the image. This option works only with 32-bit or signed 16-bit images. Other image types are automatically converted to 32-bit when this option is selected.
183- **Reciprocal** - Generates the reciprocal of the image. This option works only with 32-bit images. Other image types are automatically converted to 32-bit when this option is selected.
184- **Macro** - Performs image arithmetic using a user-specified expression. It can be used to create fully-synthetic images or to perform precise pixel manipulations on existing images.
185
186]]>
187
188 </help>
189 <expand macro="fiji_headless_citations"/>
190</tool>