how to read multiple images and calculate mean?

12 ビュー (過去 30 日間)
gurpreet kaur
gurpreet kaur 2014 年 10 月 25 日
コメント済み: sonia carole 2015 年 12 月 8 日
i want to input multiple images from a folder and then find mean image of those images?
  2 件のコメント
Geoff Hayes
Geoff Hayes 2014 年 10 月 25 日
The reading of the multiple images from a folder should be straightforward, but you may want to clarify what you mean by find mean images of those images? Does each image have the same dimension? Are all in colour (RGB) or grayscale?
gurpreet kaur
gurpreet kaur 2014 年 10 月 25 日
i am working on face recognition and i want to calculate the mean of three face images. yes each image have same dimension as 92x112. images are grayscale

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

採用された回答

Mohammad Abouali
Mohammad Abouali 2014 年 10 月 25 日
編集済み: Mohammad Abouali 2014 年 10 月 25 日
There are two options:
1) If you don't have "Computer Vision Toolbox"
Then read the images as follow:
for i=1:nImages
imgSet{i}=imread(imageFilename{i});
end
where imageFilename store the path and file name to your images.
then you can calculate the mean of each image as follow
meanEachImage=cellfun(@(x) mean(x(:)), imgSet);
then mean of all images is:
meanImages=mean(meanEachImage);
you can combine the last to command into one command of course.
2) If you have "Computer Vision Toolbox"
first creat a imageSet as follow
imgSet=imageSet('Path to the folder containing all your images.')
then get the mean of each image as follow:
nBand=1;
meanEachImage=arrayfun(@(x) mean(reshape(imgSet.read(x),[],nBand)), (1:imgSet.Count)','UniformOutput',false);
then you can get the mean of all images by
meanImages=mean(cell2mat(meanEachImage));
The difference between this approach and the other one is that the first approach you load all your images in the memory, but in the second one you just load them one by one. So pretty much one image at a time is in the memory.
Although you can convert the first approach so that you only load one image at a time. Some thing like this would work
nBand=1
meanEachImage=cellfun(@(x) mean(reshape(imread(imageFilename{x}),[],nBand)), (1:nImage)','UniformOutput',false);
This would also load each image one by one and take the mean.
  5 件のコメント
Image Analyst
Image Analyst 2015 年 12 月 7 日
sonia carole
sonia carole 2015 年 12 月 8 日
yes i have visited this page here it is my file there is a lot of mismatches i think it is normal do not which method can help to solve it. since it not just to match them but to determine how many percent the current image has reference features code
%read the first image from the image set I=read(imgSet,1); %Initialize features for I(1) queryImage=rgb2gray( imresize(I,[300 300])); points=detectSURFFeatures(queryImage); strongest1=selectStrongest(points,20); [features,points]=extractFeatures(queryImage,strongest1); tforms(imgSet.Count) = projective2d(eye(3)); %Iterate over remaining images for i=2:imgSet.Count querypoints=points; queryfeatures=features; %read I(n_). I=read(imgSet,i); %detect and extract SURF features for I(n) grayImage=rgb2gray(imresize(I,[300 300])); points=detectSURFFeatures(grayImage); strongest2= selectStrongest(points,20); [feature,validpoints]=extractFeatures(grayImage,strongest2); detectfeatures=feature; detectpoints=validpoints; %find correspondences between queryImage and the rest of the images indexpairs=matchFeatures(queryfeatures,detectfeatures,'Unique',true); matchedPoints=querypoints(indexpairs(:,1),:); matchPointPrev=detectpoints(indexpairs(:,2),:); %figure;ax =axes; %showMatchedFeatures(queryImage,grayImage,matchedPoints,matchPointPrev,'montage','Parent',ax); %[tform ,inliersdetectpoints,inliersquerypoints]=... %estimateGeometricTransform(matchedPoints,matchPointPrev,'affine'); %figure; %showMatchedFeatures(queryImage,grayImage,inliersquerypoints,inliersdetectpoints,... %'montage');

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by