Mercurial > repos > imgteam > morphological_operations
annotate morphological_operations.py @ 1:ad795d260ba8 draft
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c045f067a57e8308308cf6329060c7ccd3fc372f
author | imgteam |
---|---|
date | Thu, 04 Apr 2024 15:25:44 +0000 |
parents | f10112b317a1 |
children | 4e25befab102 |
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 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
3 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
|
4 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
|
5 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
|
6 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
|
7 |
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 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
|
10 """ |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
11 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
|
12 """ |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
13 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
|
14 'square', |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
15 'disk', |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
16 ) |
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 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
|
19 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
|
20 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
21 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
|
22 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
|
23 |
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 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
|
26 """ |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
27 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
|
28 """ |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
29 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
|
30 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
|
31 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
|
32 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
|
33 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
|
34 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
|
35 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
|
36 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
|
37 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
|
38 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
|
39 else: |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
40 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
|
41 |
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 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
|
44 operations = { |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
45 '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
|
46 '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
|
47 '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
|
48 '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
|
49 } |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
50 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
|
51 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
|
52 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
|
53 else: |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
54 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
|
55 |
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 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
|
58 operations = { |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
59 '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
|
60 '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
|
61 '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
|
62 '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
|
63 '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
|
64 } |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
65 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
|
66 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
|
67 |
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 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
|
70 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
79 im = skimage.io.imread(args.input) |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
80 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
|
81 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
82 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
|
83 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
|
84 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
85 else: |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 |
f10112b317a1
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/morphological_operations commit c6d2a4fb19b54c804029ae3d52eb9fb2619e4265
imgteam
parents:
diff
changeset
|
93 skimage.io.imsave(args.output, im_result) |