averaging many images for every pixel - recursively.

5 views (last 30 days)
I have a set of 30 images. I want to be able to consider each pixel, and take an average of that pixel over the 30 images, and do this for all pixels (So to calculate the fixed pattern noise). So my end result is a matrix of average values on a pixel level. Rather than read in each image and store it, I have read I can use recursion. Im not really sure where to start for any of this.
any pointers would be greatly appreciated.
Thanks Jason

Accepted Answer

Walter Roberson
Walter Roberson on 31 May 2016
No, you will need to read in each of the images. You will not need to store them all: instead you could keep a running total for each pixel location, and then at the end divide by the number of images. For example,
tot = 0;
for imnumber = 1 : 20
this_file = sprintf('frame_%02d.tif', imnumber);
this_image = imread(this_file);
tot = tot + double(this_image);
end
avg = tot ./ 20;

More Answers (1)

Ahmed Rashid
Ahmed Rashid on 31 May 2016
Edited: Ahmed Rashid on 31 May 2016
X = imread('peppers.png');
nrOfImages = 30;
% assuming that you have the images in a cell array
images = cell(nrOfImages);
for i = 1:nrOfImages
images{i} = X;
end
% main code
XX = zeros([size(X), nrOfImages]);
for i = 1:30
XX(:, :, :, i) = double(images{i});
end
averageX = sum(XX, 4) / nrOfImages;
imshow(uint8(averageX))
I assumed that you have the images in a cell array.

Community Treasure Hunt

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

Start Hunting!