Mercurial > repos > imgteam > morphological_operations
annotate morphological_operations.py @ 2:4e25befab102 draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c86a1b93cb7732f7331a981d13465653cc1a2790
author | imgteam |
---|---|
date | Wed, 24 Apr 2024 08:12:39 +0000 |
parents | f10112b317a1 |
children |
rev | line source |
---|---|
0
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
1 import argparse |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
2 |
2
4e25befab102
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c86a1b93cb7732f7331a981d13465653cc1a2790
imgteam
parents:
0
diff
changeset
|
3 import giatools.io |
0
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
4 import numpy as np |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
5 import scipy.ndimage as ndi |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
6 import skimage.io |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
7 import skimage.morphology as morph |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
8 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
9 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
10 def create_selem(args): |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
11 """ |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
12 Creates structuring element based on commandline arguments. |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
13 """ |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
14 assert args.selem_shape in ( |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
15 'square', |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
16 'disk', |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
17 ) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
18 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
19 if args.selem_shape == 'square': |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
20 return np.ones((args.selem_size, args.selem_size)) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
21 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
22 elif args.selem_shape == 'disk': |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
23 return morph.disk(args.selem_size) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
24 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
25 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
26 def apply_operation(args, im): |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
27 """ |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
28 Applies morphological operation to a 2-D single-channel image. |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
29 """ |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
30 assert im.ndim == 2 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
31 selem = create_selem(args) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
32 values_count = len(np.unique(im)) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
33 if values_count <= 2: |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
34 im_proxy = np.zeros(im.shape, bool) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
35 im_proxy[im == im.max()] = True |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
36 result_proxy = apply_binary_operation(args, im_proxy, selem) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
37 result = np.full(im.shape, im.min(), im.dtype) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
38 result[result_proxy] = im.max() |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
39 return result |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
40 else: |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
41 return apply_intensity_based_operation(args, im, selem) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
42 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
43 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
44 def apply_intensity_based_operation(args, im, selem): |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
45 operations = { |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
46 'erosion': ndi.grey_erosion, |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
47 'dilation': ndi.grey_dilation, |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
48 'opening': ndi.grey_opening, |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
49 'closing': ndi.grey_closing, |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
50 } |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
51 if args.operation in operations: |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
52 operation = operations[args.operation] |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
53 return operation(input=im, structure=selem) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
54 else: |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
55 raise ValueError(f'Operation "{args.operation}" not supported for this image type ({im.dtype}).') |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
56 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
57 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
58 def apply_binary_operation(args, im, selem): |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
59 operations = { |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
60 'erosion': ndi.binary_erosion, |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
61 'dilation': ndi.binary_dilation, |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
62 'opening': ndi.binary_opening, |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
63 'closing': ndi.binary_closing, |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
64 'fill_holes': ndi.binary_fill_holes, |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
65 } |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
66 operation = operations[args.operation] |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
67 return operation(input=im, structure=selem) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
68 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
69 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
70 if __name__ == '__main__': |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
71 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
72 parser = argparse.ArgumentParser() |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
73 parser.add_argument('--operation', type=str) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
74 parser.add_argument('--selem-shape', type=str) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
75 parser.add_argument('--selem-size', type=int) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
76 parser.add_argument('input', type=str) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
77 parser.add_argument('output', type=str) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
78 args = parser.parse_args() |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
79 |
2
4e25befab102
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c86a1b93cb7732f7331a981d13465653cc1a2790
imgteam
parents:
0
diff
changeset
|
80 im = giatools.io.imread(args.input) |
0
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
81 assert im.ndim in (2, 3), 'Input image must be two-dimensional and either single-channel or multi-channel.' |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
82 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
83 if im.ndim == 2: |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
84 im_result = apply_operation(args, im) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
85 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
86 else: |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
87 ch_result_list = [] |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
88 for ch_idx in range(im.shape[2]): |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
89 ch = im[:, :, ch_idx] |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
90 ch_result = apply_operation(args, ch) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
91 ch_result_list.append(ch_result) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
92 im_result = np.dstack(ch_result_list) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
93 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
94 skimage.io.imsave(args.output, im_result) |