使用各向异性滤波器和图像处理方法进行脑肿瘤检测(MATLAB)

医学图像分割一直以来都是计算机辅助诊断领域的研究热点。在医学图像的处理和分析中,对图像中感兴趣区域的准确分割尤其关键。要对感兴趣区域进行分类识别,首先要从图像中把感兴趣区域精确分割出来,然后有针对性地对感兴趣区域提取特征并分类。目前关于脑部MRI的分割主要的研究都集中在脑部的灰质,白质和脑脊液等组织的分割。

图像分割方法根据分割类型的不同,大致可以分为基于区域的分割方法和基于边界的分割方法。基于区域的分割方法一般是根据图像中点与点之间的灰度值、纹理特征等属性来判断它们的相似度,根据相似度来划分图像区域。基于边界的分割方法是以灰度变化的梯度大小来确定感兴趣区域的边界。在实际应用中,常常将这两种方法结合在一起使用。

鉴于此,采用各向异性滤波器和图像处理方法进行脑肿瘤分割检测,运行环境为MATLAB 2018,主运行代码如下:

Matlab 复制代码
%%filter
num_iter = 10;
    delta_t = 1/7;
    kappa = 15;
    option = 2;
    disp('Preprocessing image please wait . . .');
    inp = anisodiff(s,num_iter,delta_t,kappa,option);
    inp = uint8(inp);
    
inp=imresize(inp,[256,256]);
if size(inp,3)>1
    inp=rgb2gray(inp);
end
figure;
imshow(inp);
title('Filtered image','FontSize',20);

%%thresholding
sout=imresize(inp,[256,256]);
t0=60;
th=t0+((max(inp(:))+min(inp(:)))./2);
for i=1:1:size(inp,1)
    for j=1:1:size(inp,2)
        if inp(i,j)>th
            sout(i,j)=1;
        else
            sout(i,j)=0;
        end
    end
end

%morphologial operation
label=bwlabel(sout);
stats=regionprops(logical(sout),'Solidity','Area','BoundingBox');
density=[stats.Solidity];
area=[stats.Area];
high_dense_area=density>0.6;
max_area=max(area(high_dense_area));
tumor_label=find(area==max_area);
tumor=ismember(label,tumor_label);
if max_area>100
   figure;
   imshow(tumor)
   title('tumor alone','FontSize',20);
else
    h = msgbox('No Tumor!!','status');
    %disp('no tumor');
    return;
end

%%binding box
box = stats(tumor_label);
wantedBox = box.BoundingBox;
figure
imshow(inp);
title('Bounding Box','FontSize',20);
hold on;
rectangle('Position',wantedBox,'EdgeColor','y');
hold off;
%%getting tumor outline
dilationAmount = 5;
rad = floor(dilationAmount);
[r,c] = size(tumor);
filledImage = imfill(tumor, 'holes');
for i=1:r
   for j=1:c
       x1=i-rad;
       x2=i+rad;
       y1=j-rad;
       y2=j+rad;
       if x1<1
           x1=1;
       end
       if x2>r
           x2=r;
       end
       if y1<1
           y1=1;
       end
       if y2>c
           y2=c;
       end
       erodedImage(i,j) = min(min(filledImage(x1:x2,y1:y2)));
   end
end
figure
imshow(erodedImage);
title('eroded image','FontSize',20);

%%subtracting eroded image from bw image
tumorOutline=tumor;
tumorOutline(erodedImage)=0;
figure;  
imshow(tumorOutline);
title('Tumor Outline','FontSize',20);

%%inserting outline
rgb = inp(:,:,[1 1 1]);
red = rgb(:,:,1);
red(tumorOutline)=255;
green = rgb(:,:,2);
green(tumorOutline)=0;
blue = rgb(:,:,3);
blue(tumorOutline)=0;
tumorOutlineInserted(:,:,1) = red; 
tumorOutlineInserted(:,:,2) = green; 
tumorOutlineInserted(:,:,3) = blue; 
figure
imshow(tumorOutlineInserted);
title('Detected Tumer','FontSize',20);


%%to display
figure
subplot(231);imshow(s);
title('Input image','FontSize',15);
subplot(232);imshow(inp);
title('Filtered image','FontSize',15);
subplot(233);imshow(inp);
title('Bounding Box','FontSize',15);
hold on;
rectangle('Position',wantedBox,'EdgeColor','y');
hold off;
subplot(234);
imshow(tumor);
title('tumor alone','FontSize',15);
subplot(235);imshow(tumorOutline);
title('Tumor Outline','FontSize',15);
subplot(236);imshow(tumorOutlineInserted);
title('Detected Tumor','FontSize',15);

知乎学术咨询:
https://www.zhihu.com/consult/people/792359672131756032?isMe=1
工学博士,担任《Mechanical System and Signal Processing》《中国电机工程学报》《控制与决策》等期刊审稿专家,擅长领域:现代信号处理,机器学习,深度学习,数字孪生,时间序列分析,设备缺陷检测、设备异常检测、设备智能故障诊断与健康管理PHM等。
  • 工学博士,担任《Mechanical System and Signal Processing》《中国电机工程学报》《控制与决策》等期刊审稿专家,擅长领域:现代信号处理,机器学习,深度学习,数字孪生,时间序列分析,设备缺陷检测、设备异常检测、设备智能故障诊断与健康管理PHM等。
相关推荐
gf132111117 小时前
python_字幕文本、音频、视频一键组合
python·音视频·swift
我的xiaodoujiao17 小时前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 32--开源电商商城系统项目实战--如何区分登录状态
python·学习·测试工具·pytest
自在极意功。17 小时前
深入解析JDBC:Java数据库操作的基础
java·开发语言·数据库·jdbc
数据的世界0117 小时前
重构智慧书-第13条:先知他人别有所图的心思,再伺机行事
人工智能
czhc114007566317 小时前
c#w 1214
开发语言·c#
ZAz_17 小时前
DAY 38 模型可视化与推理
python
艾上编程17 小时前
第二章——数据分析场景之用Python进行CSV/Excel数据清洗:为数据分析筑牢根基
python·数据分析·excel
闲人编程17 小时前
FastAPI性能优化技巧
后端·python·性能优化·fastapi·性能·codecapsule
数据的世界0117 小时前
重构智慧书-第10条:名声与好运
人工智能
Amazon数据采集17 小时前
# 🚀 亚马逊URL参数拼接实战:数据采集效率提升指南
python