Mercurial > repos > imgteam > colocalization_viz
comparison colocalization_viz.py @ 1:fc85eb253163 draft
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/colocalization_viz/ commit 1453917dfaf4c0922aec82c400015ff7e13ab737
author | imgteam |
---|---|
date | Mon, 22 Jul 2019 07:08:46 -0400 |
parents | 9ddb11b272ee |
children | c73332d5c3bb |
comparison
equal
deleted
inserted
replaced
0:9ddb11b272ee | 1:fc85eb253163 |
---|---|
1 import skimage.io | 1 import skimage.io |
2 import skimage.color | 2 import skimage.color |
3 from skimage import img_as_uint | |
4 from skimage.exposure import equalize_adapthist | |
3 import numpy as np | 5 import numpy as np |
4 import os | 6 import argparse |
5 import sys | 7 import sys |
6 import warnings | |
7 | 8 |
8 #TODO make importable by python script | |
9 | 9 |
10 args = sys.argv | 10 # TODO make importable by python script |
11 | |
12 def readImg(path): | 11 def readImg(path): |
13 img = skimage.io.imread(path) | 12 img = skimage.io.imread(path) |
13 | |
14 if len(img.shape) > 2: | 14 if len(img.shape) > 2: |
15 img = skimage.color.rgb2gray(img) | 15 img = skimage.color.rgb2gray(img) |
16 img = np.expand_dims(img > 0, 3) | 16 img = equalize_adapthist(img, clip_limit=0.03) |
17 img = img_as_uint(img) | |
18 img = np.reshape(img, [img.shape[0], img.shape[1], 1]) | |
17 return img | 19 return img |
18 | 20 |
19 im1 = readImg(args[1]) | |
20 im2 = readImg(args[2]) | |
21 res = np.concatenate((im1, im2, np.zeros_like(im1)), axis=2) * 1.0 | |
22 | 21 |
23 with warnings.catch_warnings(): | 22 parser = argparse.ArgumentParser() |
24 warnings.simplefilter("ignore") | 23 parser.add_argument('input_file1', type=argparse.FileType('r'), default=sys.stdin, help='input file (red)') |
25 skimage.io.imsave(args[3], res) | 24 parser.add_argument('input_file2', type=argparse.FileType('r'), default=sys.stdin, help='input file (green)') |
25 parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)') | |
26 args = parser.parse_args() | |
27 | |
28 im1 = readImg(args.input_file1.name) | |
29 im2 = readImg(args.input_file2.name) | |
30 res = np.concatenate((im1, im2, np.zeros_like(im1)), axis=-1) | |
31 skimage.io.imsave(args.out_file.name, res) |