How to convert images folder to .mat
조회 수: 8 (최근 30일)
이전 댓글 표시
I have this path ('C:\Users\hp\Desktop\testing\abood'), and i want to convert all images in this path to .mat file
답변 (1개)
KSSV
2022년 7월 12일
편집: KSSV
2022년 7월 12일
thepath = 'C:\Users\hp\Desktop\testing\abood' ;
imgFiles = dir([thepath,'\*jpg']) ; % give your image extension
N = length(imgFiles) ;
for i = 1:N
imgFile = fullfile(imgFiles(i).folder,imgFiles(i).name) ;
I = imread(imgFile) ;
[filepath,name,ext] = fileparts(imgFile) ;
fname = [thepath,filesep,name,'.mat'] ;
save(fname,'I')
end
댓글 수: 7
KSSV
2022년 7월 12일
thepath = 'C:\Users\hp\Desktop\testing\abood' ;
imgFiles = dir([thepath,'\*jpg']) ; % give your image extension
N = length(imgFiles) ;
I = cell(N,1) ;
for i = 1:N
imgFile = fullfile(imgFiles(i).folder,imgFiles(i).name) ;
I{i} = imread(imgFile) ;
end
fname = [thepath,'myFile','.mat'] ;
save(fname,'I')
Bhagavathula Meena
2022년 9월 24일
I have been searching for the same context to my work . Thank you very much . its working .
참고 항목
카테고리
Help Center 및 File Exchange에서 Software Development Tools에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!