![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
weixin_43730508
每天进步一点点
展开
-
python修改图片的大小
'''import osfrom PIL import Imagedef save_resize_img(img_path, img_path_train, width, height): if not os.path.exists(img_path_train): os.mkdir(img_path_train) number = 0 for label_name in os.listdir(img_path): if not os.pat原创 2020-06-11 19:04:38 · 2889 阅读 · 1 评论 -
给图片设置透明度
from PIL import Imageimg = Image.open("F:/mx_matting/test_pic/img_resize/erzhitu_bai/000006_croped7_2.png")img = img.convert('RGBA') # 修改颜色通道为RGBAx, y = img.size # 获得长和宽#设置每个像素点颜色的透明度for i in range(x): for k in range(y): color = img.getp原创 2020-06-11 18:41:27 · 1161 阅读 · 0 评论 -
利用mask图(二值图)和原图实现扣除前景/背景
利用mask图(二值图)和原图实现扣除前景/背景test.pyimport cv2from PIL import Imageimport numpy as npyuantu = "F:/mx_matting/test_pic/img_resize/yuantu/000082_croped83.jpg"masktu1 = "F:/mx_matting/test_pic/img_resize/erzhitu/000082_croped83_2.png"masktu2 = "F:/mx_matti原创 2020-06-11 18:10:59 · 2498 阅读 · 1 评论 -
批量把一个文件夹下的所有图片文件名保存到一个文本文档里
百度搜到的方法,简单又有用,记录下来:先建一个 .txt 文件复制下面的代码保存在 .txt 文件里,并把后缀名改为 .bat @echo off dir /b /on >list.txt把这个 .bat 文件放到图片文件夹下,双击图片文件夹中会多出来一个 list.txt 文件,打开里边的内容就是所有图片的文件名了...原创 2019-12-17 16:58:35 · 877 阅读 · 0 评论 -
Python
python-函数*总结1.递归函数汉诺塔的移动(用递归来解)这道题的另一种问法分析:递归的方法,可以将盘分为上n-1个,和第n个,那么问题就简化成上面n-1个需要移动到另一个柱子,第n个盘子直接移动到C即可,同理下一步就是n-2个移动到另一个柱子,第n-1个移动到C,直到A和B一个圆盘都没有为止。可以把除底盘之外的其他盘子看做一个整体,这样实际每次就移动了两个盘子,一个是(n-1...原创 2019-10-18 20:09:41 · 107 阅读 · 0 评论