mat file using jpeg files !

조회 수: 1 (최근 30일)
MohChawki
MohChawki 2019년 6월 20일
댓글: Jan 2019년 6월 21일
hello
i have dataset containe 13000 images JPEG ;
my goal is to create .mat file using this pictures with sames names of all original pictures.
ie. i can get image that named Fer.jpeg in my original dataset from .mat file directly
if any one have ideas or can help me i will be very thankfull ......
  댓글 수: 1
Rik
Rik 2019년 6월 20일
Have a read here and here. It will greatly improve your chances of getting an answer.
Also, with any size image that is not tiny, it will probably be a bit tricky to put everything together in one file.

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

답변 (1개)

Chinmay Anand
Chinmay Anand 2019년 6월 21일
Files = dir('./Images'); % Your images are saved in Images folder in current directory
for i=3:length(Files) % Loop starting from 3 to ignore . and .. generated from above in Files
imgFile = Files(i).name;
img = imread(imgFile);
save(string(imgFile(1:end-5)) + '.mat','img') % Saving files in current directory
end
  댓글 수: 1
Jan
Jan 2019년 6월 21일
And if you cannot be sure, that the extension is '.jpeg' in all cases:
Files = dir('./Images'); % Your images are saved in Images folder in current directory
Files([File.isdir]) = []; % It is not documented, that . and .. are the 1st two elements
for k = 1:numel(Files) % Loop starting from 3 to ignore . and .. generated from above in Files
imgFile = Files(i).name;
[~, imgName] = fileparts(imgFile);
img = imread(imgFile);
save([imgName, '.mat'], 'img'); % Saving fileas MAT in current directory
end

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

카테고리

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