forked from okuspokus/roipoly.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
38 lines (29 loc) · 977 Bytes
/
example.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
import pylab as pl
from roipoly import roipoly
# create image
img = pl.ones((100, 100)) * range(0, 100)
# show the image
pl.imshow(img, interpolation='nearest', cmap="Greys")
pl.colorbar()
pl.title("left click: line segment right click: close region")
# let user draw first ROI
ROI1 = roipoly(roicolor='r') #let user draw first ROI
# show the image with the first ROI
pl.imshow(img, interpolation='nearest', cmap="Greys")
pl.colorbar()
ROI1.displayROI()
pl.title('draw second ROI')
# let user draw second ROI
ROI2 = roipoly(roicolor='b') #let user draw ROI
# show the image with both ROIs and their mean values
pl.imshow(img, interpolation='nearest', cmap="Greys")
pl.colorbar()
[x.displayROI() for x in [ROI1, ROI2]]
[x.displayMean(img) for x in [ROI1, ROI2]]
pl.title('The two ROIs')
pl.show()
# show ROI masks
pl.imshow(ROI1.getMask(img) + ROI2.getMask(img),
interpolation='nearest', cmap="Greys")
pl.title('ROI masks of the two ROIs')
pl.show()