
Python
gentleman_zh
这个作者很懒,什么都没留下…
展开
-
PIL_图像通道的分离合并操作
def Binarization(): img = Image.open("1.png") r, g, b = img.split() # 分离三通道 # pic = Image.merge('RGB', (r, g, b)) # 合并三通道 limg = img.convert('L') # 转换成单通道的灰度图 threshold = 4 ...原创 2019-01-17 10:50:15 · 7335 阅读 · 0 评论 -
python_统计文件夹下的所有文件夹数目、统计文件夹下所有文件数目、遍历文件夹下的文件
#统计 /home/dir/ 下的文件夹个数import ospath ="home/dir"count = 0for fn in os.listdir(path): #fn 表示的是文件名 count = count+1print countimport ospath = os.getcwd() #获取当前路径count = 0for root,di...原创 2019-01-07 11:31:52 · 2498 阅读 · 1 评论 -
python_opencv和plt加载图像
OpenCv以彩色图片的形式加载的图片是BGR模式。但是在Matplotlib中,是以RGB的模式加载的。使用OpenCv保存深度学习数据集中的RGB图像需要交换通道才能正常使用。 for imgs, dpts in test_loader: if torch.cuda.is_available(): imgs = imgs.cuda() ...原创 2019-01-18 15:11:24 · 2501 阅读 · 0 评论 -
PIL_查看图像的详细信息
import numpy as np# 图像的二值化def Binarization(): img = Image.open("1.png") plt.imshow(img) plt.show() limg = img.convert('L') #转化成灰度图 threshold = 127 table = [] for i in r...原创 2019-01-16 21:40:30 · 4821 阅读 · 0 评论