time averaged of 5000 images

2 次查看(过去 30 天)
Shabnam M
Shabnam M 2020-9-9
评论: Shabnam M 2020-9-9
Hello,
Actually I have 5000 images which are captured at specific time intervals and they are saved as first_00001, first_00002, first_00003, ...
I want to create a time-averaged image.
I tried to read them by:
======================================================
for k=1:5000
if k<10
Image1(:,:,k) = double(imread(['first_0000',num2str(k),'.tif']));
else if k>9 && k<100
Image1(:,:,k) = double(imread(['first_000',num2str(k),'.tif']));
else if k>99 && k <1000
Image1(:,:,k) = double(imread(['first_00',num2str(k),'.tif']));
else if k>999 && k <10000
Image1(:,:,k) = double(imread(['first_0',num2str(k),'.tif']));
else if k>9999 && k <100000
Image1(:,:,k) = double(imread(['first_',num2str(k),'.tif']));
end
end
end
end
end
end
=====================================================
Now, if I want to create the time averaged image, I should calculate that function on each array and then create a final image.
I will be so gratefull if you can help me to calculate this section.
Thanks in advance
  3 个评论
Shabnam M
Shabnam M 2020-9-9
Yes right, but how could I calculate the time-averaged data?
For common averaged data,we can use "mean" but I dont know what should I do for time-averaged one.
Thanks for spending your time
KSSV
KSSV 2020-9-9
You can pick the indices you want from 3D matrix and use mean right.

请先登录,再进行评论。

回答(1 个)

KSSV
KSSV 2020-9-9
imgFile = dir("*.tif") ;
N = length(imgFiles) ;
iwant = zeros(m,n,N) ; % where [m,n] is size of each image. Assuming each image is of size m*n.
% loop for each image.
for i = 1:N
iwant(:,:,i) = imread(imgFiles(i).name) ;
end
Now you have a 3D matrix. If you want mean of images from 9 to 100; use
M = mean(iwant(:,:,9:100),3) ;
  1 个评论
Shabnam M
Shabnam M 2020-9-9
Thanks for your help, but your will give the common mean value (for example it sum the arrays and devide them to their numbers), but I need the time-averaged data.
For instance each images are captured with 100fps which means the difference between each two images is 0.01s.
now I want to get the time-averaged data in the specific perid for 5000 images.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by