I have a stack of images and I need a define, for each image, the substack defined by the neighbouring 10 (5 before and 5 after). The stack of images is defined as IM(m,:,:)
(details below).
m = 0;
for j = 1:projections
for k = 1:number_images
u = sprintf('images_%03i_%05i.fits',j-1, k-1);
IM(m,:,:) = fitsread(u);
end
end
What I want to do is something like (code non working)
for k = 6:number_images
rolling_interval_IM = [IM(k-5,:,:):IM(k+5,:,:)];
Is there a better way to do it?
number_images = 60;
offset = 5;
for n=offset+1:1:number_images-offset
rolling_interval_IM = squeeze(IM(n-offset:1:n+offset,:,:));
end
You didn't say whether you wanted to store each rolling interval so this will just overwrite the previous.
It's a bit unusual I think to have the time dimension as your first dimension. That is normally the last in my experience.