annotate colorize_labels.py @ 4:5907be5a8d7c draft default tip

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
author imgteam
date Tue, 24 Sep 2024 17:30:20 +0000
parents 2d1de6e7b113
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
1 import argparse
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
2
3
2d1de6e7b113 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit c86a1b93cb7732f7331a981d13465653cc1a2790
imgteam
parents: 1
diff changeset
3 import giatools.io
4
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
4 import matplotlib.pyplot as plt
1
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
5 import networkx as nx
0
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
6 import numpy as np
1
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
7 import scipy.ndimage as ndi
0
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
8 import skimage.io
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
9 import skimage.util
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
10
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
11
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
12 def color_hex_to_rgb_tuple(hex):
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
13 if hex.startswith('#'):
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
14 hex = hex[1:]
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
15 return (
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
16 int(hex[0:2], 16),
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
17 int(hex[2:4], 16),
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
18 int(hex[4:6], 16),
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
19 )
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
20
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
21
1
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
22 def build_label_adjacency_graph(im, radius, bg_label):
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
23 G = nx.Graph()
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
24 for label in np.unique(im):
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
25
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
26 if label == bg_label:
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
27 continue
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
28
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
29 G.add_node(label)
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
30
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
31 cc = (im == label)
4
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
32 neighborhood = (ndi.distance_transform_edt(~cc) <= radius)
1
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
33 adjacent_labels = np.unique(im[neighborhood])
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
34
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
35 for adjacent_label in adjacent_labels:
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
36
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
37 if adjacent_label == bg_label or adjacent_label <= label:
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
38 continue
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
39
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
40 G.add_edge(label, adjacent_label)
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
41 G.add_edge(adjacent_label, label)
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
42
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
43 return G
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
44
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
45
4
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
46 def get_n_unique_mpl_colors(n, colormap='jet', cyclic=False):
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
47 """
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
48 Yields `n` unique colors from the given `colormap`.
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
49
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
50 Set `cyclic` to `True` if the `colormap` is cyclic.
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
51 """
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
52 cmap = plt.get_cmap(colormap)
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
53 m = n if cyclic else n - 1
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
54 for i in range(n):
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
55 yield np.multiply(255, cmap(i / m))
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
56
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
57
0
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
58 if __name__ == '__main__':
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
59
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
60 parser = argparse.ArgumentParser()
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
61 parser.add_argument('input', type=str)
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
62 parser.add_argument('--bg_label', type=int)
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
63 parser.add_argument('--bg_color', type=str)
1
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
64 parser.add_argument('--radius', type=int)
0
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
65 parser.add_argument('--output', type=str)
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
66 args = parser.parse_args()
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
67
1
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
68 # Load image and normalize
3
2d1de6e7b113 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit c86a1b93cb7732f7331a981d13465653cc1a2790
imgteam
parents: 1
diff changeset
69 im = giatools.io.imread(args.input)
0
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
70 im = np.squeeze(im)
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
71 assert im.ndim == 2
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
72
1
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
73 # Build adjacency graph of the labels
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
74 G = build_label_adjacency_graph(im, args.radius, args.bg_label)
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
75
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
76 # Apply greedy coloring
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
77 graph_coloring = nx.greedy_color(G)
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
78 unique_colors = frozenset(graph_coloring.values())
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
79
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
80 # Assign colors to nodes based on the greedy coloring
4
5907be5a8d7c planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 4344f548f365dba87c20188d6e3c2df8630d2313
imgteam
parents: 3
diff changeset
81 graph_color_to_mpl_color = dict(zip(unique_colors, get_n_unique_mpl_colors(len(unique_colors))))
1
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
82 node_colors = [graph_color_to_mpl_color[graph_coloring[n]] for n in G.nodes()]
0
0afb17e107ff planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit ffedf4e17ecbb226657ccf8472b0572532e9aa8a
imgteam
parents:
diff changeset
83
1
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
84 # Render result
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
85 bg_color_rgb = color_hex_to_rgb_tuple(args.bg_color)
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
86 result = np.dstack([np.full(im.shape, bg_color_rgb[ch], np.uint8) for ch in range(3)])
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
87 for label, label_color in zip(G.nodes(), node_colors):
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
88
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
89 cc = (im == label)
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
90 for ch in range(3):
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
91 result[:, :, ch][cc] = label_color[ch]
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
92
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
93 # Write result image
43c80f3c3b60 planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/colorize_labels commit 98270c8f2805d406e0d88605fde778f8f182df9b
imgteam
parents: 0
diff changeset
94 skimage.io.imsave(args.output, result)