【图像分割】基于 K-means 聚类算法实现乳腺肿瘤图像分割含Matlab源码

1 简介

对图像进行颜色区域分割.将图像转换到CIE Lab颜色空间,用K均值聚类分析算法对描述颜色的a和b通道进行聚类分析;通过提取各个颜色区域独立成为单色的新图像,对图像进行分割处理.实验结果表明,在CIE Lab空间使用K—means聚类算法可以有效地分割彩色纺织品图像的颜色区域.

2 部分代码

clc

clear

close all

%% dataset:

for image=1:33

    image

    Iref=dicomread(['RIDER dataset/ref/1 (',num2str(image),').dcm']);

    Igt=dicomread(['RIDER dataset/GT/1 (',num2str(image),').dcm']);

    fim=(double(Iref)/(max(max(double(Iref)))));

    GT=logical(Igt);

    maxwin=0;

    for i=30:5:size(GT,1)-100

        for j=30:5:size(GT,2)-100

            window=GT(i:i+90,j:j+90);

            if sum(sum(window))>maxwin

                maxwin=sum(sum(window));

                bestwin=window;

                besti=i;

                bestj=j;

            end

        end

    end

    GT=bestwin;

    fim=fim(besti:besti+90,bestj:bestj+90);

    subplot(1,4,1)

    imshow(GT);

    title('Ground Truth');

    %% fcm

    [bwfim,level]=threshold1(fim);  

    %% kmeans 

    [bwfim2,level2]=threshold2(fim);   

    %% Cuckoo + Kmeans

    [bwfim3,level3]=threshold3(fim);

    %%

    result=(bwfim);

    nResult=sum(sum(result==1));

    nGT=sum(sum(GT==1));

    nUNI=0;

    for i=1:numel(GT)

        if result(i)==1 && GT(i)==1

            nUNI=nUNI+1;

        end

    end

    Q_fcm= nUNI/nGT * nUNI/nResult;

    subplot(1,4,2)

    imshow(bwfim);

    title(['FCM/ Q=',num2str(Q_fcm)]);

    %%

    result=(bwfim2);

    nResult=sum(sum(result==1));

    nGT=sum(sum(GT==1));

    nUNI=0;

    for i=1:numel(GT)

        if result(i)==1 && GT(i)==1

            nUNI=nUNI+1;

        end

    end

    Q_km= nUNI/nGT * nUNI/nResult;

    subplot(1,4,3)

    imshow(bwfim2);

    title(['Kmeans/ Q=',num2str(Q_km)]);

    %%

    result=bwfim3;

    nResult=sum(sum(result==1));

    nGT=sum(sum(GT==1));

    nUNI=0;

    for i=1:numel(GT)

        if result(i)==1 && GT(i)==1

            nUNI=nUNI+1;

        end

    end

    Qc= nUNI/nGT * nUNI/nResult;

    subplot(1,4,4)

    imshow(bwfim3);

    title(['Cuckoo/ Q=',num2str(Qc)]);

    pause(0.1)

    QQ=[Q_fcm,Q_km,Qc];

    xlswrite('xl.xlsx',QQ,1,['A',num2str(image)])

end

3 仿真结果

4 参考文献

[1]李鹏飞, 张宏伟. 基于K-means聚类的纺织品印花图像区域分割[J]. 西安工程大学学报, 2008, 22(5):551-554.​

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

  • 16
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值