python
文章平均质量分 52
香博士
仗剑走天涯,不水不浪
展开
-
skimage data函数库
dataastronautbinary_blobscameracheckerboardchelseaclockcoffeecoinsexpected_warningshorsehubble_deep_fieldimg_as_boolimmunohistochemistryimreadloadlogomoon页火箭stereo_motorcycletextuse_plugin标准测试图像。有关更多图像,请参阅 http://sipi.usc.edu/database/database.php项目原创 2021-12-26 14:40:33 · 4973 阅读 · 1 评论 -
skimage.feature函数使用说明
featureGenerate noisy image of a squareFirst trial with the Canny filter, with the default smoothingIncrease the smoothing for better resultsonly select one feature over twoskimage.feature.blob_dog(image[, min_sigma, …])Finds blobs in the given grayscale原创 2021-12-23 14:24:38 · 5683 阅读 · 0 评论 -
python sample函数
python sample函数1 sample(序列a,n)2 random sample()1 sample(序列a,n)sample(序列a,n)功能:从序列a中随机抽取n个元素,并将n个元素生以list形式返回。例:from random import randint, sampledate = [randint(10,20) for _ in range(10)]c = sample(date, 5)print(c)# 输出:[12, 17, 10, 12, 17]rand原创 2021-12-21 19:55:36 · 42561 阅读 · 2 评论 -
python更改图像尺寸resize
from PIL import Imageimport os.pathimport globdef convertjpg(jpgfile,outdir,width=256,height=256): img=Image.open(jpgfile) h, w = img.size if h != 256 or w != 256: try: print(jpgfile,h,w) new_img=img.resize((w原创 2021-12-12 15:59:47 · 2089 阅读 · 0 评论 -
python替换删除增加图像名称中特定字符
# -*- coding:utf-8 -*-import ospath = "./3-concreteCrackSegmentationDataset/rgb/"files = os.listdir(path)for file in files: print(file)i = 0for file in files: # old name old = path + os.sep + files[i] # new name new = path + os原创 2021-12-12 15:58:48 · 802 阅读 · 0 评论 -
python 批量输出图像的尺寸大小及模式
file_path = './example/images/'i = 0for filename in os.listdir(file_path): img = Image.open(file_path + filename) mod = img.mode h,w = img.size print(filename,h,w,mod) # (int(h/4),int(w/4) #if h % 448 != 0 or w % 448 != 0: #可根据尺寸原创 2021-12-12 15:55:31 · 1149 阅读 · 0 评论 -
python识别两个文件夹中文件是否相同,将不同的提出来
较少文件夹较多文件夹import osimport shutilfrom PIL import Imageimport numpy as np#判定两个文件夹内的文件是否相同file_path1= './3-concreteCrackSegmentationDataset/rgb/' #已知 内容较少的文件夹file_path2 = './3-concreteCrackSegmentationDataset/BW/'f1 = []f2 = []for filename in os原创 2021-12-12 15:53:08 · 2901 阅读 · 0 评论 -
python 图像二值化处理
python 图像二值化处理import osfrom PIL import Imageimport shutilfile_path = './5-crack919/mask/'save_path = './5-crack919/mask01/'if not os.path.exists(save_path): os.makedirs(save_path)###二值化for filename in os.listdir(file_path): print(filenam原创 2021-12-12 15:46:25 · 4736 阅读 · 0 评论 -
python按顺序裁剪大图像分割为小图像,并组合
图像裁剪分割后组合裁剪分割代码图像组合裁剪分割代码分辨率3840x2160分辨率1920x1080# -*- coding: utf-8 -*-from PIL import Imageimport osimport cv2crop_w = 1024 #裁剪图像宽度crop_h = 1024 #裁剪图像高度imageDir="./example/images/" #./Original/Images/Labels #原大图像数据saveDir="./exam原创 2021-12-12 15:37:33 · 5093 阅读 · 15 评论 -
python学习(2)显示/保存/转换图片
显示及保存图片显示、保存matplotlibskimage.ioPILRGB与灰度转换matplotlibPIL图像与array(numpy数组)的转化PIL非数组转化数组转化为PIL图像显示、保存matplotlibdirpath = './image/1.jpg'import matplotlib.pyplot as pltimg_plt = plt.imread(dirpath)plt.imshow(img_plt, cmap=plt.cm.binary)plt.show()pl原创 2021-06-12 16:19:19 · 628 阅读 · 1 评论 -
python学习(1)图像数据读取方式
图像数据读取方式一、OpenCV读取图片二、PIL读取图片三、keras读取图片四、skimage读取图片五、matplotlib.image读取图片六、matplotlib.pyplot读取图片一、OpenCV读取图片OpenCV读取的图片,直接就是numpy.ndarray格式,无需转换import cv2dirpath = './image/1.jpg'img_cv = cv2.imread(dirpath)print('img_cv:',img_cv.shape)print('img_原创 2021-06-12 15:17:25 · 1440 阅读 · 1 评论 -
pillow.Image常用操作-图像预处理
pillow.image图片裁剪调整图像大小查看图片格式图片粘贴图像旋转图像水平翻转图像垂直翻转高斯模糊边缘增强找到边缘锐化平滑处理细节pillow.Image常用操作如图片裁剪,旋转,缩放,翻转等技术标签: pillow 图像预处理在Python中import Image包格式如下:from PIL import Imagewidth_rate=random.randint(1,width_rate)/100height_rate=random.randint(1,height_rate)原创 2021-01-06 20:10:37 · 1104 阅读 · 0 评论 -
python的os.path操作所有代码解释
os.path.abspath(path) #返回绝对路径os.path.basename(path) #返回文件名os.path.commonprefix(list) #返回多个路径中,所有path共有的最长的路径。os.path.dirname(path) #返回文件路径os.path.exists(path) #路径存在则返回True,路径损坏返回Falseos.path.lexists #路径存在则返回True,路径损坏也返回Trueos.path.expanduser(path)原创 2020-08-22 22:41:54 · 228 阅读 · 0 评论 -
python中的字符数字之间的转换函数
int(x [,base ]) 将x转换为一个整数long(x [,base ]) 将x转换为一个长整数float(x ) 将x转换到一个浮点数complex(real [,imag ]) 创建一个复数str(x ) 将对象 x 转换为字符串repr(x ) 将对象 x 转换为表达式字符串eval(str ) 用来计算在字符串中的有效Python表达原创 2020-08-22 12:15:35 · 163 阅读 · 0 评论 -
Python3.0中的OSError: [Errno 22] Invalid argument: ‘D:\\pytorch\\crop\test\\list1.
在Python中想打开文件,发现出现OSError: [Errno 22]错误。于是查资料发现树上是这么写的f=open(r‘D:\pytorch\crop\test\list1.txt’)突然觉着不对啊,之前看的一些文章好像是这么写的f=open(‘D:\pytorch\crop\test\list1.txt’)上网找资料,居然是转义字符在作怪。。。。。。于是改成f=open(‘D:/pytorch/crop/test/list1’)成功运行~所以,以后还是老实的用/不要用\\咯.原创 2020-08-17 21:12:34 · 693 阅读 · 1 评论 -
python random 的用法
python random 常用的几个import random源码PYTHON RANDOM模块(获取随机数)常用方法使用例子python random的里面的方法其实是Random实例化的对象。常用的几个import randomprint( random.randint(1,10) ) # 产生 1 到 10 的一个整数型随机数 print( random.random() ) # 产生 0 到 1 之间的随机浮点数print( random.un原创 2020-08-15 16:04:41 · 2754 阅读 · 0 评论 -
python中的__init__
作者:追远·J 链接:https://www.zhihu.com/question/46973549/answer/767530541来源:知乎 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。作为典型的面向对象的语言,Python中类的定义和使用是不可或缺的一部分知识。对于有面向对象的经验、对类和实例的概念已经足够清晰的人,学习Python的这套定义规则不过是语法的迁移。但对新手小白而言,要想相对快速地跨过__init__这道坎,还是结合一个简单例子来说比较好。以创建一个“学生.原创 2020-08-07 16:36:53 · 261 阅读 · 0 评论 -
python内置函数format
python内置函数format基本语法format 函数可以接受不限个参数,位置可以不按顺序。如:"{1} {0} {1}".format(“hello”, “world”) 输出结果为“'world hello world”。format使用举例print("{:.2f}".format(3.1415926))输出结果为:3.14...原创 2020-08-07 15:15:18 · 533 阅读 · 0 评论 -
报错TabError: Inconsistent use of tabs and spaces in indentation
TabError: Inconsistent use of tabs and spaces in indentation首先这个错误的意思是:在缩进的时候,使用了错误的空格和tab我使用的python3.6,造成这个错误的原因是我在网上复制代码后,残生了错位或者其他原因,也就是说,这种错误产生的原因正是由于空格或者tab缩进造成的。然后我做了试验,将空格删除,直接使用tab完成缩进,发现程序正常运行;再试一下空格缩进,然后发现还是报错了,同样TabError: Inconsistent use原创 2020-07-17 16:46:06 · 6762 阅读 · 0 评论 -
python语言:split()方法
含义:先用baisplit(’.’)方法将字符串以"."开割形成一个字符串数组du,然后再通zhi过索引[1]取出所得数组中的第二dao个元素的值。思路解析:split()方法是将指定字符串按某指定的分隔符进行拆分,拆分将会形成一个字符串的数组并返回。数组中的每元素都各自对应一个索引值,就好比在数据库的表中每行数据纪录都拥有自己的索引ID一样数组元素的索引值是从0开始计数的,也就是说第一个元素的索引值是0,往后依次加1。我们可以用数组的索引值来取对应位置的数组元素的值,比如说我们要取数组的第一个“a原创 2020-07-17 16:40:56 · 5441 阅读 · 0 评论 -
报错/usr/bin/pip: No such file or directory
解决/usr/bin/pip: No such file or directory问题描述:因为home的空间不足,所以我将anaconda3文件夹移动到了别的位置上了,导致我在命令行中输入python的命令时,显示的是python2.7(也就是linux自带的),后面我又为anaconda3重新配置了环境变量,然后当我想使用pip命令去安装别的库时,则显示:/usr/bin/pip: No such file or directory如何解决:执行以下命令:sudo apt-get remove原创 2020-07-17 16:27:16 · 2514 阅读 · 0 评论 -
深度学习论文查代码
https://paperswithcode.com/原创 2020-05-16 19:26:27 · 280 阅读 · 0 评论 -
python(4)python基本概念
python基本概念0.Python 解释器:1.Python数据结构:2.变量与运算符:3. 流程控制4.文件5.输入输出6.异常7.函数和模块8.面向对象编程9.多线程10.标准库11.第三方案0.Python 解释器:1.Python数据结构:2.变量与运算符:3. 流程控制4.文件5.输入输出6.异常7.函数和模块8.面向对象编程9.多线程10.标...原创 2020-01-16 16:52:00 · 161 阅读 · 1 评论 -
python(3)通过pillow识别动态验证码
生活中,我们在登录微博,邮箱的时候,常常会碰到验证码。在工作时,如果想要爬取一些数据,也会碰到验证码的阻碍。本次试验将带领大家认识验证码的一些特性,并利用 Python 中的 pillow 库完成对验证码的破解。原创 2020-01-14 11:28:33 · 1619 阅读 · 0 评论 -
python(2)中文编码乱码问题
python(2)中文编码乱码问题一、什么是字符编码。1.ASCII2.GB23123.Unicode4.UTF-8二、Python2中的字符编码三、decode()与encode()方法四、一个字符编码的例子**前言:**中文编码问题一直是程序员头疼的问题,而Python2中的字符编码足矣令新手抓狂。本文将尽量用通俗的语言带大家彻底的了解字符编码以及Python2和3中的各种编码问题。一...原创 2020-01-11 15:08:56 · 5940 阅读 · 4 评论 -
Python(1) os.listdir() 方法
概述os.listdir() 方法用于返回指定的文件夹包含的文件或文件夹的名字的列表。它不包括 . 和 … 即使它在文件夹中。只支持在 Unix, Windows 下使用。语法listdir()方法语法格式如下:os.listdir(path)参数path – 需要列出的目录路径返回值返回指定路径下的文件和文件夹列表。实例以下实例演示了 listdir() 方...原创 2020-01-10 21:40:52 · 248 阅读 · 0 评论 -
python插件(1)Matplotlib
Matplotlib是Python的一个绘图库,是Python中最常用的可视化工具之一,可以非常方便地创建2D图表和一些基本的3D图表。它以各种硬复制格式和跨平台的交互式环境生成出版质量级别的图形。通过Matplotlib,开发者可能仅需要几行代码,便可以生成绘图、直方图、功率谱、条形图、错误图、散点图等。它提供了一整套和Matlab相似的命令API,十分适合交互式地进行制图。而且也可以方便地...原创 2020-01-09 15:26:33 · 683 阅读 · 0 评论