Speed up convolution and supersampling in 3D binary matrix
Afficher commentaires plus anciens
HAllo! and thanks in advance to averybody.
I have a 3D matrix made by confocal microscopy images that have the same resolution on x,y axes and about 1/7 of resolution on z axes. To perform a supersampling on z axes I wrote this code that perform a convolution with a gaussian function on Z axes and than an uppersampling for each Z vector.
function [matrixZ,Zplanes] = denoising3Z (matrix,planes);
x = [1,1,1];
h = @(x) gaussmf(x,[4,0]);
Zplanes = planes * 7;
[r,c] = size(matrix{1,1});
matrixZ = zeros (r,c, Zplanes);
for i = 1: r
for j = 1 : c
vectorZ = zeros(1,6);
for z = 1 : planes
vectorZ(1,z) = matrix{1,z}(i,j);
end
vectorCZ(1,:) = filter(h(x),2,vectorZ(1,:));
V2 = imresize(vectorCZ, [1 Zplanes], 'bilinear');
matrixZ(i,j,:) = V2(1,:);
end
i
end
end
It works very well but it has to repeat these operation for 6 million of Z vector per images and the entire operation takes a long time. How I can speed up the process? It is possible to create a filter volume and applicate the volume to the matrix in just one pass? Probably it should be a bit more rapid. Thanks.
Réponse acceptée
Plus de réponses (1)
Deepak Bhatia
le 3 Mar 2017
0 votes
Looking at the nested loop structure, I recommend looking into vectorization in MATLAB as it might reduce code execution time.
Catégories
En savoir plus sur Biomedical Imaging dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!