Splitting and Saving multiple images

2 vues (au cours des 30 derniers jours)
Eberechi ICHI
Eberechi ICHI le 24 Mar 2021
Modifié(e) : Jan le 24 Mar 2021
Hello,
Please i am trying to save multile images generated by the code.
I want the number of the image to start from 1 but its starting from 16.
Can someone out there please help.
new_I=imresize(I,[381,3041]);
S=190;
m=2;
n=16;
for j = 1:m
for i = 1:n
row1 = (j-1)*S+1 ;
row2 = row1 + S ;
col1 = (i-1)*S+1 ;
col2 = col1+S;
PR_NB = new_I (row1:row2 , col1:col2, :);
base_name = sprintf('%s_%i.jpg',char(org_name(end)),n);
full_name = fullfile (newfol, base_name);
fprintf('Saving %s\n', char(full_name));
imwrite( PR_NB, char(full_name)) ;
n=(n+1)
end
end
Thanks

Réponse acceptée

Jan
Jan le 24 Mar 2021
Modifié(e) : Jan le 24 Mar 2021
Then do not use n as counter, but another one:
iFile = 1;
...
base_name = sprintf('%s_%i.jpg', org_name{end}, iFile);
full_name = fullfile(newfol, base_name);
imwrite( PR_NB, full_name) ;
iFile = iFile + 1;
By the way, you can omit the "char()", because fullname is a char already.

Plus de réponses (0)

Catégories

En savoir plus sur Read, Write, and Modify Image dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by