-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowmask.py
47 lines (36 loc) · 1.27 KB
/
showmask.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os, os.path, sys
import numpy as np
import scipy as sp
import matplotlib
matplotlib.use('qt5agg')
import matplotlib.pyplot as plt
import skimage
from skimage import (morphology, segmentation, exposure, feature, filters,
measure, transform, util, io, color)
import click
import spotzplot
#-------------------------------------------------------------------------------
@click.command()
@click.argument("imgfile",
type = click.File("r"))
@click.argument("maskfile",
type = click.File("r"))
@click.option("--color",
help = "Color map to use to display labeled objects.",
type = str,
default = "Reds")
@click.option("--alpha",
help = "Alpha transparency over labeled object overlay.",
type = float,
default = 0.35,
show_default = True)
def main(imgfile, maskfile, color, alpha):
"""Draw labeled objects from segmentation mask over image.
"""
img = np.squeeze(io.imread(imgfile))
labeled_img = sp.sparse.load_npz(maskfile).toarray()
fig, ax = spotzplot.draw_image_and_labels(img, labeled_img,
mask_cmap = color, alpha = alpha)
plt.show()
if __name__ == "__main__":
main()