How to convert images folder to .mat

조회 수: 9 (최근 30일)
abdullah al-dulaimi
abdullah al-dulaimi 2022년 7월 12일
댓글: Bhagavathula Meena 2022년 9월 24일
I have this path ('C:\Users\hp\Desktop\testing\abood'), and i want to convert all images in this path to .mat file
  댓글 수: 1
Debadipto
Debadipto 2022년 7월 12일
Please refer to this answer. Hope this helps.

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

답변 (1개)

KSSV
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
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
Bhagavathula Meena 2022년 9월 24일
I have been searching for the same context to my work . Thank you very much . its working .

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

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by