MEAN OF IMAGE IN MATLAB

3 次查看(过去 30 天)
Aybüke Ceren Duran
编辑: Rik 2019-4-24
format compact
%Firstly, I converted all the images in the vector form.
whereImagesReside = 'lfwdataset';
%dir function will return the images in a structure array.
listOfImages= dir(fullfile(whereImagesReside, '*.pgm'));
%0x1 structure array is created
data = cell(size(listOfImages));
%pmg files are stored in column matrix columnMatrix in the end of the loop
%below
for k=1:numel(listOfImages)
data{k}=imread(fullfile(whereImagesReside, listOfImages(k).name));
%data{k}=im2double(rgb2gray(data{k}));
[r,c] = size(data{k}); % get number of rows and columns in image
%columnMatrix(:,k)=data(:);
V{k}=data(:);
end
%So, data cell array holds the intensity of each gray image.
%intensity = cellfun(@imshow, data, 'uniform', 0);
%disp(intensity);
How can I take the mean of image?
  1 个评论
Rik
Rik 2019-4-24
This time I edited your question for you. Next time, please use the tools explained on this page to make your question more readable.

请先登录,再进行评论。

回答(1 个)

Rik
Rik 2019-4-24
编辑:Rik 2019-4-24
If your list of images is a 0x1 struct, then the files are not found. Once you solve that issue, you can use the code below to find the intensity. Note that storing the full image may require a lot of memory, so you may consider skipping that.
data = cell(size(listOfImages));
intensity = zeros(size(listOfImages));
for k=1:numel(listOfImages)
data{k}=imread(fullfile(whereImagesReside, listOfImages(k).name));
intensity(k)=mean(data{k}(:));%mean will convert your data type to double
end

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by