当前位置:网站首页>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
边栏推荐
- Digital property management has become a trend. How can traditional property companies achieve digital butterfly change through transformation?
- Under the background of aging, the comprehensive energy efficiency management platform escorts hospitals
- List中subList的add造成的死循环
- Unity text component space newline problem
- The digital transformation index report 2021 released by Tencent Research Institute has accelerated the digital transformation and upgrading of mainland enterprises!
- APP性能优化之启动流程分析
- Generate all possible binary search trees
- 关于H5移动端用什么自动化测试
- Loop caused by add of sublist in list
- 2.摄像机标定
猜你喜欢

What are the good solutions for industrial control safety of production line

嵌入式接口复习资料

Generative countermeasure networks (Gans) and variants

High imitation Betta app

docker 部署redis

Task queue of laravel

多门店药品进销存系统源码 大型连锁药店管理系统源码

iNFTnews | 创造者经济的未来在Web3世界中该去向何处?

High imitation Book flag novel flutter edition, learn it

Six complete open source projects, learning enough at a time
随机推荐
一个人竟然撸了一个微博 APP
How to achieve energy-saving and reasonable lighting control in order to achieve the "double carbon" goal
Generative countermeasure networks (Gans) and variants
开口式霍尔电流传感器助力直流配电改造
High imitation Book flag novel flutter edition, learn it
log Network Execution Time
Embedded interface review materials
为实现“双碳”目标,应如何实现节能、合理的照明管控
What are the good solutions for industrial control safety of production line
高仿書旗小說 Flutter 版,學起來
fatal: The upstream branch of your current branch does not match the name of your current branch.
【Proteus仿真】T6963C驱动PG12864示例(带中英文显示)
复原IP地址[标准回溯+标准剪枝]
节流和防抖
不同物体使用同一材质,有不同的表现
思考(八十七):协议加密与压缩
Postman return value Chinese garbled????
1.< tag-动态规划和路径组合问题>lt.62. 不同路径 + lt.63. 不同路径 II
产线工控安全有什么好的解决方案
Classical Chinese can be programmed???