How to convert images folder to .mat

10 visualizzazioni (ultimi 30 giorni)
abdullah al-dulaimi
abdullah al-dulaimi il 12 Lug 2022
I have this path ('C:\Users\hp\Desktop\testing\abood'), and i want to convert all images in this path to .mat file

Risposte (1)

KSSV
KSSV il 12 Lug 2022
Modificato: KSSV il 12 Lug 2022
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 Commenti
KSSV
KSSV il 12 Lug 2022
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 il 24 Set 2022
I have been searching for the same context to my work . Thank you very much . its working .

Accedi per commentare.

Categorie

Scopri di più su Software Development Tools in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by