how to average 5 RGB images ?

a,b,c,d,e --------------- 5 rgb image matrix.
sum = a+b+c+d+e;
average = sum./5;
average image has same dimension as a,b,c,d,e.

2 Comments

Hi, what is exactly the problem? If you average 5 images, it is to be expected that the resulting average image has the same dimensions as your original images.
One more thing, using sum as variable name can be confusing, since it is also a Matlab function.
thanks for comment.your comment is my answer only ...
sum of all image is greater than 8bit but i have taken 8 bit data variable
to store it . and i didnt get true answer..
thank u 4 comment.

Sign in to comment.

Answers (1)

You must cast them to single or double before adding so you don't clip at 255. Then divide by 5;
meanRGB = (double(image1) + double(image2) + double(image3) + double(image4) + double(image5)) / 5;
Cast back to uint8 if you want to display it or save it.

Asked:

on 21 Aug 2013

Community Treasure Hunt

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

Start Hunting!