![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
代码
垃圾程序
久居,心会凉
这个作者很懒,什么都没留下…
展开
-
排序问题一归并排序
三指针归并排序 归并排序一般是两个链表合成第三个链表,比较典型,直接用归并排序法设置三个指针,前两个分别是要合的链表,第三个是要合成的链表 在这里插入代码片 def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: m = ListNode(0) l = m while l1 and l2: if l1.val > l2.原创 2021-09-16 16:29:38 · 89 阅读 · 0 评论 -
pillow读取txt文档在图片中画框写字
import cv2 from PIL import Image, ImageDraw from PIL import ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True Image.MAX_IMAGE_PIXELS = None tifpath = './result/result_0.tif' tif = './result/a.tiff' img = cv2.imread(tifpath) def rawimage_box(txt): i原创 2021-04-26 20:08:55 · 271 阅读 · 0 评论 -
利用阈值法提取指定区域并保存
利用阈值法提取指定区域并保存 import os import cv2 import numpy as np from PIL import Image def green_detect( greenpath ): dirs = os.listdir(greenpath) for file in dirs: img = greenpath + '/' + file img1 = cv2.imread(img, 0) ret, thresh1原创 2021-04-12 16:58:28 · 382 阅读 · 1 评论 -
python cv2利用txt文件再图像中画框,显示文本
python利用txt文件再图像中画框,显示文本 import cv2 import os import numpy as np a='a'+'\n' tifpath = r'F:\test_img\trans.tif' txt = r'F:\test_img\test.txt' img = cv2.imread(tifpath) '''with open(r'F:\test_img\text2.txt','w') as f: #f.write(a, 'a') for i in range(原创 2021-03-18 21:55:08 · 897 阅读 · 0 评论 -
大图中画框裁剪子图,子图裁剪固定大小小图,小图大小不足填充至需要大小
实验室项目需要在一幅大遥感图像中手动选择区域传入目标检测网络,写了点小代码。 首先利用matplotlib和PIL选出裁剪区域,生成crop子图,再利用numpy填充至需要的大小,再进行裁剪(指定大小),因为填充过了,不会存在大小不合规范。 在这里插入代码片 ```import numpy as np from PIL import ImageFile from PIL import Image ImageFile.LOAD_TRUNCATED_IMAGES = True Image.MAX_IMAGE_P原创 2021-06-09 11:40:56 · 225 阅读 · 0 评论 -
python在图片中利用二值化提取指定像素大小的轮廓
python在图片中利用二值化提取指定像素大小的轮廓 import cv2 import os #设置检测图片区域像素大小 def area_dect(img,file): img1 = cv2.imread(img, 0) # 1.进行阈值二值化操作,大于阈值30的,使用255表示, 小于阈值127的,使用0表示 ret, thresh1 = cv2.threshold(img1, 30, 255, cv2.THRESH_BINARY) contours, hierarc原创 2021-03-18 21:51:39 · 1555 阅读 · 0 评论