data_process.py 文件源码

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

项目:paint_transfer_c92 作者: Hiroshiba 项目源码 文件源码
def __call__(self, image: numpy.ndarray, test):
        from scipy import stats

        def dilate_diff(image, range, iterations=1):
            dil = cv2.dilate(image, numpy.ones((range, range), numpy.float32), iterations=iterations)
            image = cv2.absdiff(image, dil)
            return image

        dtype = image.dtype
        rgb = (image.transpose(1, 2, 0) + 1) / 2
        lab = rgb2lab(rgb) / 100

        image = lab[:, :, 0]
        image = dilate_diff(image, 3).astype(numpy.float32)

        rand = 0.2 + (numpy.random.randn(1) / 20 if not test else 0)
        rand = 0.000001 if rand <= 0 else rand
        image = cv2.GaussianBlur(image, (5, 5), rand)

        rand = 0.4 + (numpy.random.randn(1) / 20 if not test else 0)
        rand = 0.000001 if rand <= 0 else rand
        image = cv2.GaussianBlur(image, (5, 5), rand)

        rand = numpy.random.randn(1) / 40 if not test else 0
        image = numpy.power(image, 0.8 + rand)

        image = image.astype(dtype)[numpy.newaxis]
        return image
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号