how to store and plot values in a loop?
显示 更早的评论
The code below currently reads in all the jpg images in a file and outputs the average intensity of the imagearray (sum of image matrix), what I am struggling to do, is convert this code so that it measures the intensity of each singular image, stores the value and then plots the change in intensity across all the images.
ImageFolder = 'H:\My Documents\Dissertation';
if ~isfolder(ImageFolder)
ErrorMessage = print('Error: The following folder does not exist: Please specify a new folder.', ImageFolder);
uiwait(warndlg(ErrorMessage));
ImageFolder = uigetdir();
if ImageFolder == 0
return;
end
end
FileType = fullfile(ImageFolder, '*.jpg');
TheImages = dir(FileType);
for k = 1:length(TheImages)
baseFileName = TheImages(k).name;
fullFileName = fullfile(TheImages(k).folder, baseFileName);
if exist(fullFileName,'file')
imageArray = imread(fullFileName);
end
meanIntensity = mean(imageArray(:));
matrix(k) = mean(imageArray(:));
end
plot(k,meanIntensity,'-.x');
hold on
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB Mobile 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!