comparison wsi_extract_top_view.py @ 2:3bd767eee603 draft default tip

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/wsi_extract_top_view/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
author imgteam
date Mon, 13 Nov 2023 22:12:44 +0000
parents cfe88c6041e9
children
comparison
equal deleted inserted replaced
1:cfe88c6041e9 2:3bd767eee603
1 import argparse 1 import argparse
2
3 import numpy as np
2 import openslide 4 import openslide
3 import os
4 import fnmatch
5 import skimage.io 5 import skimage.io
6 import numpy as np 6
7 7
8 def wsi_extract_top_view(input_path, out_path): 8 def wsi_extract_top_view(input_path, out_path):
9 img_raw = openslide.OpenSlide(input_path) 9 img_raw = openslide.OpenSlide(input_path)
10 top_size = img_raw.level_dimensions[len(img_raw.level_dimensions)-1] 10 top_size = img_raw.level_dimensions[len(img_raw.level_dimensions) - 1]
11 img_area = img_raw.read_region((0,0), len(img_raw.level_dimensions)-1, top_size) 11 img_area = img_raw.read_region((0, 0), len(img_raw.level_dimensions) - 1, top_size)
12 img_area = np.asarray(img_area, dtype=np.uint8) 12 img_area = np.asarray(img_area, dtype=np.uint8)
13 skimage.io.imsave(out_path, img_area, plugin="tifffile") 13 skimage.io.imsave(out_path, img_area, plugin="tifffile")
14 14
15 15
16 if __name__ == "__main__": 16 if __name__ == "__main__":
17 parser = argparse.ArgumentParser() 17 parser = argparse.ArgumentParser()
18 parser.add_argument('input_file', type=argparse.FileType('r'), help='input file') 18 parser.add_argument('input_file', type=argparse.FileType('r'), help='input file')
19 parser.add_argument('out_file', help='out file') 19 parser.add_argument('out_file', help='out file')
20 args = parser.parse_args() 20 args = parser.parse_args()
21 21
22 wsi_extract_top_view(args.input_file.name, args.out_file) 22 wsi_extract_top_view(args.input_file.name, args.out_file)