python类SMOOTH_MORE的实例源码

app.py 文件源码 项目:blackout 作者: lizadaly 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def image_filter(img):
    for i in range(10):
        img = img.filter(ImageFilter.SMOOTH_MORE)
    return img
noise.py 文件源码 项目:road_simulator 作者: vinzeebreak 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def call(self, img):

        if img is None: raise ValueError('img is None')

        im_n = img.copy()

        gauss_blur_low, gauss_blur_high = 0, self.gauss_blur
        blur_low, blur_high = gauss_blur_high, gauss_blur_high + self.blur
        smooth_low, smooth_high = blur_high, blur_high + self.smooth
        smooth_more_low, smooth_more_high = smooth_high, smooth_high + self.smooth_more
        rank_low, rank_high = smooth_more_high, smooth_more_high + self.rank_filter

        r = random()
        if gauss_blur_low <= r <= gauss_blur_high:
            im_n = im_n.filter(ImageFilter.GaussianBlur(1))
        elif blur_low < r <= blur_high:
            im_n = im_n.filter(ImageFilter.BLUR)
        elif smooth_low < r <= smooth_high:
            im_n = im_n.filter(ImageFilter.SMOOTH)
        elif smooth_more_low < r <= smooth_more_high:
            im_n = im_n.filter(ImageFilter.SMOOTH_MORE)
        elif rank_low < r <= rank_high:
            im_n = im_n.filter(ImageFilter.RankFilter(size=3, rank=7))
        else:
            pass
        return im_n


问题


面经


文章

微信
公众号

扫码关注公众号