Mercurial > repos > imgteam > anisotropic_diffusion
comparison anisotropic_diffusion.py @ 4:6ad5de2c5b7c draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/anisotropic-diffusion/ commit c86a1b93cb7732f7331a981d13465653cc1a2790
author | imgteam |
---|---|
date | Wed, 24 Apr 2024 08:12:09 +0000 |
parents | e6987afa0484 |
children |
comparison
equal
deleted
inserted
replaced
3:097b803aeb5d | 4:6ad5de2c5b7c |
---|---|
1 import argparse | 1 import argparse |
2 import sys | 2 import sys |
3 import warnings | 3 import warnings |
4 | 4 |
5 import giatools.io | |
5 import skimage.io | 6 import skimage.io |
6 import skimage.util | 7 import skimage.util |
7 from medpy.filter.smoothing import anisotropic_diffusion | 8 from medpy.filter.smoothing import anisotropic_diffusion |
8 | 9 |
9 parser = argparse.ArgumentParser() | 10 parser = argparse.ArgumentParser() |
16 args = parser.parse_args() | 17 args = parser.parse_args() |
17 | 18 |
18 with warnings.catch_warnings(): | 19 with warnings.catch_warnings(): |
19 warnings.simplefilter("ignore") # to ignore FutureWarning as well | 20 warnings.simplefilter("ignore") # to ignore FutureWarning as well |
20 | 21 |
21 img_in = skimage.io.imread(args.input_file.name, plugin='tifffile') | 22 img_in = giatools.io.imread(args.input_file.name, plugin='tifffile') |
22 res = anisotropic_diffusion(img_in, niter=args.niter, kappa=args.kappa, gamma=args.gamma, option=args.eqoption) | 23 res = anisotropic_diffusion(img_in, niter=args.niter, kappa=args.kappa, gamma=args.gamma, option=args.eqoption) |
23 res[res < -1] = -1 | 24 res[res < -1] = -1 |
24 res[res > +1] = +1 | 25 res[res > +1] = +1 |
25 | 26 |
26 res = skimage.util.img_as_uint(res) # Attention: precision loss | 27 res = skimage.util.img_as_uint(res) # Attention: precision loss |