有人可以指导我介绍各向异性扩散的一些现有实现方式,最好是 perona-malik扩散吗?

最佳答案

翻译以下MATLAB代码:

% pm2.m - Anisotropic Diffusion routines



function ZN = pm2(ZN,K,iterate);

[m,n] = size(ZN);

% lambda = 0.250;
lambda = .025;
%K=16;

rowC = [1:m]; rowN = [1 1:m-1]; rowS = [2:m m];
colC = [1:n]; colE = [2:n n]; colW = [1 1:n-1];
result_save=0;
for i = 1:iterate,
   %i;
%    result=PSNR(Z,ZN);
%    if result>result_save
%     result_save=result;
% else
%     break;
% end
  deltaN = ZN(rowN,colC) - ZN(rowC,colC);
  deltaS = ZN(rowS,colC) - ZN(rowC,colC);
  deltaE = ZN(rowC,colE) - ZN(rowC,colC);
  deltaW = ZN(rowC,colW) - ZN(rowC,colC);
%   deltaN = deltaN .*abs(deltaN<K);
%   deltaS = deltaS .*abs(deltaS<K);
%   deltaE = deltaE .*abs(deltaE<K);
%   deltaW = deltaW .*abs(deltaW<K);

     fluxN = deltaN .* exp(-((abs(deltaN) ./ K).^2)  );
     fluxS = deltaS .* exp(-((abs(deltaS) ./ K).^2)  );
     fluxE = deltaE .* exp(-((abs(deltaE) ./ K).^2)  );
     fluxW = deltaW .* exp(-((abs(deltaW) ./ K).^2)  );


   ZN = ZN + lambda*(fluxN +fluxS + fluxE + fluxW);
   %ZN=max(0,ZN);ZN=min(255,ZN);
end

该代码不是我的,并且取自:http://www.csee.wvu.edu/~xinl/code/pm2.m

关于opencv - Emgu CV-各向异性扩散,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14715817/

10-09 08:49