MATLAB Answers

Soum
0

Average of 10 images

Asked by Soum
on 14 Jul 2013
Latest activity Answered by lateef oparemi on 6 Jun 2019
Hi;
I read a series of images and I want to calculate their average I've written
this code :
I=zeros(size(Io))
for i=1:10
image{i}=im2double(imread(['0.1s_',num2str(i),'.tif']));
I=I+image{i}
end;
I=I./10;
am I right ? knowing that it gives a result

  0 Comments

Sign in to comment.

2 Answers

Image Analyst
Image Analyst 님의 답변 14 Jul 2013

No, it's not. For one thing, don't use image as the name of a variable since it's the name of a built-in function. And no reason to store them all and use a cell array.
I0 = imread('0.1s_1.tif')
sumImage = double(I0); % Inialize to first image.
for i=2:10 % Read in remaining images.
rgbImage = imread(['0.1s_',num2str(i),'.tif']));
sumImage = sumImage + double(rgbImage);
end;
meanImage = sumImage / 10;

  4 Comments

Show 1 older comment
The images must be in slightly different positions, despite you thinking they aren't. The way around it is to call imregister() to align the images before summing.
CS 21 Nov 2018
and how can we do that? put imregister() before the imread?
By the way i was trying to find moving object so i thought of finding the background and then subtract, do you know a better way to do that?
You need a base image such aas the first in the series . Then after every imread you would register the new image against the base image and add in the aligned version of the new image .

Sign in to comment.


Answer by lateef oparemi on 6 Jun 2019

I0 = imread('0.1s_1.tif')
sumImage = double(I0); % Inialize to first image.
for i=2:10 % Read in remaining images.
rgbImage = imread(['0.1s_',num2str(i),'.tif']));
sumImage = sumImage + double(rgbImage);
end;
meanImage = sumImage / 10;

  0 Comments

Sign in to comment.