changeset 0:d13e26f576bc draft

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/anisotropic-diffusion/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581
author imgteam
date Sat, 09 Feb 2019 14:30:00 -0500
parents
children 17d3cfba9b5a
files anisotropic_diffusion.py anisotropic_diffusion.xml test-data/galaxyIcon_noText.tif test-data/res.tif
diffstat 4 files changed, 72 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/anisotropic_diffusion.py	Sat Feb 09 14:30:00 2019 -0500
@@ -0,0 +1,28 @@
+import argparse
+import sys
+import warnings
+import numpy as np
+import skimage.io
+import skimage.util
+from medpy.filter.smoothing import anisotropic_diffusion
+
+parser = argparse.ArgumentParser()
+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('niter', type=int, help='Number of iterations', default=1)
+parser.add_argument('kappa', type=int, help='Conduction coefficient', default=50)
+parser.add_argument('gamma', type=float, help='Speed of diffusion', default=0.1)
+parser.add_argument('eqoption', type=int, choices=[1,2], help='Perona Malik diffusion equation', default=1)
+args = parser.parse_args()
+
+with warnings.catch_warnings():
+	warnings.simplefilter("ignore") #to ignore FutureWarning as well 
+
+	img_in = skimage.io.imread(args.input_file.name, plugin='tifffile')
+	res = anisotropic_diffusion(img_in, niter=args.niter, kappa=args.kappa, gamma=args.gamma, option=args.eqoption)
+	res[res<-1]=-1
+	res[res>1]=1
+
+	res = skimage.util.img_as_uint(res) #Attention: precision loss
+
+	skimage.io.imsave(args.out_file.name, res, plugin='tifffile')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/anisotropic_diffusion.xml	Sat Feb 09 14:30:00 2019 -0500
@@ -0,0 +1,44 @@
+<tool id="ip_anisotropic_diffusion" name="Anisotropic Diffusion" version="0.1">
+    <description>Edge-preserving, Anisotropic diffusion</description>
+    <requirements>
+        <requirement type="package" version="0.14.2">scikit-image</requirement>
+        <requirement type="package" version="0.3.0">medpy</requirement>
+        <requirement type="package" version="1.15.4">numpy</requirement>
+    </requirements>
+    <command>
+        <![CDATA[
+        python '$__tool_directory__/anisotropic_diffusion.py' '$input' '$output' '$niter' '$kappa' '$gamma' '$eqoption'
+        ]]>
+    </command>
+    <inputs>
+        <param name="input" type="data" format="tiff" label="Image file"/>
+        <param label="Number of iterations" name="niter" optional="true" type="integer" value="50"/>
+        <param label="Conduction coefficient" name="kappa" optional="true" type="integer" value="50"/>
+        <param label="Speed of diffusion" name="gamma" optional="true" type="float" value="0.1"/>
+        <param name="eqoption" type="select" label="Diffusion Feature" help="Perona Malik diffusion equation">
+            <option value="1" selected="True">Favour high contrast edges</option>
+            <option value="2">Favour wide regions</option>
+        </param>
+    </inputs>
+    <outputs>
+        <data format="tiff" name="output"/>
+    </outputs>
+    <tests>
+        <test>
+            <param name="input" value="galaxyIcon_noText.tif" />
+            <param name="niter" value="100" />
+            <param name="kappa" value="50" />
+            <param name="gamma" value="0.1" />
+            <param name="eqoption" value="1" />
+            <output name="output" file="res.tif" ftype="tiff" compare="sim_size"/>
+        </test>
+    </tests>
+    <help>
+    **What it does**
+
+    Edge-preserving, Anisotropic image diffusion
+    </help>
+    <citations>
+        <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation>
+    </citations>
+</tool>
Binary file test-data/galaxyIcon_noText.tif has changed
Binary file test-data/res.tif has changed