随笔 - 26,  文章 - 0,  评论 - 0,  阅读 - 13878
复制代码
from PIL import Image, ImageFilter
import os


class MyGaussianBlur(ImageFilter.Filter):
    name = "GaussianBlur"

    def __init__(self, radius=2, bounds=None):
        self.radius = radius
        self.bounds = bounds

    def filter(self, image):
        if self.bounds:
            clips = image.crop(self.bounds).gaussian_blur(self.radius)
            image.paste(clips, self.bounds)
            return image
        else:
            return image.gaussian_blur(self.radius)


if __name__ == '__main__':

    open_path = './image/'
    save_path = './images100k/'
    open_list_path = os.listdir(open_path)
    for i in open_list_path:
        frame_image = Image.open(open_path + i)
        image = frame_image.filter(MyGaussianBlur(radius=3))   # 通过调节redius的值调整图片的清晰度
        image.thumbnail((1920, 1020))  # 调整图片的尺寸
        image.save(save_path + str(i))

    print('success')
复制代码

如果觉得对你有帮助的话可以给我点个赞哦!么么哒~

posted on 2020-11-02 17:05  风雨无阻!  阅读(1603)  评论(0)    收藏  举报
编辑推荐:
· 我在厂里搞 wine 的日子
· 如何通过向量化技术比较两段文本是否相似?
· 35+程序员的转型之路:经济寒冬中的希望与策略
· JavaScript中如何遍历对象?
· 领域模型应用
阅读排行:
· 独立开发,这条路可行吗?
· C#源生成器:让你的代码飞起来的黑科技
· Java简历、面试、试用期、转正
· Java开发AI项目,太爽了!LangChain4j保姆级教程
· SpringBoot3 + LangChain4j + Redis 实现大模型多轮对话及工具调用

< 2025年7月 >
29 30 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31 1 2
3 4 5 6 7 8 9
点击右上角即可分享
微信分享提示