gui_draw.py 文件源码

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

项目:iGAN 作者: junyanz 项目源码 文件源码
def shadow_image(self, img, pos):
        if img is None:
            return None
        weighted_img = np.ones((img.shape[0], img.shape[1]), np.uint8)
        x = int(pos.x() / self.scale)
        y = int(pos.y() / self.scale)

        weighted_img[y, x] = 0
        dist_img = cv2.distanceTransform(weighted_img, distanceType=cv2.cv.CV_DIST_L2, maskSize=5).astype(np.float32)
        dist_sigma = self.img_size/2.0
        dist_img_f = np.exp(-dist_img / dist_sigma)
        dist_img_f = np.tile(dist_img_f[..., np.newaxis], [1,1,3])
        l = 0.25
        img_f = img.astype(np.float32)
        rst_f = (img_f * l + (1-l) * (img_f * dist_img_f + (1-dist_img_f)*255.0))
        rst = rst_f.astype(np.uint8)
        return rst
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号