Convert a sequence of PNG into JPG with imwrite

25 ビュー (過去 30 日間)
Nicola Caldognetto
Nicola Caldognetto 2017 年 11 月 21 日
回答済み: Image Analyst 2017 年 11 月 21 日
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

回答 (1 件)

Image Analyst
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

カテゴリ

Help Center および File ExchangeRead, Write, and Modify Image についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by