how to save decomposed sub images/blocks of images into new folder ?

조회 수: 2 (최근 30일)
Naushad Varish
Naushad Varish 2016년 11월 16일
댓글: KSSV 2016년 11월 16일
For example, i have 5 images of size 512*512 and divided these images into 128*128 blocks/subimages. Here i want to store theses sub-images i.e. 16*5=80 into new folder where each image has 16 sub-images. How i can do it with imwrite commond.
Can you please anyone help me to do it. Thank you in advance

채택된 답변

KSSV
KSSV 2016년 11월 16일
편집: KSSV 2016년 11월 16일
% saving the images first
N = 5 ;
for i = 1:N
I = rand(512,512) ;
I1 = reshape(I,128,128,[]) ;
for j = 1:size(I1,3)
filename = strcat(num2str(N),'_',num2str(j),'.png') ;
imwrite(I1(:,:,j),filename) ;
end
end
% To read the images in the folder
F = dir('*.png'); % your extension of images
for ii = 1:length(F)
I = imread(F(ii).name) ;
end
Combine the above codes. I have saved images using random data as of now. you can call the images using the second code.
  댓글 수: 2
Naushad Varish
Naushad Varish 2016년 11월 16일
sir only 16 subimages have been stored instead of 80 subimages, i think images are overwrite from previous one.
KSSV
KSSV 2016년 11월 16일
yes...change this line:
filename = strcat(num2str(N),'_',num2str(j),'.png') ;
to
filename = strcat(num2str(i),'_',num2str(j),'.png') ;

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Import, Export, and Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by