annotation.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:facade-segmentation 作者: jfemiani 项目源码 文件源码
def get_mask(self, fill=1, outline=0):
        """
        Get a mask that is nonzero within the object.
        :param fill:  A color to use on the object's interior
        :param outline: A color to use on the object's edge (single pixel)
        :return: A 2D numpy array of uint8
        """
        if self.type in (TYPE_POLYGON, TYPE_BOUNDING_BOX):
            (top, left, bottom, right) = self.polygon.bounds()
            w = right-left
            h = bottom-top
            mask = Image.new("I", (w, h))
            d = ImageDraw.Draw(mask)
            d.polygon([(px-left, py-top) for (px, py) in self.polygon.points],
                        fill=fill, outline=outline)
            del d
            return np.asarray(mask)
        else:
            assert False, "Unhandled Type"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号