Convert a sequence of PNG into JPG with imwrite

34 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Image Analyst
Image Analyst il 21 Nov 2017
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

Categorie

Scopri di più su Convert Image Type in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by