comparison histogram_equalization.py @ 3:b1c2c210813c draft default tip

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_histogram_equalization/ commit c86a1b93cb7732f7331a981d13465653cc1a2790
author imgteam
date Wed, 24 Apr 2024 08:11:54 +0000
parents 77f7159d775a
children
comparison
equal deleted inserted replaced
2:3f3783846dc0 3:b1c2c210813c
1 import argparse 1 import argparse
2 import sys 2 import sys
3 3
4 import giatools.io
4 import skimage.exposure 5 import skimage.exposure
5 import skimage.io 6 import skimage.io
6 import skimage.util 7 import skimage.util
7 8
8 hOptions = { 9 hOptions = {
15 parser.add_argument('input_file', type=argparse.FileType('r'), default=sys.stdin, help='input file') 16 parser.add_argument('input_file', type=argparse.FileType('r'), default=sys.stdin, help='input file')
16 parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)') 17 parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)')
17 parser.add_argument('h_type', choices=hOptions.keys(), help='histogram equalization method') 18 parser.add_argument('h_type', choices=hOptions.keys(), help='histogram equalization method')
18 args = parser.parse_args() 19 args = parser.parse_args()
19 20
20 img_in = skimage.io.imread(args.input_file.name) 21 img_in = giatools.io.imread(args.input_file.name)
21 res = hOptions[args.h_type](img_in) 22 res = hOptions[args.h_type](img_in)
22 res = skimage.util.img_as_uint(res) 23 res = skimage.util.img_as_uint(res)
23 skimage.io.imsave(args.out_file.name, res, plugin="tifffile") 24 skimage.io.imsave(args.out_file.name, res, plugin="tifffile")