time averaged of 5000 images
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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) ;
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!