Gaussian smoothing filtering of 4D data
16 次查看(过去 30 天)
显示 更早的评论
Hi,
I have 4D MRI data (Magnetic Resonace Imaging). Where dimensions are: x-, y-, z- dimension and time.
I would like to smooth my data with Gaussian filter.
Does anyone know if Matlab has a function to smooth 4D or 3D data?
Is imgaussfilt what I need? Can I use this function in 4D Nifty format images?
0 个评论
回答(2 个)
Matt J
2019-6-10
编辑:Matt J
2019-6-10
imgaussfilt is for 2D only, but it wouldn't be too hard to implement your own 4D separable Gaussian filter just by using my KronProd class,
%% Fake 4D image data
N=100;
Image=rand(N,N,N,N,'single');
%% Construct 1D convolution matrix
sigma=2;
t=linspace(-3*sigma,3*sigma,21);
k=exp(-t.^2/2/sigma); %1D Gaussian kernel
A=conv2(eye(N),k.','same'); % convolution matrix
%% Perform filtering
tic;
filteredImage=KronProd({A,A,A,A})*Image;
toc;
%Elapsed time is 2.844996 seconds.
Above, I've kept things simple by assuming the image is NxNxNxN. In the less simplified case when your image has different dimensions, or you want to apply different sigma along different dimensions, you would need to derive different convolution matrices appropriate to each dimension, following the same general procedure above.
filteredImage=KronProd({A4,A3,A2,A1})*Image;
0 个评论
Matt J
2019-6-10
Does anyone know if Matlab has a function to smooth 4D or 3D data?
For 3D data there is imgaussfilt3 (introduced in R2015a).
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!