【图像分割】基于改进的模糊聚类WFCM算法实现图像分割matlab代码
2021/11/3 22:11:57
本文主要是介绍【图像分割】基于改进的模糊聚类WFCM算法实现图像分割matlab代码,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1 简介
模糊 C 均值聚类(FCM)算法是一种基于非监督聚类算法。样本加权模糊 C 均值聚类(WFCM)算法是 FCM 算法的改进,该算法能够明显提高收敛速度和聚类的准确性。无论是 FCM 算法还是 WFCM 算法,对噪声都相对敏感,而且聚类数目仍然需要人工确定。在此提出一种改进算法,首先通过偏微分方程(PDE)降噪算法对原始脑 MRI医学图像进行处理;其次利用聚类有效性确定最佳聚类数目,对 WFCM 算法进行改进;最后利用本文改进算法对图像进行聚类分割。实验表明,该方法是一种具有自动分类能力、抗噪性较好的模糊聚类图像分割算法。
2 部分代码
%% Image segmentation by WFCM % WFCM refer to 'Fuzzy cluster analysis and its application' by Teacher % Gao, Published by xidian % we first implement one thresholding segmentation, then auto % multi-thresholding % we also used two-dimentional gray histogram % Algorithm by Teacher Xinbo Gao, implemented by Lin Zhao, VIPS Lab; %% Code Follows clear;clc;close all; inputim = imread('TestImage\lena.bmp'); inputim = rgb2gray(inputim); figure;imshow(inputim,[]); % count 1D histogram or 2D histogram [h,x] = imhist(inputim); figure;stem(x,h); nst = imhist2(inputim); count = 0:1:255; % count = nst; % compute the weighted coefficient wi w = h'./sum(h'); % iteration to compute the center of clustering,here c=2 vc1 = 64; vc2 = 192; % initialization v1 = 0; v2 = 0; n = 0; while (abs(v1-vc1)>2)||(abs(v2-vc2)>2) if n ~= 0 vc1 = v1; vc2 = v2; end % update uij for j = 1:1:2 if j == 1 vc = vc1; else vc = vc2; end for i = 1:1:256 dij = norm(count(i)-vc); di1 = norm(count(i)-vc1); di2 = norm(count(i)-vc2); u(i,j) = (dij/di1).^2+(dij/di2).^2;% m = 3 u(i,j) = 1/u(i,j); end end for i = 1:1:256 for j = 1:1:2 if isnan(u(i,j)) u(i,j) = 0; end end end % update vj x1 = w.*u(:,1)'.^3.*count; x1 = sum(x1); y1 = sum(w.*u(:,1)'.^3); v1 = x1/y1; x2 = w.*u(:,2)'.^3.*count; x2 = sum(x2); y2 = sum(w.*u(:,2)'.^3); v2 = x2/y2; n = n+1; end % compute the threholding t = (vc1+vc2)/2; T = repmat(t,size(inputim,1),size(inputim,2)); outputim = inputim>T; outputim = double(outputim); figure;imshow(outputim,[]);
3 仿真结果
4 参考文献
[1]陈梅, and 王健. "基于改进模糊C-均值聚类算法的图像分割." 现代电子技术 30.13(2007):2.
这篇关于【图像分割】基于改进的模糊聚类WFCM算法实现图像分割matlab代码的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-28pyqt 怎么打包整个项目-icode9专业技术文章分享
- 2024-09-28laravel Commands 创建带有参数的 Artisan 命令的步骤和示例-icode9专业技术文章分享
- 2024-09-28antd怎么实现渲染tiff图片-icode9专业技术文章分享
- 2024-09-28英文半角中划线和中文全角的中划线有什么区别-icode9专业技术文章分享
- 2024-09-28nvm npm 和node 他们之间有什么关系-icode9专业技术文章分享
- 2024-09-28Node Version Manager (nvm)使用教程-icode9专业技术文章分享
- 2024-09-28nvm命令太慢,是什么原因-icode9专业技术文章分享
- 2024-09-28Kotlin 如何增加、删除和修改 MutableStateFlow 中的值。-icode9专业技术文章分享
- 2024-09-28Kotlin的stateFlow.update 写法介绍-icode9专业技术文章分享
- 2024-09-28kotlin 怎么获取当前时间格式-icode9专业技术文章分享