MEAN OF IMAGE IN MATLAB

4 ビュー (過去 30 日間)
Aybüke Ceren Duran
Aybüke Ceren Duran 2019 年 4 月 24 日
編集済み: 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 Center および File ExchangeConvert Image Type についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by