フィルターのクリア

How to load images from variable

3 ビュー (過去 30 日間)
Lukas
Lukas 2014 年 2 月 14 日
コメント済み: Image Analyst 2014 年 2 月 15 日
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

回答 (1 件)

Image Analyst
Image Analyst 2014 年 2 月 14 日
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 件のコメント
Lukas
Lukas 2014 年 2 月 14 日
編集済み: Image Analyst 2014 年 2 月 15 日
ok a did it..som simple...
imageArray = imread(fullFileName);
** *x{k}=imageArray;* **
imshow(imageArray); % Display image.
still, thank you :)
Image Analyst
Image Analyst 2014 年 2 月 15 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by