当前位置:网站首页>学习笔记_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
边栏推荐
- 配置网络接口的“IP“命令
- 杰理之开关降噪语音识别没有用【篇】
- Detailed explanation of Oracle's windowing function
- Construction and practice of full stack code test coverage and use case discovery system
- 2022-08-08 mysql慢SQL-Q18-10GB数据量-mysql/innodb测试
- Alibaba Cloud Tianchi Contest Question (Machine Learning) - Prediction of Industrial Steam Volume (Complete Code)
- Query the size of the total points obtained in a certain time period to sort
- 2022 Security Officer-A Certificate Special Work Permit Exam Question Bank and Online Mock Exam
- `英语` 2022/8/8
- 「竞品分析报告」不会写?不知从哪收集数据?请收下这篇竞品指南
猜你喜欢
随机推荐
simple math formula calculation
TASSEL软件导入plink格式文件报错
337. Robbery III
稳定性测试怎么做,这篇文章彻底讲透了!
LeetCode - remove consecutive nodes with a sum of zero from a linked list
JVM学习——1——虚拟机基础概念
MySql.Data.MySqlClient.DBNull
MySQL:意向共享锁和意向排它锁 | 死锁 | 锁的优化
LeetCode题解—15.三数之和
阿里云天池大赛赛题(机器学习)——天猫用户重复购买预测(完整代码)
遗传力缺失的案例
2022高压电工考试试题及答案
串扰与防护
使用ceph-deploycep集群部署,并用3个磁盘作为专用osd
【暑期每日一题】洛谷 P1216 [USACO1.5][IOI1994]数字三角形 Number Triangles
ceph创建存储池,映射,删除练习
union
杰理之手机OTG问题【篇】
“error“: { “root_cause“: [{ “type“: “circuit_breaking_exception“, “reason“: “[parent] D【已解决】
软件质效领航者 | 优秀案例•东风集团DevOps改革项目