how to read multiple images and calculate mean?
12 次查看(过去 30 天)
显示 更早的评论
i want to input multiple images from a folder and then find mean image of those images?
2 个评论
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?
采纳的回答
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
2015-12-7
sonia, see "Feature Matching" on this page: http://www.mathworks.com/products/computer-vision/features.html#object-tracking-and-motion-estimation
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 Exchange 中查找有关 Image Processing and Computer Vision 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!