Mercurial > repos > imgteam > 2d_histogram_equalization
changeset 1:77455af98d88 draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_histogram_equalization/ commit 558152251d5d7a1bf77db91aa5388aca7a68ae62
| author | imgteam |
|---|---|
| date | Fri, 20 Feb 2026 09:56:36 +0000 |
| parents | d54f14727f77 |
| children | |
| files | creators.xml histogram_equalization.py histogram_equalization.xml test-data/out.tif test-data/out.tiff test-data/out_clahe.tiff test-data/sample.tif test-data/sample.tiff tests.xml |
| diffstat | 9 files changed, 194 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/creators.xml Fri Feb 20 09:56:36 2026 +0000 @@ -0,0 +1,43 @@ +<macros> + + <xml name="creators/bmcv"> + <organization name="Biomedical Computer Vision Group, Heidelberg Universtiy" alternateName="BMCV" url="http://www.bioquant.uni-heidelberg.de/research/groups/biomedical_computer_vision.html" /> + <yield /> + </xml> + + <xml name="creators/kostrykin"> + <person givenName="Leonid" familyName="Kostrykin"/> + <yield/> + </xml> + + <xml name="creators/rmassei"> + <person givenName="Riccardo" familyName="Massei"/> + <yield/> + </xml> + + <xml name="creators/alliecreason"> + <person givenName="Allison" familyName="Creason"/> + <yield/> + </xml> + + <xml name="creators/bugraoezdemir"> + <person givenName="Bugra" familyName="Oezdemir"/> + <yield/> + </xml> + + <xml name="creators/thawn"> + <person givenName="Till" familyName="Korten"/> + <yield/> + </xml> + + <xml name="creators/pavanvidem"> + <person givenName="Pavan" familyName="Videm"/> + <yield/> + </xml> + + <xml name="creators/tuncK"> + <person givenName="Tunc" familyName="Kayikcioglu"/> + <yield/> + </xml> + +</macros>
--- a/histogram_equalization.py Tue Jul 23 14:06:42 2019 -0400 +++ b/histogram_equalization.py Fri Feb 20 09:56:36 2026 +0000 @@ -1,13 +1,22 @@ import argparse -import os import sys + +import giatools.io +import numpy as np +import skimage.exposure import skimage.io -import skimage.exposure import skimage.util + +def rescale(img): + assert np.issubdtype(img.dtype, np.floating), str(img.dtype) # sanity check + img = img - img.min() + return img / img.max() if img.max() != 0 else 1 + + hOptions = { - 'default' : lambda img_raw: skimage.exposure.equalize_hist(img_raw), - 'clahe' : lambda img_raw: skimage.exposure.equalize_adapthist(img_raw) + 'default': lambda img_raw: rescale(skimage.exposure.equalize_hist(img_raw)), # rescale needed for values to be in [0, 1] + 'clahe': lambda img_raw: skimage.exposure.equalize_adapthist(img_raw), # produces image with values in [0, 1] } if __name__ == "__main__": @@ -17,7 +26,7 @@ parser.add_argument('h_type', choices=hOptions.keys(), help='histogram equalization method') args = parser.parse_args() - img_in = skimage.io.imread(args.input_file.name) + img_in = giatools.io.imread(args.input_file.name) res = hOptions[args.h_type](img_in) res = skimage.util.img_as_uint(res) skimage.io.imsave(args.out_file.name, res, plugin="tifffile")
--- a/histogram_equalization.xml Tue Jul 23 14:06:42 2019 -0400 +++ b/histogram_equalization.xml Fri Feb 20 09:56:36 2026 +0000 @@ -1,19 +1,35 @@ -<tool id="ip_histogram_equalization" name="Histogram equalization" version="0.0.1"> - <description>automatic histogram equalization</description> - <requirements> - <requirement type="package" version="0.14.2">scikit-image</requirement> - <requirement type="package" version="1.15.4">numpy</requirement> - <requirement type="package" version="5.3.0">pillow</requirement> - <requirement type="package" version="0.15.1">tifffile</requirement> - </requirements> - <command detect_errors="aggressive"> - <![CDATA[ - python '$__tool_directory__/histogram_equalization.py' '$input' '$output' $h_type - ]]> - </command> - <inputs> - <param name="input" type="data" format="tiff" label="Source file" /> - <param name="h_type" type="select" label="Histogram Equalization Algorithm"> +<tool id="ip_histogram_equalization" name="Perform histogram equalization" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.05"> + <description>with scikit-image</description> + <macros> + <import>creators.xml</import> + <import>tests.xml</import> + <token name="@TOOL_VERSION@">0.25.2</token> + <token name="@VERSION_SUFFIX@">0</token> + </macros> + <creator> + <expand macro="creators/bmcv" /> + </creator> + <edam_operations> + <edam_operation>operation_3443</edam_operation> + </edam_operations> + <xrefs> + <xref type="bio.tools">scikit-image</xref> + <xref type="biii">scikit-image</xref> + </xrefs> + <requirements> + <requirement type="package" version="@TOOL_VERSION@">scikit-image</requirement> + <requirement type="package" version="2.3.5">numpy</requirement> + <requirement type="package" version="2025.5.10">tifffile</requirement> + <requirement type="package" version="0.1.2">giatools</requirement> + </requirements> + <command detect_errors="aggressive"> + <![CDATA[ + python '$__tool_directory__/histogram_equalization.py' '$input' '$output' $h_type + ]]> + </command> + <inputs> + <param name="input" type="data" format="tiff" label="Input image" /> + <param name="h_type" type="select" label="Histogram equalization algorithm"> <option value="default">Stretching</option> <option value="clahe" selected="True">CLAHE</option> </param> @@ -23,13 +39,20 @@ </outputs> <tests> <test> - <param name="input" value="sample.tif"/> - <output name="output" value="out.tif" ftype="tiff" compare="sim_size"/> + <param name="input" value="sample.tiff"/> <param name="h_type" value="default"/> + <expand macro="tests/intensity_image_diff" name="output" value="out.tiff" ftype="tiff"/> + </test> + <test> + <param name="input" value="sample.tiff"/> + <param name="h_type" value="clahe"/> + <expand macro="tests/intensity_image_diff" name="output" value="out_clahe.tiff" ftype="tiff"/> </test> </tests> <help> - Applies histogram equalization to an image. + + **Applies histogram equalization to an image.** + </help> <citations> <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests.xml Fri Feb 20 09:56:36 2026 +0000 @@ -0,0 +1,95 @@ +<macros> + + <!-- Macros for verification of image outputs --> + + <xml + name="tests/binary_image_diff" + tokens="name,value,ftype,metric,eps" + token_metric="mae" + token_eps="0.01"> + + <output name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@" pin_labels="0"> + <assert_contents> + <has_image_n_labels n="2"/> + <yield/> + </assert_contents> + </output> + + </xml> + + <xml + name="tests/label_image_diff" + tokens="name,value,ftype,metric,eps,pin_labels" + token_metric="iou" + token_eps="0.01" + token_pin_labels="0"> + + <output name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@" pin_labels="@PIN_LABELS@"> + <assert_contents> + <yield/> + </assert_contents> + </output> + + </xml> + + <xml + name="tests/intensity_image_diff" + tokens="name,value,ftype,metric,eps" + token_metric="rms" + token_eps="0.01"> + + <output name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@"> + <assert_contents> + <yield/> + </assert_contents> + </output> + + </xml> + + <!-- Variants of the above for verification of collection elements --> + + <xml + name="tests/binary_image_diff/element" + tokens="name,value,ftype,metric,eps" + token_metric="mae" + token_eps="0.01"> + + <element name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@" pin_labels="0"> + <assert_contents> + <has_image_n_labels n="2"/> + <yield/> + </assert_contents> + </element> + + </xml> + + <xml + name="tests/label_image_diff/element" + tokens="name,value,ftype,metric,eps" + token_metric="iou" + token_eps="0.01" + token_pin_labels="0"> + + <element name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@" pin_labels="@PIN_LABELS@"> + <assert_contents> + <yield/> + </assert_contents> + </element> + + </xml> + + <xml + name="tests/intensity_image_diff/element" + tokens="name,value,ftype,metric,eps" + token_metric="rms" + token_eps="0.01"> + + <element name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@"> + <assert_contents> + <yield/> + </assert_contents> + </element> + + </xml> + +</macros>
