upstream/tools/image_processing/imagej2/imagej2_enhance_contrast.xml
1<tool id="imagej2_enhance_contrast" name="Enhance contrast" 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_enhance_contrast_jython_script.py'
23'$input_with_ext'
24'$equalize_histogram_cond.equalize_histogram'
25#if $equalize_histogram_cond.equalize_histogram == 'no':
26 $equalize_histogram_cond.saturated_pixels
27 '$equalize_histogram_cond.normalize'
28#else:
29 'None'
30 'no'
31#end if
32'$output_filename'
33'$input.ext'
34&& mv '$output_filename' '$output';
35]]></command>
36 <inputs>
37 <expand macro="param_input"/>
38 <conditional name="equalize_histogram_cond">
39 <param name="equalize_histogram" type="select" label="Equalize histogram?">
40 <option value="no" selected="True">No</option>
41 <option value="yes">Yes</option>
42 </param>
43 <when value="no">
44 <param name="saturated_pixels" type="float" value="0.3" min="0.0" max="100.0" label="Saturated pixels pct" help="Value is percentage of total number of pixels">
45 <validator type="in_range" min="0" exclude_min="true" max="100"/>
46 </param>
47 <param name="normalize" type="select" label="Normalize?">
48 <option value="no" selected="True">No</option>
49 <option value="yes">Yes</option>
50 </param>
51 </when>
52 <when value="yes"/>
53 </conditional>
54 </inputs>
55 <outputs>
56 <data name="output" format_source="input"/>
57 </outputs>
58 <tests>
59 <test>
60 <param name="input" value="blobs.gif"/>
61 <conditional name="equalize_histogram_cond">
62 <param name="equalize_histogram" value="yes"/>
63 </conditional>
64 <output name="output" file="blobs_equalize.gif" compare="image_diff"/>
65 </test>
66 <test>
67 <param name="input" value="blobs.gif"/>
68 <conditional name="equalize_histogram_cond">
69 <param name="equalize_histogram" value="no"/>
70 <param name="saturated_pixels" value="6.2"/>
71 </conditional>
72 <output name="output" file="blobs_saturate.gif" compare="image_diff"/>
73 </test>
74 <test>
75 <param name="input" value="blobs.gif"/>
76 <conditional name="equalize_histogram_cond">
77 <param name="equalize_histogram" value="no"/>
78 <param name="saturated_pixels" value="13.0"/>
79 <param name="normalize" value="yes"/>
80 </conditional>
81 <output name="output" file="blobs_normalize.gif" compare="image_diff"/>
82 </test>
83 </tests>
84 <help>
85
86**What it does**
87
88<![CDATA[
89
90Enhances image contrast by using either normalization (contrast stretching) or histogram
91equalization.
92
93Normalization (i.e., contrast stretching) attempts to improve the contrast in an image by
94stretching the range of intensity values it contains to span a desired range of values
95(e.g. the the full range of pixel values that the image type allows). It differs from the
96more sophisticated histogram equalization in that it can only apply a linear scaling function
97to the image pixel values. As a result the enhancement is less harsh.
98
99Histogram equalization provides a sophisticated method for modifying the dynamic range and
100contrast of an image by altering the image such that its intensity histogram has a desired
101shape. Unlike contrast stretching, histogram modeling operators may employ non-linear and
102non-monotonic transfer functions to map between pixel intensity values in the input and output
103images. Histogram equalization re-assigns the intensity values of pixels in the input image
104such that the output image contains a uniform distribution of intensities (i.e. a flat histogram).
105
106- **Equalize histogram** - Enhances the image using histogram equalization. Choosing this option eliminates the "Saturated pixels pct" and "Normalize" options.
107- **Saturated pixels pct** - Determines the number of pixels in the image that are allowed to become saturated. Increasing this value increases contrast. This value should be greater than zero to prevent a few outlying pixels from causing the histogram stretch to not work as intended.
108- **Normalize** - Recalculates the pixel values of the image so the range is equal to the maximum range for the data type, or 0-1.0 for float images. The maximum range is 0-255 for 8-bit images and 0-65535 for 16-bit images. Normalization of RGB images is not supported, so selecting "yes" is ignored for this image type.
109
110]]>
111
112 </help>
113 <expand macro="fiji_headless_citations"/>
114</tool>