Python PIL.ImageFilter 模块,SMOOTH 实例源码

我们从Python开源项目中,提取了以下17个代码示例,用于说明如何使用PIL.ImageFilter.SMOOTH

项目:IV    作者:collinmutembei    | 项目源码 | 文件源码
def apply_effects(image, effects):
    """method to apply effects to original image from list of effects
    """
    for effect in effects:
        gray = ImageOps.grayscale(image)
        # dictionary with all the availble effects
        all_effects = {
            'BLUR': image.filter(ImageFilter.BLUR),
            'CONTOUR': image.filter(ImageFilter.CONTOUR),
            'EMBOSS': image.filter(ImageFilter.EMBOSS),
            'SMOOTH': image.filter(ImageFilter.SMOOTH),
            'HULK': ImageOps.colorize(gray, (0, 0, 0, 0), '#00ff00'),
            'FLIP': ImageOps.flip(image),
            'MIRROR': ImageOps.mirror(image),
            'INVERT': ImageOps.invert(image),
            'SOLARIZE': ImageOps.solarize(image),
            'GREYSCALE': ImageOps.grayscale(image),

        }
        phedited = all_effects[effect]
        image = phedited
    return phedited
项目:imagepaste    作者:robinchenyu    | 项目源码 | 文件源码
def __init__(self, image):
        self.image = image
        self.degenerate = image.filter(ImageFilter.SMOOTH)

        if 'A' in image.getbands():
            self.degenerate.putalpha(image.split()[-1])
项目:ascii-art-py    作者:blinglnav    | 项目源码 | 文件源码
def __init__(self, image):
        self.image = image
        self.degenerate = image.filter(ImageFilter.SMOOTH)

        if 'A' in image.getbands():
            self.degenerate.putalpha(image.split()[-1])
项目:radar    作者:amoose136    | 项目源码 | 文件源码
def __init__(self, image):
        self.image = image
        self.degenerate = image.filter(ImageFilter.SMOOTH)

        if 'A' in image.getbands():
            self.degenerate.putalpha(image.split()[-1])
项目:sdining    作者:Lurance    | 项目源码 | 文件源码
def post_smooth(image):
    try:
        import ImageFilter
    except ImportError:
        from PIL import ImageFilter
    return image.filter(ImageFilter.SMOOTH)
项目:Imagyn    作者:zevisert    | 项目源码 | 文件源码
def soften(img):
    """
    Soften image
    :param img: PIL image object
    :return: PIL image object
    """
    img = img.filter(ImageFilter.SMOOTH)
    return img
项目:cetusshop    作者:icetusorg    | 项目源码 | 文件源码
def post_smooth(image):
    try:
        import ImageFilter
    except ImportError:
        from PIL import ImageFilter
    return image.filter(ImageFilter.SMOOTH)
项目:WXBotForPi    作者:nemoTyrant    | 项目源码 | 文件源码
def __init__(self, image):
        self.image = image
        self.degenerate = image.filter(ImageFilter.SMOOTH)

        if 'A' in image.getbands():
            self.degenerate.putalpha(image.split()[-1])
项目:road_simulator    作者:vinzeebreak    | 项目源码 | 文件源码
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
项目:django-rest-captcha    作者:zueve    | 项目源码 | 文件源码
def filter_default(image):
    return utils.filter_smooth(image, ImageFilter.SMOOTH)
项目:teleport    作者:eomsoft    | 项目源码 | 文件源码
def __init__(self, image):
        self.image = image
        self.degenerate = image.filter(ImageFilter.SMOOTH)

        if 'A' in image.getbands():
            self.degenerate.putalpha(image.split()[-1])
项目:teleport    作者:eomsoft    | 项目源码 | 文件源码
def __init__(self, image):
        self.image = image
        self.degenerate = image.filter(ImageFilter.SMOOTH)

        if 'A' in image.getbands():
            self.degenerate.putalpha(image.split()[-1])
项目:alfred-image-utilities    作者:danielecook    | 项目源码 | 文件源码
def __init__(self, image):
        self.image = image
        self.degenerate = image.filter(ImageFilter.SMOOTH)

        if 'A' in image.getbands():
            self.degenerate.putalpha(image.split()[-1])
项目:Image-Processing-and-Steganogrphy    作者:motkeg    | 项目源码 | 文件源码
def Color_Quantization(img):
    '''Color quantization is the process 
    that drastically reduces the number of colors used in a digital color image 
    by approximating the original pixels with their nearest representative colors'''
    img=img.filter(ImageFilter.SMOOTH)
    result = img.convert('P', palette=ADAPTIVE, colors=4)
    result.save('C:\Users\USER\workspace\Final Project\src\outputImage\OUTEqualization.png')
    result.show()
