Convert a sequence of PNG into JPG with imwrite
25 ビュー (過去 30 日間)
古いコメントを表示
I have loaded a sequence of PNG images with
vet_files=dir('RBSvideo/*.png');
for i=1:120
I=imread(sprintf('RBSvideo/%s',vet_files(i).name));
end;
Now i need to convert every image into jpg keeping the name if possible
I have tried with imwrite(I,'compressed.jpg','Quality',QF); but I can't understand how use a for cicle to change everytime image on compressed.jpg
0 件のコメント
回答 (1 件)
Image Analyst
2017 年 11 月 21 日
Try this:
folder = 'RBSvideo';
vet_files=dir(fullfile(folder, '*.png'));
for i=1:120
inputFullFileName = fullfile(folder, vet_files(i).name);
thisImage = imread(fullFileName);
outputFullFileName = strrep(lower(inputFullFileName), '.png', '.jpg');
imwrite(thisImage, outputFullFileName, 'Quality', QF);
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Read, Write, and Modify Image についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!