Convert a sequence of PNG into JPG with imwrite

34 visualizaciones (últimos 30 días)
Nicola Caldognetto
Nicola Caldognetto el 21 de Nov. de 2017
Respondida: Image Analyst el 21 de Nov. de 2017
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

Respuestas (1)

Image Analyst
Image Analyst el 21 de Nov. de 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

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by