项目:Image-Processing-and-Steganogrphy    作者:motkeg    | 项目源码 | 文件源码
def ImgMax(img):
    img=img.filter(ImageFilter.SMOOTH)
    img=img.filter(ImageFilter.MedianFilter(5))
    img.show()
项目:Image-Processing-and-Steganogrphy    作者:motkeg    | 项目源码 | 文件源码
def Avg(img):
    R,G,B=0,0,0
    img=img.filter(ImageFilter.SMOOTH)
    pxls=img.load()

    N=img.size[0]*img.size[1]
    out_im =new("RGB", img.size, color = 1 )
    out_im2 =new("RGB", img.size, color = 1 )
    #img=cv2.bilateralFilter(np.array(pxls),9,75,75)


    print ("Calculate Avg..")
    for x in xrange (img.size[0]):
        for y in xrange(img.size[1]):
            R,G,B=R+pxls[x,y][0],G+pxls[x,y][1],B+pxls[x,y][2]

    R,G,B=R/N,G/N,B/N 
    for x in xrange (img.size[0]):
        for y in xrange(img.size[1]):
            tup=((pxls[x,y][0])/img.size[0],
                     (pxls[x,y][1])/img.size[0],
                     (pxls[x,y][2])/img.size[0])
            out_im.putpixel((x,y),tup)
            if((pxls[x,y][0]>R and  pxls[x,y][1]>G and pxls[x,y][2]>B)
                or (pxls[x,y][0]<R and  pxls[x,y][1]<G and pxls[x,y][2]<B)):
                out_im.putpixel((x,y),pxls[x,y])

    out_im.save('C:\Users\USER\workspace\Final Project\src\outputImage\OUTAVG.png')
    print ("Output Saved") 
    out_im.show()
项目:PoiBot    作者:link2110    | 项目源码 | 文件源码
def rip(self, ctx, member_or_text: str):
        """RIP\nCreates a tombstone for either a member or some text. Mention a member to get the avatar + name"""
        if ctx.message.mentions:
            user_name = ctx.message.mentions[0].name.replace(" ", "%20")
            rip_member = ctx.message.mentions[0]
            ava_url = rip_member.avatar_url
            url = "https://ripme.xyz/{}"
            msg = url.format(user_name)

            tomb = Image.open(os.path.join(asset_pos, "tombstone.png"))
            base_img = Image.new("RGBA", (tomb.width, tomb.height), color="White")
            with aiohttp.ClientSession() as session:
                async with session.get(ava_url) as resp:
                    ava = await resp.content.read()

            ava_img = Image.open(io.BytesIO(ava))
            ava_img_greyscale = ImageOps.autocontrast(ava_img.convert("L").filter(ImageFilter.CONTOUR)).filter(
                ImageFilter.SMOOTH).resize((200, 200))
            base_img.paste(ava_img_greyscale, (140, 380, 340, 580))
            final = ImageChops.multiply(base_img, tomb)
            f = ImageFont.truetype(os.path.join(asset_pos, "Symbola.ttf"), size=35)
            d = ImageDraw.Draw(final)
            w, h = d.textsize(rip_member.name, font=f)
            d.multiline_text(((60 + ((350 - w) / 2)), 315), rip_member.name, fill="Black", font=f, align="center")
            final.save(os.path.join(asset_pos, "rip.png"))
            await self.bot.send_file(ctx.message.channel, os.path.join(asset_pos, "rip.png"), content=msg)
        else:
            content = ctx.message.content.partition(" ")
            user_name = content[2].replace(" ", "_")
            url = "https://ripme.xyz/{}"
            msg = url.format(user_name)
            base_img = Image.new("RGB", (520, 640), color="White")
            tomb = Image.open(os.path.join(asset_pos, "tombstone.png"))
            base_img.paste(tomb)
            f = ImageFont.truetype(os.path.join(asset_pos, "Symbola.ttf"), size=35)
            d = ImageDraw.Draw(base_img)
            text = textwrap.shorten(content[2], width=25, placeholder="")
            w, h = d.textsize(text, font=f)
            d.text(((60 + ((350 - w) / 2)), 315), text, fill="Black", font=f, align="center")
            d.text((160, 450), "2016 - 2016", fill="Black", font=f)
            base_img.save(os.path.join(asset_pos, "rip.jpeg"))
            await self.bot.send_file(ctx.message.channel, os.path.join(asset_pos, "rip.jpeg"), content=msg)