Speed up convolution and supersampling in 3D binary matrix
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (1)
Deepak Bhatia
el 3 de Mzo. de 2017
0 votos
Looking at the nested loop structure, I recommend looking into vectorization in MATLAB as it might reduce code execution time.
Categorías
Más información sobre Biomedical Imaging en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!