필터 지우기
필터 지우기

Splitting and Saving multiple images

조회 수: 1 (최근 30일)
Eberechi ICHI
Eberechi ICHI 2021년 3월 24일
편집: Jan 2021년 3월 24일
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

채택된 답변

Jan
Jan 2021년 3월 24일
편집: Jan 2021년 3월 24일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by