近年脑肿瘤发病率呈上升趋势,约占全身肿瘤的5%,占儿童肿瘤的70%。CT、MRI等多种影像检查方法可用于检测脑肿瘤,其中MRI应用于脑肿瘤成像效果最佳。精准的脑肿瘤分割是病情诊断、手术规划及后期治疗的必备条件,既往研究者对脑部肿瘤分割算法进行了深入研究,并取得了很多成果。然而脑部结构复杂,包括脑皮层、灰质、白质、胼胝体、脑脊液等组织,分割精度难以保证。目前临床使用最广泛的脑部肿瘤分割方法是模糊C均值算法和均值漂移算法。图像分割主要包括滤波和分割两部分,一般选取常用于脑部胶质瘤图像分割的非局部均值滤波、中值滤波、各向异性滤波3种滤波方法和分水岭算法、模糊C均值算法等常用的不同类型分割算法。
鉴于此,本项目采用传统的图像处理算法脑部磁共振成像肿瘤图像进行分割,运行环境为MATLAB 2018。
function diff_im = anisodiff(im, num_iter, delta_t, kappa, option)
fprintf('Removing noise\n');
fprintf('Filtering Completed !!');
% Convert input image to double.
im = double(im);
% PDE (partial differential equation) initial condition.
diff_im = im;
% Center pixel distances.
dx = 1;
dy = 1;
dd = sqrt(2);
% 2D convolution masks - finite differences.
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];
% Anisotropic diffusion.
for t = 1:num_iter
% Finite differences. [imfilter(.,.,'conv') can be replaced by conv2(.,.,'same')]
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');
% Diffusion function.
if option == 1
cN = exp(-(nablaN/kappa).^2);
cS = exp(-(nablaS/kappa).^2);
cW = exp(-(nablaW/kappa).^2);
cE = exp(-(nablaE/kappa).^2);
cNE = exp(-(nablaNE/kappa).^2);
cSE = exp(-(nablaSE/kappa).^2);
cSW = exp(-(nablaSW/kappa).^2);
cNW = exp(-(nablaNW/kappa).^2);
elseif option == 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);
end
% Discrete PDE solution.
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 );
完整代码:https://mbd.pub/o/bread/mbd-ZJacmJ9s
end
工学博士,担任《Mechanical System and Signal Processing》《中国电机工程学报》《控制与决策》等期刊审稿专家,擅长领域:现代信号处理,机器学习,深度学习,数字孪生,时间序列分析,设备缺陷检测、设备异常检测、设备智能故障诊断与健康管理PHM等。
标签:kappa,conv,imfilter,im,MATLAB,exp,diff,磁共振,2018 From: https://blog.csdn.net/weixin_39402231/article/details/139408356