Skip to content

Commit

Permalink
Use tight bounding box to represent bbox for shape_type="mask"
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Dec 30, 2023
1 parent ca07ccc commit f802707
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions labelme/widgets/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,12 +768,12 @@ def paintEvent(self, event):
points=[[point.x(), point.y()] for point in drawing_shape.points],
point_labels=drawing_shape.point_labels,
)
y1, x1, y2, x2 = imgviz.instances.mask_to_bbox([mask])[0].astype(int)
y1, x1, y2, x2 = imgviz.instances.masks_to_bboxes([mask])[0].astype(int)
drawing_shape.setShapeRefined(
shape_type="mask",
points=[QtCore.QPointF(x1, y1), QtCore.QPointF(x2, y2)],
point_labels=[1, 1],
mask=mask[y1:y2, x1:x2],
mask=mask[y1 : y2 + 1, x1 : x2 + 1],
)
drawing_shape.selected = True
drawing_shape.paint(p)
Expand Down Expand Up @@ -818,12 +818,12 @@ def finalise(self):
points=[[point.x(), point.y()] for point in self.current.points],
point_labels=self.current.point_labels,
)
y1, x1, y2, x2 = imgviz.instances.mask_to_bbox([mask])[0].astype(int)
y1, x1, y2, x2 = imgviz.instances.masks_to_bboxes([mask])[0].astype(int)
self.current.setShapeRefined(
shape_type="mask",
points=[QtCore.QPointF(x1, y1), QtCore.QPointF(x2, y2)],
point_labels=[1, 1],
mask=mask[y1:y2, x1:x2],
mask=mask[y1 : y2 + 1, x1 : x2 + 1],
)
self.current.close()

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_version():
def get_install_requires():
install_requires = [
"gdown",
"imgviz>=0.11",
"imgviz>=1.7.5",
"matplotlib",
"natsort>=7.1.0",
"numpy",
Expand Down

0 comments on commit f802707

Please sign in to comment.