I want to do the same action to every files(.png) in one folder, but I face some problem.
1 回表示 (過去 30 日間)
古いコメントを表示
I want to put 1092 files(109 x 109 .png image) in the center of 227 x 227 matrix, so I write down a code like this
files = dir('*.png') ; % I am in folder of the png files
N = length(files) ; % total number of files
% loop for each file
for i = 1:N
x = files(i).name ;
b=imread('x');
a=zeros(227);
a(60:168,69:159)=b;
a=uint8(a);
end
end
answer
Error using imread>get_full_filename (line 516)
File "x" does not exist.
Error in imread (line 340)
fullname = get_full_filename(filename);
How can I process all my files in the folder, and save as .png in a new folder ?
採用された回答
Image Analyst
2019 年 10 月 19 日
Try the padarray() function.
Or if you want to do it by indexing:
baseFileName = files(i).name ;
b=imread(baseFileName);
a=zeros(227, 227, 'uint8'); % Add class and get rid of a=uint8(a); line of code
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!