In a folder containing images (bmp,tif etc.) I have to keep the names and the color type of each one and save them in a matrix. My question is if that is possible. I want to save the name member of the struct that has been created by using 'dir' to access the files into an array, then by using 'imfinfo' to take the color type of each image and then save them into an 2xN matrix.

 채택된 답변

Jan
Jan 2017년 11월 10일

0 개 추천

You need a cell matrix to store the strings of different lengths:
FileList = dir(fullfile(Folder, '*.*'));
nFile = numel(FileList);
Output = cell(nFile, 2);
for iFile = 1:nFile
File = fullfile(Folder, FileList(iFile).name);
Info = iminfo(File);
Output{iFile, 1} = File;
Output{iFile, 2} = Info.ColorType;
end

댓글 수: 1

Angelos Naoum
Angelos Naoum 2017년 11월 12일
Thank you very much for your answer, it was very helpful.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

질문:

2017년 11월 10일

댓글:

2017년 11월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by