# HG changeset patch # User imgteam # Date 1549740794 18000 # Node ID 30517f733f7b7df12d026203ecd2205cceb5e9fd planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/concat_channels/ commit c3f4b766f03770f094fda6bda0a5882c0ebd4581 diff -r 000000000000 -r 30517f733f7b concat_channels.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/concat_channels.py Sat Feb 09 14:33:14 2019 -0500 @@ -0,0 +1,33 @@ +import argparse +import sys +import warnings +import numpy as np +import skimage.io +import skimage.util + +def concat_channels(input_image_paths, output_image_path, axis): + images = [] + for image_path in input_image_paths: + raw_image = skimage.io.imread(image_path) + if len(raw_image.shape) == 2: + if axis == 0: + raw_image = [raw_image] + else: + raw_image = np.expand_dims(raw_image, 2) + images.append(raw_image) + res = np.concatenate(images, axis) + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + res = skimage.util.img_as_uint(res) #Attention: precision loss + skimage.io.imsave(output_image_path, res, plugin='tifffile') + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('input_files', type=argparse.FileType('r'), nargs='+', help='input file') + parser.add_argument('-o', dest='out_file', type=argparse.FileType('w'), help='out file (TIFF)') + parser.add_argument('--axis', dest='axis', type=int, default=0, choices=[0,2], help='concatenation axis') + args = parser.parse_args() + + # print([x.name for x in args.input_files], args.out_file.name, args.axis) + concat_channels([x.name for x in args.input_files], args.out_file.name, args.axis) + # concat_channels(args.input_files, args.out_file, args.axis) diff -r 000000000000 -r 30517f733f7b concat_channels.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/concat_channels.xml Sat Feb 09 14:33:14 2019 -0500 @@ -0,0 +1,41 @@ + + + + scikit-image + numpy + + + + + + + + + + + + + + + + + + + + + + + **What it does** + + This tool concatenates images. + + + 10.1016/j.jbiotec.2017.07.019 + + diff -r 000000000000 -r 30517f733f7b test-data/out.tiff Binary file test-data/out.tiff has changed diff -r 000000000000 -r 30517f733f7b test-data/res.tiff Binary file test-data/res.tiff has changed diff -r 000000000000 -r 30517f733f7b test-data/sample1.png Binary file test-data/sample1.png has changed diff -r 000000000000 -r 30517f733f7b test-data/sample2.png Binary file test-data/sample2.png has changed