Skip to content

Commit b2db7c3

Browse files
authored
Merge pull request #72 from BioinfoTongLI/roi_import_fix
quick fix of roi import plg
2 parents 9a1c334 + 2d332aa commit b2db7c3

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

imagepy/menus/File/Import/roi_plg.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import read_roi
88
from imagepy.core.engine import Free
99
from imagepy import IPy
10-
from skimage.draw import polygon
10+
from skimage.draw import polygon, ellipse
1111

1212
class 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'])

0 commit comments

Comments
 (0)