Mercurial > repos > imgteam > split_labelmap
comparison split_labelmap.py @ 3:0e7be7c35f15 draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/split_labelmaps/ commit c86a1b93cb7732f7331a981d13465653cc1a2790
author | imgteam |
---|---|
date | Wed, 24 Apr 2024 08:13:26 +0000 |
parents | 9db1c22dbe17 |
children |
comparison
equal
deleted
inserted
replaced
2:7a2e2e3cf836 | 3:0e7be7c35f15 |
---|---|
1 import argparse | 1 import argparse |
2 import warnings | 2 import warnings |
3 | 3 |
4 import giatools.io | |
4 import numpy as np | 5 import numpy as np |
5 import scipy | 6 import scipy |
6 import skimage.draw | 7 import skimage.draw |
7 import skimage.io | 8 import skimage.io |
8 from imageio import imread as io_imread | |
9 from skimage.measure import regionprops | 9 from skimage.measure import regionprops |
10 | 10 |
11 # split_label_image takes a label image and outputs a similar file with the given name where the labeled | 11 # split_label_image takes a label image and outputs a similar file with the given name where the labeled |
12 # parts of the image that touch (or overlap) are separated by at least 1 pixel (at most 2). | 12 # parts of the image that touch (or overlap) are separated by at least 1 pixel (at most 2). |
13 | 13 |
14 | 14 |
15 def split_labelmap(labelmap, outputfile): | 15 def split_labelmap(labelmap, outputfile): |
16 | 16 |
17 # Information from the label map. | 17 # Information from the label map. |
18 label_img = io_imread(labelmap) | 18 label_img = giatools.io.imread(labelmap) |
19 xtot, ytot = label_img.shape | 19 xtot, ytot = label_img.shape |
20 props = regionprops(label_img) | 20 props = regionprops(label_img) |
21 N = len(props) | 21 N = len(props) |
22 | 22 |
23 # Creating the backgrounds. | 23 # Creating the backgrounds. |