comparison scale_image.py @ 5:85666e555698 draft

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/scale_image/ commit c86a1b93cb7732f7331a981d13465653cc1a2790
author imgteam
date Wed, 24 Apr 2024 08:13:13 +0000
parents 3179853faae9
children
comparison
equal deleted inserted replaced
4:3179853faae9 5:85666e555698
1 import argparse 1 import argparse
2 import sys 2 import sys
3 3
4 import giatools.io
4 import numpy as np 5 import numpy as np
5 import skimage.io 6 import skimage.io
6 import skimage.transform 7 import skimage.transform
7 import skimage.util 8 import skimage.util
8 from PIL import Image 9 from PIL import Image
9 10
10 11
11 def scale_image(input_file, output_file, scale, order, antialias): 12 def scale_image(input_file, output_file, scale, order, antialias):
12 Image.MAX_IMAGE_PIXELS = 50000 * 50000 13 Image.MAX_IMAGE_PIXELS = 50000 * 50000
13 im = skimage.io.imread(input_file) 14 im = giatools.io.imread(input_file)
14 15
15 # Parse `--scale` argument 16 # Parse `--scale` argument
16 if ',' in scale: 17 if ',' in scale:
17 scale = [float(s.strip()) for s in scale.split(',')] 18 scale = [float(s.strip()) for s in scale.split(',')]
18 assert len(scale) <= im.ndim, f'Image has {im.ndim} axes, but scale factors were given for {len(scale)} axes.' 19 assert len(scale) <= im.ndim, f'Image has {im.ndim} axes, but scale factors were given for {len(scale)} axes.'