Mercurial > repos > imgteam > 2d_simple_filter
comparison filter.xml @ 2:b2d9c92bc431 draft
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_simple_filter/ commit a6fd77be465068f709a71d377900da99becf94d8
| author | imgteam |
|---|---|
| date | Fri, 12 Dec 2025 21:18:04 +0000 |
| parents | e2542d0ac64f |
| children | 53c55776a974 |
comparison
equal
deleted
inserted
replaced
| 1:e2542d0ac64f | 2:b2d9c92bc431 |
|---|---|
| 1 <tool id="ip_filter_standard" name="Filter Image" version="0.0.3"> | 1 <tool id="ip_filter_standard" name="Apply 2-D image filter" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.05"> |
| 2 <description>applies a standard filter to an image</description> | 2 <description>with scipy</description> |
| 3 <macros> | |
| 4 <import>creators.xml</import> | |
| 5 <import>tests.xml</import> | |
| 6 <token name="@TOOL_VERSION@">1.16.3</token> | |
| 7 <token name="@VERSION_SUFFIX@">0</token> | |
| 8 <xml name="select_axis"> | |
| 9 <param name="axis" type="select" label="Direction"> | |
| 10 <option value="1" selected="true">Horizontal</option> | |
| 11 <option value="0">Vertical</option> | |
| 12 </param> | |
| 13 </xml> | |
| 14 </macros> | |
| 15 <creator> | |
| 16 <expand macro="creators/bmcv"/> | |
| 17 <expand macro="creators/kostrykin"/> | |
| 18 </creator> | |
| 19 <edam_operations> | |
| 20 <edam_operation>operation_3443</edam_operation> | |
| 21 </edam_operations> | |
| 22 <xrefs> | |
| 23 <xref type="bio.tools">galaxy_image_analysis</xref> | |
| 24 <xref type="biii">scipy</xref> | |
| 25 </xrefs> | |
| 3 <requirements> | 26 <requirements> |
| 4 <requirement type="package" version="0.14.2">scikit-image</requirement> | 27 <requirement type="package" version="@TOOL_VERSION@">scipy</requirement> |
| 5 <requirement type="package" version="1.15.4">numpy</requirement> | 28 <requirement type="package" version="2.3.5">numpy</requirement> |
| 6 <requirement type="package" version="5.3.0">pillow</requirement> | 29 <requirement type="package" version="0.25.2">scikit-image</requirement> |
| 7 <requirement type="package" version="0.15.1">tifffile</requirement> | 30 <requirement type="package" version="2025.10.16">tifffile</requirement> |
| 31 <requirement type="package" version="0.5.2">giatools</requirement> | |
| 8 </requirements> | 32 </requirements> |
| 9 <command detect_errors="aggressive"> | 33 <command detect_errors="aggressive"><![CDATA[ |
| 10 <![CDATA[ | 34 |
| 11 python '$__tool_directory__/filter_image.py' '$input' '$output' $filter_type $radius | 35 python '$__tool_directory__/filter.py' |
| 12 ]]> | 36 |
| 13 </command> | 37 '$input' |
| 38 '$output' | |
| 39 '$params' | |
| 40 | |
| 41 ]]></command> | |
| 42 <configfiles> | |
| 43 <configfile name="params"><![CDATA[ | |
| 44 { | |
| 45 | |
| 46 ## ===================================================================== | |
| 47 #if $filter.filter_type == "gaussian" | |
| 48 "sigma": $filter.sigma, | |
| 49 "order": $filter.derivative.order, | |
| 50 | |
| 51 #if $filter.derivative.order != "0" | |
| 52 "axis": $filter.derivative.axis, | |
| 53 #end if | |
| 54 | |
| 55 ## ===================================================================== | |
| 56 #elif $filter.filter_type == "uniform" | |
| 57 "size": $filter.size, | |
| 58 | |
| 59 ## ===================================================================== | |
| 60 #elif $filter.filter_type == "median" | |
| 61 "radius": $filter.radius, | |
| 62 | |
| 63 ## ===================================================================== | |
| 64 #elif $filter.filter_type == "prewitt" or $filter.filter_type == "sobel" | |
| 65 "axis": $filter.axis, | |
| 66 | |
| 67 ## ===================================================================== | |
| 68 #end if | |
| 69 | |
| 70 "filter_type": "$filter.filter_type" | |
| 71 | |
| 72 } | |
| 73 ]]></configfile> | |
| 74 </configfiles> | |
| 14 <inputs> | 75 <inputs> |
| 15 <param name="filter_type" type="select" label="Image type"> | 76 <param name="input" type="data" format="tiff,png" label="Input image"/> |
| 16 <option value="median" selected="True">Median</option> | 77 <conditional name="filter"> |
| 17 <option value="gaussian">Gaussian Blur</option> | 78 <param name="filter_type" type="select" label="Filter type"> |
| 18 <option value="prewitt">Prewitt</option> | 79 <option value="gaussian" selected="True">Gaussian</option> |
| 19 <option value="sobel">Sobel</option> | 80 <option value="uniform">Box filter (uniform filter)</option> |
| 20 <option value="scharr">Scharr</option> | 81 <option value="median">Median</option> |
| 21 </param> | 82 <option value="prewitt">Prewitt</option> |
| 22 <param name="radius" type="integer" value="3" label="Radius/Sigma" /> | 83 <option value="sobel">Sobel</option> |
| 23 <param name="input" type="data" format="tiff" label="Source file" /> | 84 </param> |
| 85 <when value="gaussian"> | |
| 86 <param name="sigma" type="float" value="3" min="0.1" label="Sigma" | |
| 87 help="The half width of the Gaussian bell (in pixels)."/> | |
| 88 <conditional name="derivative"> | |
| 89 <param name="order" type="select" label="Use a derivative?"> | |
| 90 <option value="0">No derivative (mean filter)</option> | |
| 91 <option value="1">1st-order derivative</option> | |
| 92 <option value="2">2nd-order derivative</option> | |
| 93 </param> | |
| 94 <when value="0"> | |
| 95 </when> | |
| 96 <when value="1"> | |
| 97 <expand macro="select_axis"/> | |
| 98 </when> | |
| 99 <when value="2"> | |
| 100 <expand macro="select_axis"/> | |
| 101 </when> | |
| 102 </conditional> | |
| 103 </when> | |
| 104 <when value="uniform"> | |
| 105 <param name="size" type="integer" min="2" value="3" label="Size" | |
| 106 help="Edge length of the neighborhood (square, in pixels)."/> | |
| 107 </when> | |
| 108 <when value="median"> | |
| 109 <param name="radius" type="integer" min="2" value="3" label="Radius" | |
| 110 help="Radius of the neighborhood (circle, in pixels)." /> | |
| 111 </when> | |
| 112 <when value="prewitt"> | |
| 113 <expand macro="select_axis"/> | |
| 114 </when> | |
| 115 <when value="sobel"> | |
| 116 <expand macro="select_axis"/> | |
| 117 </when> | |
| 118 </conditional> | |
| 24 </inputs> | 119 </inputs> |
| 25 <outputs> | 120 <outputs> |
| 26 <data format="tiff" name="output" /> | 121 <data format="tiff" name="output" /> |
| 27 </outputs> | 122 </outputs> |
| 28 <tests> | 123 <tests> |
| 29 <test> | 124 <!-- Tests with uint8 TIFF input image --> |
| 30 <param name="input" value="sample.tif" /> | 125 <test> |
| 31 <output name="output" value="res.tif" ftype="tiff" compare="sim_size"/> | 126 <param name="input" value="input1_uint8.tiff"/> |
| 32 <param name="filter_type" value="prewitt" /> | 127 <conditional name="filter"> |
| 33 <param name="radius" value="4" /> | 128 <param name="filter_type" value="gaussian"/> |
| 34 </test> | 129 </conditional> |
| 130 <expand macro="tests/intensity_image_diff" name="output" value="input1_gaussian.tiff" ftype="tiff"> | |
| 131 <!-- | |
| 132 | |
| 133 The input file `input1_uint8.tiff` has values ranging between 23 and 254, with a mean value of 63.67. | |
| 134 | |
| 135 Below, we use an assertion in addition to the `image_diff` comparison, to ensure that the range of | |
| 136 values is preserved. The motiviation behind this is that the expectation images are usually checked | |
| 137 visually, which means that the `image_diff` comparison is likely to ensure that the brightness of | |
| 138 the image is correct, thus it's good to double-check the range of values (hence the comparably large | |
| 139 value for `eps`). This also concerns the median filter. | |
| 140 | |
| 141 --> | |
| 142 <has_image_mean_intensity mean_intensity="63.67" eps="10"/> | |
| 143 </expand> | |
| 144 </test> | |
| 145 <test> | |
| 146 <param name="input" value="input1_uint8.tiff"/> | |
| 147 <conditional name="filter"> | |
| 148 <param name="filter_type" value="median"/> | |
| 149 </conditional> | |
| 150 <expand macro="tests/intensity_image_diff" name="output" value="input1_median.tiff" ftype="tiff"> | |
| 151 <!-- See note for Gaussian filter above. --> | |
| 152 <has_image_mean_intensity mean_intensity="63.67" eps="10"/> | |
| 153 </expand> | |
| 154 </test> | |
| 155 <test> | |
| 156 <param name="input" value="input1_uint8.tiff"/> | |
| 157 <conditional name="filter"> | |
| 158 <param name="filter_type" value="prewitt"/> | |
| 159 <param name="axis" value="1"/> | |
| 160 </conditional> | |
| 161 <expand macro="tests/intensity_image_diff" name="output" value="input1_prewitt_h.tiff" ftype="tiff"/> | |
| 162 </test> | |
| 163 <test> | |
| 164 <param name="input" value="input1_uint8.tiff"/> | |
| 165 <conditional name="filter"> | |
| 166 <param name="filter_type" value="prewitt"/> | |
| 167 <param name="axis" value="0"/> | |
| 168 </conditional> | |
| 169 <expand macro="tests/intensity_image_diff" name="output" value="input1_prewitt_v.tiff" ftype="tiff"/> | |
| 170 </test> | |
| 171 <test> | |
| 172 <param name="input" value="input1_uint8.tiff"/> | |
| 173 <conditional name="filter"> | |
| 174 <param name="filter_type" value="sobel"/> | |
| 175 <param name="axis" value="1"/> | |
| 176 </conditional> | |
| 177 <expand macro="tests/intensity_image_diff" name="output" value="input1_sobel_h.tiff" ftype="tiff"/> | |
| 178 </test> | |
| 179 <test> | |
| 180 <param name="input" value="input1_uint8.tiff"/> | |
| 181 <conditional name="filter"> | |
| 182 <param name="filter_type" value="sobel"/> | |
| 183 <param name="axis" value="0"/> | |
| 184 </conditional> | |
| 185 <expand macro="tests/intensity_image_diff" name="output" value="input1_sobel_v.tiff" ftype="tiff"/> | |
| 186 </test> | |
| 187 <!-- Tests with float TIFF input image --> | |
| 188 <test> | |
| 189 <param name="input" value="input2_float.tiff"/> | |
| 190 <conditional name="filter"> | |
| 191 <param name="filter_type" value="gaussian"/> | |
| 192 </conditional> | |
| 193 <expand macro="tests/intensity_image_diff" name="output" value="input2_gaussian.tiff" ftype="tiff"> | |
| 194 <!-- See note for Gaussian filter above. --> | |
| 195 <has_image_mean_intensity mean_intensity="0.25" eps="0.01"/> | |
| 196 </expand> | |
| 197 </test> | |
| 198 <test> | |
| 199 <param name="input" value="input2_float.tiff"/> | |
| 200 <conditional name="filter"> | |
| 201 <param name="filter_type" value="uniform"/> | |
| 202 <param name="size" value="4"/> | |
| 203 </conditional> | |
| 204 <expand macro="tests/intensity_image_diff" name="output" value="input2_uniform.tiff" ftype="tiff"> | |
| 205 <!-- See note for Gaussian filter above. --> | |
| 206 <has_image_mean_intensity mean_intensity="0.25" eps="0.01"/> | |
| 207 </expand> | |
| 208 </test> | |
| 209 <!-- Tests with multi-channel image (RGB) --> | |
| 210 <test> | |
| 211 <param name="input" value="scikit-image/retina.png"/> | |
| 212 <conditional name="filter"> | |
| 213 <param name="filter_type" value="gaussian"/> | |
| 214 <param name="sigma" value="5"/> | |
| 215 <conditional name="derivative"> | |
| 216 <param name="order" value="0"/> | |
| 217 </conditional> | |
| 218 </conditional> | |
| 219 <expand macro="tests/intensity_image_diff" name="output" value="retina_gaussian_order0.tiff" ftype="tiff"/> | |
| 220 </test> | |
| 221 <test> | |
| 222 <param name="input" value="scikit-image/retina.png"/> | |
| 223 <conditional name="filter"> | |
| 224 <param name="filter_type" value="gaussian"/> | |
| 225 <param name="sigma" value="3"/> | |
| 226 <conditional name="derivative"> | |
| 227 <param name="order" value="2"/> | |
| 228 <param name="axis" value="0"/> | |
| 229 </conditional> | |
| 230 </conditional> | |
| 231 <expand macro="tests/intensity_image_diff" name="output" value="retina_gaussian_order2_axis0.tiff" ftype="tiff"/> | |
| 232 </test> | |
| 35 </tests> | 233 </tests> |
| 36 <help> | 234 <help> |
| 37 **What it does** | 235 |
| 38 | 236 **Applies a standard, general-purpose 2-D filter to an image.** |
| 39 Applies a standard filter to an image. | 237 |
| 238 Support for different image types: | |
| 239 | |
| 240 - For 3-D images, the filter is applied to all z-slices of the image. | |
| 241 - For multi-channel images, the filter is applied to all channels of the image. | |
| 242 - For time-series images, the filter is also applied for all time steps. | |
| 243 | |
| 244 Mean filters like the Gaussian filter, the box filter, or the median filter preserve both the brightness of the image, and | |
| 245 the range of values. This does not hold for the derivative variants of the Gaussian filter, which may produce negative values. | |
| 246 | |
| 40 </help> | 247 </help> |
| 41 <citations> | 248 <citations> |
| 42 <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation> | 249 <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation> |
| 43 </citations> | 250 </citations> |
| 44 </tool> | 251 </tool> |
