Convert a sequence of PNG into JPG with imwrite

23 次查看(过去 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

回答(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 CenterFile 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!

Translated by