how to read multiple images and calculate mean?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
gurpreet kaur
el 25 de Oct. de 2014
Comentada: sonia carole
el 8 de Dic. de 2015
i want to input multiple images from a folder and then find mean image of those images?
2 comentarios
Geoff Hayes
el 25 de Oct. de 2014
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?
Respuesta aceptada
Mohammad Abouali
el 25 de Oct. de 2014
Editada: Mohammad Abouali
el 25 de Oct. de 2014
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 comentarios
Image Analyst
el 7 de Dic. de 2015
sonia, see "Feature Matching" on this page: http://www.mathworks.com/products/computer-vision/features.html#object-tracking-and-motion-estimation
sonia carole
el 8 de Dic. de 2015
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');
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Processing and Computer Vision en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!