卷积相关公式的matlab代码

取半径=3

用matlab代码实现上式公式:

length=3;
for Ki = 1:length
  for Kj = 1:length
    for Kk = 1:length
      Ksigma(Ki,Kj,Kk)=exp(-(Ki-2)^2/8-(Kj-2)^2/8-(Kk-2)^2/8);                                 此公式为:K(u), ρ=3
    end
  end
end

KONE = convn(ones(size(Img3D_mc,1),size(Img3D_mc,2),size(Img3D_mc,3)),Ksigma,'same');  此公式为:∫k(x-y)dx

 

D_I(:,:,:,nn)= KONE.*Img(:,:,:,nn).^2-2*C(nn,kk)*Img(:,:,:,nn).*convn(B(:,:,:,nn),Ksigma,'same')+C(nn,kk)^2*convn(B(:,:,:,nn).^2,Ksigma,'same');

 

注:

 

posted on 2016-06-20 15:26  Kevin.Tu  阅读(676)  评论(0编辑  收藏  举报