How to load images from variable

5 visualizaciones (últimos 30 días)
Lukas
Lukas el 14 de Feb. de 2014
Comentada: Image Analyst el 15 de Feb. de 2014
Hello. I used this code to load images from folder to matlab. It worked well, but i don´t know how to load for example 3. and 5.(it doesn´t matter which one) image from imageArray and show it by figure...so how are images indexed in imageArray? please give me some simple example. i am begginer. thank you
myFolder = 'C:\Users\lukino\Pictures\...';
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(myFolder, '*.jpg');
jpegFiles = dir(filePattern);
for k = 1:length(jpegFiles)
baseFileName = jpegFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray = imread(fullFileName);
imshow(imageArray); % Display image.
drawnow; % Force display to update immediately.
end

Respuestas (1)

Image Analyst
Image Analyst el 14 de Feb. de 2014
Look like code from the FAQ. What's the problem? What are examples 3 and 5? imageArray is not indexed. It's overwritten each iteration. You read in that image, process it, and then you're done and you move on to the next image.
  3 comentarios
Lukas
Lukas el 14 de Feb. de 2014
Editada: Image Analyst el 15 de Feb. de 2014
ok a did it..som simple...
imageArray = imread(fullFileName);
** *x{k}=imageArray;* **
imshow(imageArray); % Display image.
still, thank you :)
Image Analyst
Image Analyst el 15 de Feb. de 2014
I would not do it that way as it's wasteful of memory. I'd call a function like AnalyzeSingleImage(imageArray) inside the loop. I don't see any need to read all of the images into a cell array and then you'll just have to have another loop after that to process them all after extracting from "x". I have no idea why you're wanting to save all of these images in an "x" array - it doesn't seem necessary to me.

Iniciar sesión para comentar.

Categorías

Más información sobre Search Path en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by