imantics icon indicating copy to clipboard operation
imantics copied to clipboard

Is it possible that imantics is missing the mask outermost pixels?

Open bpmsilva opened this issue 5 years ago • 2 comments

Hello everyone,

I'm converting binary masks created from exported COCO Annotator JSON files. From a JSON file, I generate binary masks using cv2.fillPoly and process them. This results in more masks that are usually next to each other (their pixels touch each other). However, after I generate the annotation segmention (using [list(map(round, polygon)) for polygon in mask.polygons()]) and importing the generated JSON to COCO Annotator, I see that these masks do not touch each other. There is a thin space between them. That's why I wonder if in the imantics conversion some pixels are missed. Another possibility is a bug or a different convention in cv2.fillPoly. I'll investigate the problem, but any help here is welcome.

I really appreciate any help you can provide.

bpmsilva avatar Jan 12 '21 18:01 bpmsilva

I think the polygon finds min and max, rather than min and stop. this means that the 'topmost' pixels aren't inside the polygon, when they are interpreted as the latter format.

a two by two box of pixels (pixels [1,1],[2,1],[2,2],[1,2] labelled as ones) produces the polygon points [1,1],[2,1],[2,2],[1,2] which is interpreted as most systems as a 1 by 1 box

I think returning [1,1],[3,1],[3,3],[1,3] would give the results you expect.

Thormidable avatar Dec 14 '21 10:12 Thormidable

6 polygons_list = (Mask(mask).polygons()).points for points in polygons_list: # print(points) for point in points: cv2.circle(jpg, (point[0], point[1]), 5, (255, 0, 0), -1) cv2.imwrite("6.jpg", jpg) Some position coordinates are missing thank you.

ZhouBay-TF avatar Feb 23 '22 10:02 ZhouBay-TF