当前位置:网站首页>Batch renaming of images by MATLAB
Batch renaming of images by MATLAB
2022-06-23 23:52:00 【HH~LL】
During the experiment , Picture naming is not standardized , It may bring us a lot of trouble in subsequent data processing , Because the general program reads the image from the folder first according to the image name , If it is 1000 Zhang image , from 1 Start naming , namely 1——1000, Read order is not 1 2 3…, It is 1 10 11 12 …100 Read first 1 At the beginning Read again 2 At the beginning , It is equivalent to reading out of order . Therefore, it is necessary to name images in a standard way .
If the total number of pictures is greater than 1000, You can modify the inner layer for The conditions in the loop and 0 The number of
file_path1=' Image folders to be named in batch ';
file_path2=' Name the folder where the pictures are saved ';
img_path_list = dir(strcat(file_path1,'*.png'));% Get all... In this folder jpg Format image
img_num = length(img_path_list);% Total number of captured images
if img_num > 0 % There are images that meet the conditions
for j = 1:img_num % Read the images one by one
image_name_old = img_path_list(j).name;% Image 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
边栏推荐
- log Network Execution Time
- MySQL导致索引失效的情况详解
- Math. Max() method obtains the maximum value in the array and returns Nan problem analysis
- 多门店药品进销存系统源码 大型连锁药店管理系统源码
- How to ensure reliable power supply of Expressway
- EF Core中的三类事务(SaveChanges、DbContextTransaction、TransactionScope)
- iNFTnews | 创造者经济的未来在Web3世界中该去向何处?
- Stm32----- timer
- 思考(八十七):协议加密与压缩
- 数据库中索引原理及填充因子
猜你喜欢
随机推荐
微信录制视频转圈效果如何实现?
2018/GAN:Self-Attention Generative Adversarial Networks自我注意生成对抗网络
Stm32-------adc (voltage detection)
工作中一些常用的工具函數
Revit API:明细表 ViewSchedule
Golang 类型断言
这个高仿小米商城项目太惊艳了
Unity Text组件空格换行问题
一款高仿腾讯漫画的漫画阅读类 APP
Multi store drug inventory system source code large chain drugstore management system source code
【 GBASE的那些事儿】系列直播活动第02期《GBase 8s高可用技术及案例分析法》
【Try to Hack】masscan
Niuke.com: the double pointer problem of receiving rainwater
2.摄像机标定
Inftnews | where should the future of the creator economy go in the Web3 world?
Taylor formula and common expansion
One person even broke up a Netease cloud music Cloud Village
开口式霍尔电流传感器助力直流配电改造
思考(八十七):协议加密与压缩
How to take the PMP Exam agile on June 25? Share your troubles









