How to convert images folder to .mat

9 visualizaciones (últimos 30 días)
abdullah al-dulaimi
abdullah al-dulaimi el 12 de Jul. de 2022
Comentada: Bhagavathula Meena el 24 de Sept. de 2022
I have this path ('C:\Users\hp\Desktop\testing\abood'), and i want to convert all images in this path to .mat file
  1 comentario
Debadipto
Debadipto el 12 de Jul. de 2022
Please refer to this answer. Hope this helps.

Iniciar sesión para comentar.

Respuestas (1)

KSSV
KSSV el 12 de Jul. de 2022
Editada: KSSV el 12 de Jul. de 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 comentarios
KSSV
KSSV el 12 de Jul. de 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 el 24 de Sept. de 2022
I have been searching for the same context to my work . Thank you very much . its working .

Iniciar sesión para comentar.

Categorías

Más información sobre Software Development Tools en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by