imfilter speed for volume

I'm working on an algorithm, which requires filtering of a 3D matrix (non-sparse, 512^3) to find edges.
I only want to find edges in each slice, so I have been doing the following:
% 2D loop appaoch
[x,y]=ndgrid(floor(-3*sigma):ceil(3*sigma),floor(-3*sigma):ceil(3*sigma));
DGauss=-(x./(2*pi*sigma^4)).*exp(-(x.^2+y.^2)/(2*sigma^2));
filteredVolume = zeros(size(vol))
for n = 1:size(vol,3)
filteredVolume(:,:,n) = imfilter(vol(:,:,n),DGauss,'conv','symmetric');
end
I also tried to do the same by calling imfilter on the entire volume:
% 3D matrix approach
filteredVolume = imfilter(vol,DGauss,'conv','symmetric');
I compared the performance of both of these approaches, but the loop version is significantly faster (6.5 seconds to 20 seconds).
Should this behavior be expected? If so, why?

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Image Processing Toolbox 的更多信息

标签

提问:

2013-10-9

Community Treasure Hunt

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

Start Hunting!

Translated by