imagepy
imagepy copied to clipboard
I hava some errors when I load ImageJ RoiSet.zip

error information is
'self.run(para) File "C:\Users\XXX\Desktop\ImagePy-64\ImagePy\programs\lib\site-packages\imagepy\menus\File\Import\roi_plg.py", line 30, in run img[polygon(ls[i]['y'], ls[i]['x'], img.shape)] = int(i) KeyError: 'y''
Hi, @FengZhiheng,
Thank you for filing the issue.
It seems that some features such as "x" and "y" are not saved when you save the roiset in ij.
Can you maybe send an example of your RoiSet.zip?
Tong
Hi, @FengZhiheng, Thank you for filing the issue. It seems that some features such as "x" and "y" are not saved when you save the roiset in
ij. Can you maybe send an example of yourRoiSet.zip? Tong
Ok! It's very kind of you for helping me out.
I successfully opened the RoiSet.zip you sent to me. Is it the same one that caused the error? It seems that the one you sent to me has no problem.
RoiSet1.zip Please try this one. This one can cause the error I met a few days ago. I used Fiji ROI manager and saves this ROI.zip file.
Ok, I confirm it's a glitch. By default, imagepy takes the xy coordinates to draw a polygon. However, IJ sometimes save the bounding box instead of the coordinates. @yxdragon , is there a way to draw a polygon with bounding box?
just using slice to fill bounding box, such as img[top:bot, left:right] = lab. the trouble is, bounding boxes may cross with each other, but for the labled image, one pixel just has one value.
I saw the roi file is a collection of oval object like this: {'type': 'oval', 'left': 154, 'top': 115, 'width': 39, 'height': 38, 'name': '0134-0173', 'position': 0} It is not a polygon object, so we need draw it by skimage.draw.ellipse
rs, cs = ellipse(top+height/2, left+width/2, height/2, width/2) img[rs, cs] = lab
https://github.com/Image-Py/imagepy/pull/72#issue-336336231 PR created for a quick-fix @FengZhiheng
@FengZhiheng merged, have a try. @BioinfoTongLI ellipse method need a shape parameter to cut the rs, cs out of image to make sure that img[rs, cs] is safe.