4
from matplotlib import pyplot as plt
6
from roipoly import RoiPoly
8
logger = logging.getLogger(__name__)
10
logging.basicConfig(format='%(levelname)s ''%(processName)-10s : %(asctime)s '
11
'%(module)s.%(funcName)s:%(lineno)s %(message)s',
15
img = np.ones((100, 100)) * range(0, 100)
19
plt.imshow(img, interpolation='nearest', cmap="Greys")
21
plt.title("left click: line segment right click: close region")
24
# Let user draw first ROI
25
roi1 = RoiPoly(color='r', fig=fig)
27
# Show the image with the first ROI
29
plt.imshow(img, interpolation='nearest', cmap="Greys")
32
plt.title('draw second ROI')
35
# Let user draw second ROI
36
roi2 = RoiPoly(color='b', fig=fig)
38
# Show the image with both ROIs and their mean values
39
plt.imshow(img, interpolation='nearest', cmap="Greys")
41
[x.display_roi() for x in [roi1, roi2]]
42
[x.display_mean(img) for x in [roi1, roi2]]
43
plt.title('The two ROIs')
47
plt.imshow(roi1.get_mask(img) + roi2.get_mask(img),
48
interpolation='nearest', cmap="Greys")
49
plt.title('ROI masks of the two ROIs')