How to save save split images in multiple filenames?

I have a code which shows the multiple images of a scanned *.tif document.
for i=1:5
d=imshow(imread('gi2.tif',i));
figure;
end
I need to save these images as multiple files. I used the following code for that:
basename='im_'
for i=1:5
d=imshow(imread('gi2.tif',i));
figure;
filename=[basename,num2str(i)];
end
But the code is just creating a variable filename with data im_5. I also tried using "sprintf" using the following code:
for i=1:5
d=imread('gi2.tif',i));
filename=sprintf('im_%d.jpg',i)
end
But this basically prints the filename im_<no.> and nothing else.
Please support!!

 Respuesta aceptada

Alex Mcaulley
Alex Mcaulley el 27 de Feb. de 2019
That solves your problem?
for i=1:5
imwrite(imread('gi2.tif',i),['im_' num2str(i) '.tif']);
end

1 comentario

Thank you very much. Issue Resolved. Thanks for the quick support!! :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Images en Centro de ayuda y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by