changeset 1:7f2962f619e3 draft

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_auto_threshold/ commit 8a2a5763d1ac38b3c7974bd7c2da4d5c1101a0a9
author imgteam
date Tue, 23 Jul 2019 05:08:42 -0400
parents 6fc65082d1e6
children f40e5d11eb47
files auto_threshold.py auto_threshold.xml
diffstat 2 files changed, 12 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/auto_threshold.py	Sat Feb 09 14:02:57 2019 -0500
+++ b/auto_threshold.py	Tue Jul 23 05:08:42 2019 -0400
@@ -1,19 +1,17 @@
 import argparse
 import numpy as np
-import os
-import sys
-import warnings
+import sys 
 import skimage.io
 import skimage.filters
 import skimage.util
 
 threshOptions = {
-    'otsu' : lambda img_raw: skimage.filters.threshold_otsu(img_raw),
-    'gaussian_adaptive' : lambda img_raw: skimage.filters.threshold_local(img_raw.reshape(img_raw.shape[0], img_raw.shape[1]), 3, method='gaussian'), # todo reshape 2d
-    'mean_adaptive' : lambda img_raw: skimage.filters.threshold_local(img_raw.reshape(img_raw.shape[0], img_raw.shape[1]), 3, method='mean'), # todo reshape 2d
-    'isodata' : lambda img_raw: skimage.filters.threshold_isodata(img_raw),
-    'li' : lambda img_raw: skimage.filters.threshold_li(img_raw),
-    'yen' : lambda img_raw: skimage.filters.threshold_yen(img_raw),
+    'otsu': lambda img_raw: skimage.filters.threshold_otsu(img_raw),
+    'gaussian_adaptive': lambda img_raw: skimage.filters.threshold_local(img_raw, 3, method='gaussian'),
+    'mean_adaptive': lambda img_raw: skimage.filters.threshold_local(img_raw, 3, method='mean'),
+    'isodata': lambda img_raw: skimage.filters.threshold_isodata(img_raw),
+    'li': lambda img_raw: skimage.filters.threshold_li(img_raw),
+    'yen': lambda img_raw: skimage.filters.threshold_yen(img_raw),
 }
 
 if __name__ == "__main__":
@@ -25,6 +23,7 @@
     args = parser.parse_args()
 
     img_in = skimage.io.imread(args.input_file.name)
+    img_in = np.reshape(img_in, [img_in.shape[0], img_in.shape[1]])
     thresh = threshOptions[args.thresh_type](img_in)
 
     if args.dark_background:
@@ -32,7 +31,5 @@
     else:
         res = img_in <= thresh
 
-    with warnings.catch_warnings():
-    	warnings.simplefilter("ignore")
-    	res = skimage.util.img_as_uint(res)
-    	skimage.io.imsave(args.out_file.name, res, plugin="tifffile")
+    res = skimage.util.img_as_uint(res)
+    skimage.io.imsave(args.out_file.name, res, plugin="tifffile")
--- a/auto_threshold.xml	Sat Feb 09 14:02:57 2019 -0500
+++ b/auto_threshold.xml	Tue Jul 23 05:08:42 2019 -0400
@@ -1,6 +1,6 @@
-<tool id="ip_threshold" name="Auto Threshold" version="0.0.3">
+<tool id="ip_threshold" name="Auto Threshold" version="0.0.4">
    <description>applies a standard threshold algorithm to an image</description>
-   <requirements>
+   <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>