diff --git a/imagepy/menus/File/Import/roi_plg.py b/imagepy/menus/File/Import/roi_plg.py index f7083ce6..17807984 100644 --- a/imagepy/menus/File/Import/roi_plg.py +++ b/imagepy/menus/File/Import/roi_plg.py @@ -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""" @@ -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'])