Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions imagepy/menus/File/Import/roi_plg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import read_roi
from imagepy.core.engine import Free
from imagepy import IPy
from skimage.draw import polygon
from skimage.draw import polygon, ellipse

class Plugin(Free):
"""load_ij_roi: use read_roi and th pass to shapely objects"""
Expand All @@ -27,5 +27,18 @@ def run(self, para=None):
ls = read_roi.read_roi_zip(para['path'])
img = np.zeros((para['height'], para['width']), dtype=np.int32)
for i in ls:
img[polygon(ls[i]['y'], ls[i]['x'], img.shape)] = int(i)
current_roi = ls[i]
roi_type = current_roi["type"]
if roi_type is "freehand":
rs, cs = polygon(ls[i]['y'], ls[i]['x'], img.shape)
elif roi_type is "oval":
rs, cs = ellipse(current_roi["top"]+current_roi["height"]/2,
current_roi["left"]+current_roi["width"]/2,
current_roi["height"]/2,
current_roi["width"]/2)
try:
ind = int(i)
except Exception:
ind = int(i.split("-")[-1])
img[rs, cs] = ind
IPy.show_img([img], para['name'])