How do I imread stimuli from a randomised array
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I tried reading stimulus image into matlab matrix but get receiving error message saying the file does not exist. Here is my code:
files = dir('D:\picture\*.jpg'); %folder name is stimuli
trial = 0;
nTrial = 10;
for trial=1:nTrial
stimfilename=strcat('D:\picture\',char(tArray(trial,3))) imdata=imread(char(stimfilename));
end
I ran the above code and it returns stimfilename as D:\picture\J123jpg. However, it vomits an error message
??? Error using ==> imread at 372
File "D:\picture\J123jpg" does not exist.
Please any help will be highly appreciated. Thanks in advance.
Tom
0 comentarios
Respuesta aceptada
Laura Proctor
el 18 de Abr. de 2011
You may wish to try by simplifying the code a bit. Try the following lines to see if you still get the same error message.
files = dir('D:\picture\*.jpg'); %folder name is stimuli
for trial=1:length(files)
stimfilename=['D:\picture\',files(trial).name];
imdata=imread(char(stimfilename));
end
5 comentarios
Laura Proctor
el 20 de Abr. de 2011
The error message shows that the file name is J123jpg, but not J123.jpg as one might expect. Can you go into the directory D:\picture and just try imread('J123.jpg') to see if the image can be read without the other code? If that works, try the following lines:
files = dir('D:\picture\*.jpg');
stimfilename=['D:\picture\',files(1).name]
imdata = imread(stimfilename)
To see if it can read just the first file.
Más respuestas (0)
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!