changeset 0:70316d792fc9 draft

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_histogram_equalization/ commit 767d7fec860d01468701c4e6dc270a7f1c74d53c
author imgteam
date Tue, 23 Jul 2019 14:07:07 -0400
parents
children 77f7159d775a
files histogram_equalization.py histogram_equalization.xml test-data/out.tif test-data/sample.tif
diffstat 4 files changed, 60 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/histogram_equalization.py	Tue Jul 23 14:07:07 2019 -0400
@@ -0,0 +1,23 @@
+import argparse
+import os
+import sys
+import skimage.io
+import skimage.exposure
+import skimage.util
+
+hOptions = {
+    'default' : lambda img_raw: skimage.exposure.equalize_hist(img_raw),
+    'clahe' : lambda img_raw: skimage.exposure.equalize_adapthist(img_raw)
+}
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser(description='Histogram equalization')
+    parser.add_argument('input_file', type=argparse.FileType('r'), default=sys.stdin, help='input file')
+    parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)')
+    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)
+    res = hOptions[args.h_type](img_in)
+    res = skimage.util.img_as_uint(res)
+    skimage.io.imsave(args.out_file.name, res, plugin="tifffile")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/histogram_equalization.xml	Tue Jul 23 14:07:07 2019 -0400
@@ -0,0 +1,37 @@
+<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">
+          <option value="default">Stretching</option>
+          <option value="clahe" selected="True">CLAHE</option>
+        </param>
+    </inputs>
+    <outputs>
+       <data format="tiff" name="output" />
+    </outputs>
+    <tests>
+        <test>
+            <param name="input" value="sample.tif"/>
+            <output name="output" value="out.tif" ftype="tiff" compare="sim_size"/>
+            <param name="h_type" value="default"/>
+        </test>
+    </tests>
+    <help>
+        Applies histogram equalization to an image.
+    </help>
+    <citations>
+        <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation>
+    </citations>
+</tool>
Binary file test-data/out.tif has changed
Binary file test-data/sample.tif has changed