File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77import read_roi
88from imagepy .core .engine import Free
99from imagepy import IPy
10- from skimage .draw import polygon
10+ from skimage .draw import polygon , ellipse
1111
1212class Plugin (Free ):
1313 """load_ij_roi: use read_roi and th pass to shapely objects"""
@@ -27,5 +27,18 @@ def run(self, para=None):
2727 ls = read_roi .read_roi_zip (para ['path' ])
2828 img = np .zeros ((para ['height' ], para ['width' ]), dtype = np .int32 )
2929 for i in ls :
30- img [polygon (ls [i ]['y' ], ls [i ]['x' ], img .shape )] = int (i )
30+ current_roi = ls [i ]
31+ roi_type = current_roi ["type" ]
32+ if roi_type is "freehand" :
33+ rs , cs = polygon (ls [i ]['y' ], ls [i ]['x' ], img .shape )
34+ elif roi_type is "oval" :
35+ rs , cs = ellipse (current_roi ["top" ]+ current_roi ["height" ]/ 2 ,
36+ current_roi ["left" ]+ current_roi ["width" ]/ 2 ,
37+ current_roi ["height" ]/ 2 ,
38+ current_roi ["width" ]/ 2 )
39+ try :
40+ ind = int (i )
41+ except Exception :
42+ ind = int (i .split ("-" )[- 1 ])
43+ img [rs , cs ] = ind
3144 IPy .show_img ([img ], para ['name' ])
You can’t perform that action at this time.
0 commit comments