在Matlab中使用高斯导数在3维上的体积梯度

时间:2018-10-15 21:15:13

标签: matlab 3d gradient gaussian derivative

我想使用高斯导数在MATLAB中计算体积的梯度。但是我做不到有人可以帮我吗?我使用以下代码在2D图像中执行此操作:

k = gaussiankernel(sigma1,1); % first order derivative of a gaussian with std 
sigma1

gx = imfilter(I,k','replicate','conv');
gy = imfilter(I,k,'replicate','conv');

请帮助我。如何使用内核gz计算k?或如何将此代码扩展到3D? 预先谢谢你。

这是使用structuretensor3d生成自适应椭球的代码:

function SE = AESE3(I,M,l1,l2,l3,phi3,theta3)
%I = input('Enter the input 3d volume: ');
%M = input('Enter the maximum allowed semi-major axes length: ');


% determining ellipsoid parameteres from eigen value decomposition of 3d
% structure tensor

row = size(I,1);
col = size(I,2);
hei = size(I,3);
SE = cell(row,col,hei);
padI = padarray(I,[M M M],'replicate','both');
padrow = size(padI,1);
padcol = size(padI,2);
padhei = size(padI,3);

[se_x,se_y,se_z] = meshgrid(-M:M,-M:M,-M:M);

for m = M+1:padrow-M
    for n = M+1:padcol-M
        for p = M+1:padhei-M
i = m-M;
j = n-M;
k = p-M;

a = (l1(i,j,k)+eps)/(l1(i,j,k)+l2(i,j,k)+l3(i,j,k)+3*eps)*M;
b = (l2(i,j,k)+eps)/(l1(i,j,k)+l2(i,j,k)+l3(i,j,k)+3*eps)*M;
c = (l3(i,j,k)+eps)/(l1(i,j,k)+l2(i,j,k)+l3(i,j,k)+3*eps)*M;

cos(phi3(i,j,k)) = cos_phi3;
sin(phi3(i,j,k)) = sin_phi3;
cos(theta3(i,j,k)) = cos_theta3;
sin(theta3(i,j,k)) = sin_theta3;

% defining structuring element for each pixel of image

se = ((se_x.*cos_theta3 - se_y.*sin_theta3.*cos_phi3 + 
se_z.*sin_theta3.*sin_phi3).^2)./a.^2+((se_x.*sin_theta3 + 
se_y.*cos_theta3.*cos_phi3 - se_z.*cos_theta3.*sin_phi3).^2)./b.^2+ 
((se_y.*sin_phi3 + se_z.*cos_phi3).^2)./c.^2 <= 1;

SE{i,j,k} = se;
        end
    end
end
end

Can I do this without zero padding?

0 个答案:

没有答案