# HG changeset patch # User imgteam # Date 1563872922 14400 # Node ID 7f2962f619e3f886c731d9dfb022c365b378d7b2 # Parent 6fc65082d1e66c2291170132e8f34b2b4c1d5392 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/2d_auto_threshold/ commit 8a2a5763d1ac38b3c7974bd7c2da4d5c1101a0a9 diff -r 6fc65082d1e6 -r 7f2962f619e3 auto_threshold.py --- 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") diff -r 6fc65082d1e6 -r 7f2962f619e3 auto_threshold.xml --- 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 @@ - + applies a standard threshold algorithm to an image - + scikit-image numpy pillow