本文主要是介绍anistropic filer,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1 、对相邻的8向或者26向进行标准邻域卷积;
hN = [0 1 0; 0 -1 0; 0 0 0];
hS = [0 0 0; 0 -1 0; 0 1 0];
hE = [0 0 0; 0 -1 1; 0 0 0];
hW = [0 0 0; 1 -1 0; 0 0 0];
hNE = [0 0 1; 0 -1 0; 0 0 0];
hSE = [0 0 0; 0 -1 0; 0 0 1];
hSW = [0 0 0; 0 -1 0; 1 0 0];
hNW = [1 0 0; 0 -1 0; 0 0 0];
nablaN = imfilter(diff_im,hN,'conv');nablaS = imfilter(diff_im,hS,'conv'); nablaW = imfilter(diff_im,hW,'conv');nablaE = imfilter(diff_im,hE,'conv'); nablaNE = imfilter(diff_im,hNE,'conv');nablaSE = imfilter(diff_im,hSE,'conv'); nablaSW = imfilter(diff_im,hSW,'conv');nablaNW = imfilter(diff_im,hNW,'conv');
2、迭代到扩散方程
cN = 1./(1 + (nablaN/kappa).^2);cS = 1./(1 + (nablaS/kappa).^2);cW = 1./(1 + (nablaW/kappa).^2);cE = 1./(1 + (nablaE/kappa).^2);cNE = 1./(1 + (nablaNE/kappa).^2);cSE = 1./(1 + (nablaSE/kappa).^2);cSW = 1./(1 + (nablaSW/kappa).^2);cNW = 1./(1 + (nablaNW/kappa).^2);
3、离散化方程
diff_im = diff_im + ...delta_t*(...(1/(dy^2))*cN.*nablaN + (1/(dy^2))*cS.*nablaS + ...(1/(dx^2))*cW.*nablaW + (1/(dx^2))*cE.*nablaE + ...(1/(dd^2))*cNE.*nablaNE + (1/(dd^2))*cSE.*nablaSE + ...(1/(dd^2))*cSW.*nablaSW + (1/(dd^2))*cNW.*nablaNW );
参考资料
% MATLAB implementation based on Peter Kovesi's anisodiff(.):
% P. D. Kovesi. MATLAB and Octave Functions for Computer Vision and Image Processing.
% School of Computer Science & Software Engineering,
% The University of Western Australia. Available from:
% <http://www.csse.uwa.edu.au/~pk/research/matlabfns/>.
%
% Credits:
% Daniel Simoes Lopes
% ICIST
% Instituto Superior Tecnico - Universidade Tecnica de Lisboa
% danlopes (at) civil ist utl pt
% http://www.civil.ist.utl.pt/~danlopes
这篇关于anistropic filer的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!