当前位置:网站首页>学习笔记_numpy图片基本操作_自用
学习笔记_numpy图片基本操作_自用
2022-08-09 04:43:00 【free_luojing】
场景一: 图片中选取部分区域
#提取原图片H(0-300),W(0-500)区域
img_region=img[0:300,0:500]
备注:opencv中,读取img.shape=(H,W,3),第一个数是高,第二个是宽
场景二: 循环把文件夹里的图片读取出来,并把图片路径写进一个数组里
import os
#建立一个空的数组
img_path=[]
path="cropmin/image"
for filename in os.listdir(path):
#拼接图片路径的两种方式
imagepath=path+"\\"+filename
imagepath2=os.path.join(path,filename)
img_path.append(imagepath)
print("img_path",img_path)
场景三: 把归一化之后的图片,转换成对应的二值图
在一分类的语义分割模型,模型输出的是归一化后的数据,保存后只能看到一片黑
x=np.array([[0.1,0.5,0.7],[0.1,0.6,0.7]])
out_ = np.where(x > 0.5, 255, 0).astype('uint8')
#输出为[[ 0 0 255]
[ 0 255 255]]
语义分割中输出的output往往是四维的,(1,1,2,3)
第一个1是batchsize,第二个1是类别
y=np.array([[[[0.1,0.5,0.7],[0.1,0.6,0.7]]]])
print(y.shape)
for i in range(y.shape[0]):
for j in range(y.shape[1]):
out_ = np.where(y[i,j] > 0.5, 255, 0).astype('uint8')
print("out_",out_)
np.where(condition,x,y),满足条件,输出x,否则输出y
边栏推荐
- MySQL: redo log log - notes for personal use
- 分布式数据库怎样才能“叫好又卖座”
- 2022 Security Officer-A Certificate Special Work Permit Exam Question Bank and Online Mock Exam
- Construction and practice of full stack code test coverage and use case discovery system
- 【暑期每日一题】洛谷 P1200 [USACO1.1]你的飞碟在这儿Your Ride Is Here
- Disappearance of heritability - wiki
- Ali YunTianChi competition problem (deep learning) - video enhancement (complete code)
- Alibaba Cloud Tianchi Contest Question (Machine Learning) - Prediction of Industrial Steam Volume (Complete Code)
- JVM垃圾回收机制简介
- 基因对疾病的影响规律--读论文
猜你喜欢
随机推荐
做现货白银前这些要诀应先记起来
全栈代码测试覆盖率及用例发现系统的建设和实践
特征工程实战篇
抖音直播带货的4个技巧,提升直播间转化率!
etcd学习笔记 - 入门
单根k线图知识别以为自己都懂了
ABP中的数据过滤器
人类微生物组和缺失遗传力--读论文
使用ceph-deploycep集群部署,并用3个磁盘作为专用osd
MySQL:意向共享锁和意向排它锁 | 死锁 | 锁的优化
TCP/IP协议中分包与重组原理介绍、分片偏移量的计算方法、IPv4报文格式
串扰与防护
Oracle 的开窗函数使用详解
自动化测试-图片中添加文字注释,添加到allure测试报告中
2022年安全员-A证特种作业证考试题库及在线模拟考试
阿里云天池大赛赛题(机器学习)——天猫用户重复购买预测(完整代码)
Flask框架实现异步处理请求
`英语` 2022/8/8
JVM垃圾回收机制简介
Efficient review of deep learning DL, CV, NLP









