当前位置:网站首页>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
边栏推荐
- How can wechat video numbers be broadcast live on a PC?
- 2018/GAN:Self-Attention Generative Adversarial Networks自我注意生成对抗网络
- 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
- 一款高仿腾讯漫画的漫画阅读类 APP
- STM32 ------ external interrupt
- smart-doc + Torna 兼容版本
- What is the production process of enterprise website? How long does it take to design and build a website?
- 1004. 最大连续1的个数 III ●●
- 电子元器件行业B2B交易管理系统:提升数据化驱动能力,促进企业销售业绩增长
- Chrome plug-in features and case analysis of actual combat scenarios
猜你喜欢

这个高仿小米商城项目太惊艳了

再来一个高仿开眼的短视频APP
![入参参数为Object,但传递过去却成了[object object] 是因为需要转为JSON格式](/img/8c/b1535e03900d71b075f73f80030064.png)
入参参数为Object,但传递过去却成了[object object] 是因为需要转为JSON格式

CTF go topic recurrence

CVPR2019/图像翻译:TransGaGa: Geometry-Aware Unsupervised Image-to-Image Translation几何感知的无监督图像到图像的翻译

Some explanations of Tim timer of embedded interface and STM32 template library function of NVIC

老龄化下背景下,综合能效管理平台为医院保驾护航

一个人竟然撸了一个网易云音乐云村

7、STM32——LCD

High imitation Book flag novel flutter edition, learn it
随机推荐
1004. number of maximum consecutive 1 III ●●
Solve the problem that slf4j logs are not printed
Avoid confusion when switching between arouter components
Nlog详解
项目中常用到的 19 条 MySQL 优化
Thinking (86): master-slave realization idea
思考(八十六):主从实现思路
Le roman du drapeau de l'imitation haute version flutter, apprenez - le
如何保证高速公路供电可靠
BroadcastReciver 和LocalBroadcastManager区别
【HackTheBox】Fawn
NLog details
Androidkotlin comprehensive and detailed class usage grammar learning guide
2022 Shandong Health Expo, Jinan International Health Industry Expo, China Nutrition and Health Exhibition
【Proteus仿真】T6963C驱动PG12864示例(带中英文显示)
不同物体使用同一材质,有不同的表现
7、STM32——LCD
List中subList的add造成的死循环
AutoCAD -- summarize three methods of drawing rounded corners in CAD
思考(八十七):协议加密与压缩