i have to read files in specific folder

first thing i have to select files a folder
then i have to read jpg
in that folder
how can i do that
i tried with below code
but i cant get the count
test_image = uigetdir('F:\R Project\');
mat = dir ('*.jpg')

Respuestas (1)

Bob Thompson
Bob Thompson el 14 de Feb. de 2019

0 votos

You need to specify the path that you gathered with 'test_image', otherwise the dir command is just going to search the current directory.
test_image = uigetdir('F:\R Project\');
mat = dir([test_image,'\*.jpg']);

5 comentarios

OriAlpha
OriAlpha el 14 de Feb. de 2019
i tried this one but mat doesnt read jpg files
its value is zero
OriAlpha
OriAlpha el 14 de Feb. de 2019
hello
i have just fixed that issue but if i want to load image
i am having error
mat = dir(uigetdir ( 'F:\R Project\Frames\' )), '\ *. jpg';
for r=1:length(mat)
load(mat(r).name');
i cant load images
Bob Thompson
Bob Thompson el 15 de Feb. de 2019
What is the error message you're getting?
OriAlpha
OriAlpha el 15 de Feb. de 2019
Editada: OriAlpha el 15 de Feb. de 2019
Cannot open file "." for reading. You might not have read permission.
Error in imread (line 340)
fullname = get_full_filename(filename);
Error in sample (line 11)
im = imread(test_image1);
Bob Thompson
Bob Thompson el 15 de Feb. de 2019
It seems that the mat file isn't gathering the correct file name, so it is unable to load. I would suggest doing some more robust debugging of your own. Check things like making sure you don't have double slashes in your directory name, or aren't missing a slash. Try copying the name directly from file explorer and loading it directly, rather than having matlab generate the name reactively.

Iniciar sesión para comentar.

Categorías

Más información sobre File Operations en Centro de ayuda y File Exchange.

Preguntada:

el 14 de Feb. de 2019

Comentada:

el 15 de Feb. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by