当前位置:网站首页>matlab实现对图像批量重命名
matlab实现对图像批量重命名
2022-06-23 22:18:00 【HH~LL】
在实验过程中,图片命名不规范,可能会给我们后续处理数据带来很大的麻烦,因为一般程序从文件夹读取图像先按图片命名读取的,如果是1000张图像,从1开始命名,即1——1000,读取顺序并不是1 2 3…,而是1 10 11 12 …100会先读取1开头的 再读取2开头的,相当于乱序读取。所以有必要对图像规范命名。
如果图片总数大于1000,可以修改内层for循环里面的条件和0的个数
file_path1='待批量命名图像文件夹';
file_path2='命名之后图片保存的文件夹';
img_path_list = dir(strcat(file_path1,'*.png'));%获取该文件夹中所有jpg格式的图像
img_num = length(img_path_list);%获取图像总数量
if img_num > 0 %有满足条件的图像
for j = 1:img_num %逐一读取图像
image_name_old = img_path_list(j).name;% 图像名
if j<10
image_name_new = strcat('000',num2str(j),'.png');
image = imread(strcat(file_path1,image_name_old));
imwrite(image,strcat(file_path2,image_name_new))
elseif j>=10 && j<100
image_name_new = strcat('00',num2str(j),'.png');
image = imread(strcat(file_path1,image_name_old));
imwrite(image,strcat(file_path2,image_name_new))
elseif j>=100
image_name_new = strcat('0',num2str(j),'.png');
image = imread(strcat(file_path1,image_name_old));
imwrite(image,strcat(file_path2,image_name_new))
end
end
end
边栏推荐
- The lower left corner of vs QT VTK displays the synchronized minor coordinate axis
- Inftnews | where should the future of the creator economy go in the Web3 world?
- CTF go topic recurrence
- [Xilinx ax7103 microbalze Learning Notes 6] MicroBlaze custom IP core packaging experiment
- 在OpenCloudOS使用snap安装.NET 6
- Graph theory (tree diameter)
- AutoCAD -- summarize three methods of drawing rounded corners in CAD
- Postman return value Chinese garbled????
- PMP考试相关计算公式汇总!考前必看
- 图论(树的直径)
猜你喜欢

2018/GAN:Self-Attention Generative Adversarial Networks自我注意生成对抗网络

《德阳市餐饮服务业油烟污染防治管理办法(征求意见稿)》之创新油烟监管

Telecommuting: how to become a master of time management| Community essay solicitation

三维向量场中的通量

Nlog详解

How to index websites in Google

嵌入式接口之TIM定时器与NVIC的STM32模板库函数的一些解释
![入参参数为Object,但传递过去却成了[object object] 是因为需要转为JSON格式](/img/8c/b1535e03900d71b075f73f80030064.png)
入参参数为Object,但传递过去却成了[object object] 是因为需要转为JSON格式

Inftnews | where should the future of the creator economy go in the Web3 world?

Can the characteristics of different network structures be compared? Ant & meituan & NTU & Ali proposed a cross architecture self supervised video representation learning method CaCl, performance SOTA
随机推荐
6 大完整开源项目,一次学个够
在OpenCloudOS使用snap安装.NET 6
[Xilinx ax7103 microbalze Learning Notes 6] MicroBlaze custom IP core packaging experiment
List中subList的add造成的死循环
STM32------ADC(电压检测)
To ensure the safety of groups with special difficulties, Guangzhou Civil Affairs made every effort to do a good job in the three prevention work
Construction of cache stack FIFO in different application scenarios for PLC data operation series (detailed algorithm explanation)
Avoid confusion when switching between arouter components
Analysis of Alibaba cloud Tianchi competition -- prediction of o2o coupon
Telecommuting: how to become a master of time management| Community essay solicitation
iNFTnews | 创造者经济的未来在Web3世界中该去向何处?
Setting method of bar code local segment data variable
数字物业管理成趋势,传统物业公司如何通过转型实现数字化蝶变?
AUTOCAD——总结CAD画圆角的三种方式
高仿書旗小說 Flutter 版,學起來
Grpc security -2: fast implementation of server-side JWT authentication
Idea automatically generates unit tests, doubling efficiency!
【Xilinx AX7103 MicroBalze学习笔记6】MicroBlaze 自定义 IP 核封装实验
How to index websites in Google
微信录制视频转圈效果如何实现?