Azzera filtri
Azzera filtri

Splitting and Saving multiple images

1 visualizzazione (ultimi 30 giorni)
Eberechi ICHI
Eberechi ICHI il 24 Mar 2021
Modificato: Jan il 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

Risposta accettata

Jan
Jan il 24 Mar 2021
Modificato: Jan il 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.

Più risposte (0)

Categorie

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

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by