Mercurial > repos > imgteam > 2d_auto_threshold
comparison auto_threshold.xml @ 5:1ae14e703e5b draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_auto_threshold/ commit 71f7ecabba78de48147d4a5e6ea380b6b70b16e8
| author | imgteam |
|---|---|
| date | Sat, 03 Jan 2026 14:42:51 +0000 |
| parents | 7d80eb2411fb |
| children |
comparison
equal
deleted
inserted
replaced
| 4:7d80eb2411fb | 5:1ae14e703e5b |
|---|---|
| 1 <tool id="ip_threshold" name="Threshold image" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.05"> | 1 <tool id="ip_threshold" name="Threshold image" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.05"> |
| 2 <description>with scikit-image</description> | 2 <description>with scikit-image</description> |
| 3 <macros> | 3 <macros> |
| 4 <import>creators.xml</import> | 4 <import>creators.xml</import> |
| 5 <import>tests.xml</import> | 5 <import>tests.xml</import> |
| 6 <token name="@TOOL_VERSION@">0.25.0</token> | 6 <token name="@TOOL_VERSION@">0.25.2</token> |
| 7 <token name="@VERSION_SUFFIX@">0</token> | 7 <token name="@VERSION_SUFFIX@">0</token> |
| 8 <xml name="inputs/offset"> | 8 <xml name="inputs/offset"> |
| 9 <param name="offset" type="float" value="0" label="Offset" help="Offset to be added to the automatically determined threshold value. Positive values will increase the threshold (and thus reduce the amount of values above the threshold)." /> | 9 <param name="offset" type="float" value="0" label="Offset" |
| 10 help="Offset to be added to the automatically determined threshold value. Positive values will increase the threshold (and thus reduce the amount of values above the threshold)."/> | |
| 10 </xml> | 11 </xml> |
| 11 </macros> | 12 </macros> |
| 12 <creator> | 13 <creator> |
| 13 <expand macro="creators/bmcv"/> | 14 <expand macro="creators/bmcv"/> |
| 15 <expand macro="creators/kostrykin"/> | |
| 14 </creator> | 16 </creator> |
| 15 <edam_operations> | 17 <edam_operations> |
| 16 <edam_operation>operation_3443</edam_operation> | 18 <edam_operation>operation_3443</edam_operation> |
| 17 </edam_operations> | 19 </edam_operations> |
| 18 <xrefs> | 20 <xrefs> |
| 21 <xref type="bio.tools">galaxy_image_analysis</xref> | |
| 22 <xref type="bio.tools">giatools</xref> | |
| 19 <xref type="bio.tools">scikit-image</xref> | 23 <xref type="bio.tools">scikit-image</xref> |
| 20 <xref type="biii">scikit-image</xref> | 24 <xref type="biii">scikit-image</xref> |
| 21 </xrefs> | 25 </xrefs> |
| 22 <requirements> | 26 <requirements> |
| 23 <requirement type="package" version="@TOOL_VERSION@">scikit-image</requirement> | 27 <requirement type="package" version="@TOOL_VERSION@">scikit-image</requirement> |
| 24 <requirement type="package" version="0.4.1">giatools</requirement> | 28 <requirement type="package" version="0.7.3">giatools</requirement> |
| 29 <requirement type="package" version="0.12.2">ome-zarr</requirement> | |
| 25 </requirements> | 30 </requirements> |
| 26 <command detect_errors="aggressive"> | 31 <required_files> |
| 27 <![CDATA[ | 32 <include type="literal" path="auto_threshold.py"/> |
| 33 </required_files> | |
| 34 <command detect_errors="aggressive"><![CDATA[ | |
| 28 | 35 |
| 29 python '$__tool_directory__/auto_threshold.py' | 36 python '$__tool_directory__/auto_threshold.py' |
| 30 | 37 |
| 31 '$input' | 38 #if $input.extension == "zarr" |
| 32 ./out.tiff | 39 --input '$input.extra_files_path/$input.metadata.store_root' |
| 33 | 40 #else |
| 34 '$th_method.method_id' | 41 --input '$input' |
| 35 '$th_method.block_size' | |
| 36 '$th_method.offset' | |
| 37 '$th_method.threshold1' | |
| 38 $invert_output | |
| 39 | |
| 40 #if str($th_method.threshold2) != '': | |
| 41 --threshold2 '$th_method.threshold2' | |
| 42 #end if | 42 #end if |
| 43 | 43 |
| 44 ]]> | 44 --output ./out.tiff |
| 45 </command> | 45 --params '$params' |
| 46 --verbose | |
| 47 | |
| 48 ]]></command> | |
| 49 <configfiles> | |
| 50 <configfile name="params"><![CDATA[ | |
| 51 { | |
| 52 | |
| 53 #if str($th_method.method_id).startswith('loc_') | |
| 54 "block_size": $th_method.block_size, | |
| 55 #end if | |
| 56 | |
| 57 #if $th_method.method_id != "manual" | |
| 58 "offset": $th_method.offset, | |
| 59 | |
| 60 #else | |
| 61 "threshold1": $th_method.threshold1, | |
| 62 #if str($th_method.threshold2) != "" | |
| 63 "threshold2": $th_method.threshold2, | |
| 64 #else | |
| 65 "threshold2": null, | |
| 66 #end if | |
| 67 | |
| 68 #end if | |
| 69 | |
| 70 "method": "$th_method.method_id", | |
| 71 "invert": $invert_output | |
| 72 | |
| 73 } | |
| 74 ]]></configfile> | |
| 75 </configfiles> | |
| 46 <inputs> | 76 <inputs> |
| 47 <param name="input" type="data" format="tiff,png" label="Input image" /> | 77 <param name="input" type="data" format="tiff,zarr,png,jpg" label="Input image"/> |
| 48 <conditional name="th_method"> | 78 <conditional name="th_method"> |
| 49 <param name="method_id" type="select" label="Thresholding method"> | 79 <param name="method_id" type="select" label="Thresholding method"> |
| 50 <option value="manual">Manual</option> | 80 <option value="manual">Manual</option> |
| 51 <option value="otsu" selected="True">Globally adaptive / Otsu</option> | 81 <option value="otsu" selected="True">Globally adaptive / Otsu</option> |
| 52 <option value="li">Globally adaptive / Li's Minimum Cross Entropy</option> | 82 <option value="li">Globally adaptive / Li's Minimum Cross Entropy</option> |
| 55 <option value="loc_gaussian">Locally adaptive / Gaussian</option> | 85 <option value="loc_gaussian">Locally adaptive / Gaussian</option> |
| 56 <option value="loc_median">Locally adaptive / Median</option> | 86 <option value="loc_median">Locally adaptive / Median</option> |
| 57 <option value="loc_mean">Locally adaptive / Mean</option> | 87 <option value="loc_mean">Locally adaptive / Mean</option> |
| 58 </param> | 88 </param> |
| 59 <when value="manual"> | 89 <when value="manual"> |
| 60 <param name="threshold1" type="float" value="0" label="Threshold value" /> | 90 <param name="threshold1" type="float" value="0" label="Threshold value"/> |
| 61 <param name="threshold2" type="float" value="" optional="true" label="Second threshold value for hysteresis thresholding" /> | 91 <param name="threshold2" type="float" value="" optional="true" label="Second threshold value for hysteresis thresholding"/> |
| 62 <param name="block_size" type="hidden" value="0" /> | 92 <param name="offset" type="hidden" value="0"/> |
| 63 <param name="offset" type="hidden" value="0" /> | |
| 64 </when> | 93 </when> |
| 65 <when value="otsu"> | 94 <when value="otsu"> |
| 66 <param name="threshold1" type="hidden" value="0" /> | 95 <expand macro="inputs/offset"/> |
| 67 <param name="threshold2" type="hidden" value="" /> | |
| 68 <param name="block_size" type="hidden" value="0" /> | |
| 69 <expand macro="inputs/offset" /> | |
| 70 </when> | 96 </when> |
| 71 <when value="li"> | 97 <when value="li"> |
| 72 <param name="threshold1" type="hidden" value="0" /> | 98 <expand macro="inputs/offset"/> |
| 73 <param name="threshold2" type="hidden" value="" /> | |
| 74 <param name="block_size" type="hidden" value="0" /> | |
| 75 <expand macro="inputs/offset" /> | |
| 76 </when> | 99 </when> |
| 77 <when value="isodata"> | 100 <when value="isodata"> |
| 78 <param name="threshold1" type="hidden" value="0" /> | 101 <expand macro="inputs/offset"/> |
| 79 <param name="threshold2" type="hidden" value="" /> | |
| 80 <param name="block_size" type="hidden" value="0" /> | |
| 81 <expand macro="inputs/offset" /> | |
| 82 </when> | 102 </when> |
| 83 <when value="yen"> | 103 <when value="yen"> |
| 84 <param name="threshold1" type="hidden" value="0" /> | 104 <expand macro="inputs/offset"/> |
| 85 <param name="threshold2" type="hidden" value="" /> | |
| 86 <param name="block_size" type="hidden" value="0" /> | |
| 87 <expand macro="inputs/offset" /> | |
| 88 </when> | 105 </when> |
| 89 <when value="loc_gaussian"> | 106 <when value="loc_gaussian"> |
| 90 <param name="threshold1" type="hidden" value="0" /> | 107 <param name="block_size" type="integer" value="5" label="Odd size of pixel neighborhood for determining the threshold"/> |
| 91 <param name="threshold2" type="hidden" value="" /> | 108 <expand macro="inputs/offset"/> |
| 92 <param name="block_size" type="integer" value="5" label="Odd size of pixel neighborhood for determining the threshold" /> | |
| 93 <expand macro="inputs/offset" /> | |
| 94 </when> | 109 </when> |
| 95 <when value="loc_median"> | 110 <when value="loc_median"> |
| 96 <param name="threshold1" type="hidden" value="0" /> | 111 <param name="block_size" type="integer" value="5" label="Odd size of pixel neighborhood for determining the threshold"/> |
| 97 <param name="threshold2" type="hidden" value="" /> | 112 <expand macro="inputs/offset"/> |
| 98 <param name="block_size" type="integer" value="5" label="Odd size of pixel neighborhood for determining the threshold" /> | |
| 99 <expand macro="inputs/offset" /> | |
| 100 </when> | 113 </when> |
| 101 <when value="loc_mean"> | 114 <when value="loc_mean"> |
| 102 <param name="threshold1" type="hidden" value="0" /> | 115 <param name="block_size" type="integer" value="5" label="Odd size of pixel neighborhood for determining the threshold"/> |
| 103 <param name="threshold2" type="hidden" value="" /> | 116 <expand macro="inputs/offset"/> |
| 104 <param name="block_size" type="integer" value="5" label="Odd size of pixel neighborhood for determining the threshold" /> | |
| 105 <expand macro="inputs/offset" /> | |
| 106 </when> | 117 </when> |
| 107 </conditional> | 118 </conditional> |
| 108 <param name="invert_output" type="boolean" checked="false" truevalue="--invert_output" falsevalue="" label="Invert output labels" help="Pixels are usually assigned the label 0 if the pixel value is below (or equal to) the threshold, and 255 if it is above the threshold. If this option is activated, pixels are assigned the label 255 if the pixel value is below (or equal to) the threshold, and 0 if it is above the threshold." /> | 119 <param name="invert_output" type="boolean" checked="false" label="Invert output labels" |
| 120 help="Pixels are usually assigned the label 0 if the pixel value is below (or equal to) the threshold, and 255 if it is above the threshold. If this option is activated, pixels are assigned the label 255 if the pixel value is below (or equal to) the threshold, and 0 if it is above the threshold."/> | |
| 109 </inputs> | 121 </inputs> |
| 110 <outputs> | 122 <outputs> |
| 111 <data format="tiff" name="output" from_work_dir="out.tiff" /> | 123 <data format="tiff" name="output" from_work_dir="out.tiff" /> |
| 112 </outputs> | 124 </outputs> |
| 113 <tests> | 125 <tests> |
| 114 <!-- Tests for single-channel images (TIFF) --> | 126 <!-- Tests for single-channel images (TIFF) --> |
| 115 <test> | 127 <test> |
| 116 <param name="input" value="sample.tiff"/> | 128 <param name="input" value="input/sample.tiff"/> |
| 117 <conditional name="th_method"> | 129 <conditional name="th_method"> |
| 118 <param name="method_id" value="loc_gaussian"/> | 130 <param name="method_id" value="loc_gaussian"/> |
| 119 <param name="block_size" value="51"/> | 131 <param name="block_size" value="51"/> |
| 120 </conditional> | 132 </conditional> |
| 121 <expand macro="tests/binary_image_diff" name="output" value="out1.tiff" ftype="tiff"/> | 133 <expand macro="tests/binary_image_diff" name="output" value="output/out1.tiff" ftype="tiff"/> |
| 122 </test> | 134 </test> |
| 123 <test> | 135 <test> |
| 124 <param name="input" value="sample.tiff"/> | 136 <param name="input" value="input/sample.tiff"/> |
| 125 <conditional name="th_method"> | 137 <conditional name="th_method"> |
| 126 <param name="method_id" value="loc_gaussian"/> | 138 <param name="method_id" value="loc_gaussian"/> |
| 127 <param name="block_size" value="51"/> | 139 <param name="block_size" value="51"/> |
| 128 <param name="offset" value="1"/> | 140 <param name="offset" value="1"/> |
| 129 </conditional> | 141 </conditional> |
| 130 <expand macro="tests/binary_image_diff" name="output" value="out2.tiff" ftype="tiff"/> | 142 <expand macro="tests/binary_image_diff" name="output" value="output/out2.tiff" ftype="tiff"/> |
| 131 </test> | 143 </test> |
| 132 <test> | 144 <test> |
| 133 <param name="input" value="sample.tiff"/> | 145 <param name="input" value="input/sample.tiff"/> |
| 134 <conditional name="th_method"> | 146 <conditional name="th_method"> |
| 135 <param name="method_id" value="otsu"/> | 147 <param name="method_id" value="otsu"/> |
| 136 </conditional> | 148 </conditional> |
| 137 <expand macro="tests/binary_image_diff" name="output" value="out3.tiff" ftype="tiff"/> | 149 <expand macro="tests/binary_image_diff" name="output" value="output/out3.tiff" ftype="tiff"/> |
| 138 </test> | 150 </test> |
| 139 <test> | 151 <test> |
| 140 <param name="input" value="sample.tiff"/> | 152 <param name="input" value="input/sample.tiff"/> |
| 141 <param name="invert_output" value="True"/> | 153 <param name="invert_output" value="True"/> |
| 142 <conditional name="th_method"> | 154 <conditional name="th_method"> |
| 143 <param name="method_id" value="manual"/> | 155 <param name="method_id" value="manual"/> |
| 144 <param name="threshold1" value="64"/> | 156 <param name="threshold1" value="64"/> |
| 145 </conditional> | 157 </conditional> |
| 146 <expand macro="tests/binary_image_diff" name="output" value="out4.tiff" ftype="tiff"/> | 158 <expand macro="tests/binary_image_diff" name="output" value="output/out4.tiff" ftype="tiff"/> |
| 147 </test> | 159 </test> |
| 148 <test> | 160 <test> |
| 149 <param name="input" value="sample.tiff"/> | 161 <param name="input" value="input/sample.tiff"/> |
| 150 <conditional name="th_method"> | 162 <conditional name="th_method"> |
| 151 <param name="method_id" value="manual"/> | 163 <param name="method_id" value="manual"/> |
| 152 <param name="threshold1" value="180"/> | 164 <param name="threshold1" value="180"/> |
| 153 <param name="threshold2" value="240"/> | 165 <param name="threshold2" value="240"/> |
| 154 </conditional> | 166 </conditional> |
| 155 <expand macro="tests/binary_image_diff" name="output" value="sample_manual_180_240.tiff" ftype="tiff"/> | 167 <expand macro="tests/binary_image_diff" name="output" value="output/sample_manual_180_240.tiff" ftype="tiff"/> |
| 156 </test> | 168 </test> |
| 157 <!-- Tests for multi-channel images (PNG) --> | 169 <!-- Tests for multi-channel images (PNG) --> |
| 158 <test> | 170 <test> |
| 159 <param name="input" value="rgb.png"/> | 171 <param name="input" value="input/rgb.png"/> |
| 160 <conditional name="th_method"> | 172 <conditional name="th_method"> |
| 161 <param name="method_id" value="otsu"/> | 173 <param name="method_id" value="otsu"/> |
| 162 </conditional> | 174 </conditional> |
| 163 <expand macro="tests/binary_image_diff" name="output" value="rgb_otsu.tiff" ftype="tiff"/> | 175 <expand macro="tests/binary_image_diff" name="output" value="output/rgb_otsu.tiff" ftype="tiff"/> |
| 164 </test> | 176 </test> |
| 165 <!-- Tests for irregular files --> | 177 <!-- Tests for irregular files (TODO: clear up what this means) --> |
| 166 <test> | 178 <test> |
| 167 <param name="input" value="sample2.tiff"/> | 179 <param name="input" value="input/sample2.tiff"/> |
| 168 <conditional name="th_method"> | 180 <conditional name="th_method"> |
| 169 <param name="method_id" value="otsu"/> | 181 <param name="method_id" value="otsu"/> |
| 170 </conditional> | 182 </conditional> |
| 171 <expand macro="tests/binary_image_diff" name="output" value="out5.tiff" ftype="tiff"/> | 183 <expand macro="tests/binary_image_diff" name="output" value="output/out5.tiff" ftype="tiff"/> |
| 184 </test> | |
| 185 <!-- Tests for exotic files --> | |
| 186 <test> | |
| 187 <param name="input" value="input/input5.jpg"/> | |
| 188 <conditional name="th_method"> | |
| 189 <param name="method_id" value="li"/> | |
| 190 </conditional> | |
| 191 <expand macro="tests/binary_image_diff" name="output" value="output/input5_li.tiff" ftype="tiff"/> | |
| 192 </test> | |
| 193 <test> | |
| 194 <param name="input" value="input/input8_zyx.zarr"/> | |
| 195 <conditional name="th_method"> | |
| 196 <param name="method_id" value="yen"/> | |
| 197 </conditional> | |
| 198 <expand macro="tests/binary_image_diff" name="output" value="output/input8_yen.tiff" ftype="tiff"/> | |
| 172 </test> | 199 </test> |
| 173 </tests> | 200 </tests> |
| 174 <help> | 201 <help> |
| 175 | 202 |
| 176 **Applies a standard thresholding algorithm to a 2-D single-channel image. Yields a binary image.** | 203 **Applies a standard thresholding algorithm to an image. Yields a binary image.** |
| 177 | 204 |
| 178 The thresholding algorithm automatically determines a threshold value (unless manual thresholding is used). | 205 The thresholding algorithm automatically determines a threshold value (unless manual thresholding is used). The input image is |
| 179 The input image is then thresholded, by assigning white (pixel value 255) to image regions above the determined threshold, | 206 then thresholded, by assigning white (pixel value 255) to image regions above the determined threshold, and black (pixel value 0) |
| 180 and black (pixel value 0) to image regions below or equal to the determined threshold. | 207 to image regions below or equal to the determined threshold. For multi-channel images, each channel is processed separately, |
| 181 | 208 which, for example, may also yield colors beyond black and white in case of RGB images. |
| 182 The assignment of black and white to image regions below and above the threshold is inverted, if the corresponding option is set. | 209 |
| 210 The assignment of the pixel values 0 and 255 (i.e. black and white) to image regions below and above the threshold is inverted, | |
| 211 if the corresponding option is set. | |
| 183 | 212 |
| 184 </help> | 213 </help> |
| 185 <citations> | 214 <citations> |
| 186 <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation> | 215 <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation> |
| 187 </citations> | 216 </citations> |
