码迷,mamicode.com
首页 > 其他好文 > 详细

【图像分割】基于GUI FCM+KFCM MRI图像分割【含Matlab源码 582期】

时间:2021-06-28 17:59:16      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:分析方法   版本   image   cut   initial   指正   如何   nim   filename   

一、简介

1 如何理解模糊聚类
事物间的界线,有些是明确的,有些则是模糊的。当聚类涉及到事物之间的模糊界线时,需要运用模糊聚类分析方法。
如何理解模糊聚类的“模糊”呢:假设有两个集合分别是A、B,有一成员a,传统的分类概念a要么属于A要么属于B,在模糊聚类的概念中a可以0.3属于A,0.7属于B,这就是其中的“模糊”概念。
模糊聚类分析有两种基本方法:系统聚类法和逐步聚类法。
系统聚类法个人理解类似于密度聚类算法,逐步聚类法类是中心点聚类法。(这里有不对的地方请指正)
逐步聚类法是一种基于模糊划分的模糊聚类分析法。它是预先确定好待分类的样本应分成几类,然后按照最优原则进行在分类,经多次迭代直到分类比较合理为止。在分类过程中可认为某个样本以某一隶属度隶属某一类,又以某一隶属度隶属于另一类。这样,样本就不是明确的属于或不属于某一类。若样本集有n个样本要分成c类,则他的模糊划分矩阵为c×n。
该矩阵有如下特性:
①. 每一样本属于各类的隶属度之和为1。
②. 每一类模糊子集都不是空集。

2 模糊C-means聚类算法
模糊c-均值聚类算法fuzzy c-means (FCM)。在众多模糊聚类算法中,模糊C-均值(FCM)算法应用最广泛且成功,它通过优化目标函数得到每个样本点对所有类中心的隶属度,从而对样本进行自动分类。

3 FCM算法原理
假定我们有数据集X,我们要对X中的数据进行分类,如果把这些数据划分成c个类的话,那么对应的就有c个类中心为Ci,每个样本Xj属于某一类Ci的隶属度定为Uij,那么定义一个FCM目标函数及其约束条件如下:
技术图片
技术图片
目标函数(式1)由相应样本的隶属度与该样本到各类中心的距离相乘组成的,式2为约束条件,也就是一个样本属于所有类的隶属度之和要为 1 。
式1中的m是一个隶属度的因子,一般为2 ,||Xj - Ci|| 表示Xj到中心点Ci的欧式距离。
目标函数J越小越好,说以我们要求得目标函数J的极小值,这里如何求极小值就不推导了(对推导感兴趣的可以看这篇文章:https://blog.csdn.net/on2way/article/details/47087201),直接给出结论:
Uij的迭代公式:
技术图片
Ci的迭代公式:
技术图片
我们发现Uij和Ci是相互关联的,彼此包含对方,那么问题来了,fcm算法开始的时候既没有Uij也没有Ci,那么如何求解呢?很简单,程序一开始的时候我们会随机生成一个Uij,只要数值满足条件即可,然后开始迭代,通过Uij计算出Ci,有了Ci又可以计算出Uij,反反复复,这个过程中目标函数J一直在变化,逐渐绉向稳定。那么当J不在变化时就认为算法收敛到一个较好的结果了。

4 KFCM概述
KFCM:基于核的改进的模糊c均值聚类算法。它是通过核函数将原始空间中的点映射到特征空间中,考虑到原始空间中的点无法用一个线性函数进行划分,于是将其变换到一个更高维度的空间中,可以在这个高维空间中找到一个线性函数,容易对原始数据进行划分。这个高维空间就叫特征空间。从低维到高维空间的映射函数的内积就叫核函数。将核函数引入机器学习的一个重要原因是:当特征空间维数很高而核函数计算量较之特征空间内的内积运算计算量相对很小时,这样做可以提高计算效率。
基于目标函数的FCM聚类算法存在两大缺陷:一方面,隶属度和为1的约束条件易造成它对对孤立点和噪声敏感;另一方面它本身是一种迭代下降的算法,使得它初始聚类中心敏感且不易收敛于全局最优。KFCM算法提高了聚类性能,使算法对噪声和孤立点具有较好的鲁棒性。

二、源代码

function varargout = MainGUI(varargin)
% MAINGUI M-file for MainGUI.fig
%      MAINGUI, by itself, creates a new MAINGUI or raises the existing
%      singleton*.
%
%      HKFCMPARA = MAINGUI returns the handle to a new MAINGUI or the handle to
%      the existing singleton*.
%
%      MAINGUI(‘CALLBACK‘,hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MAINGUI.M with the given input arguments.
%
%      MAINGUI(‘Property‘,‘Value‘,...) creates a new MAINGUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before MainGUI_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to MainGUI_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE‘s Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help MainGUI
% Last Modified by GUIDE v2.5 10-May-2005 12:20:34

% Author: Genial.Rong@USTC.P.R.C
% Email: JGRong@ustc.edu
% URL:  http://genial.yculblog.com


% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name‘,       mfilename, ...
                   ‘gui_Singleton‘,  gui_Singleton, ...
                   ‘gui_OpeningFcn‘, @MainGUI_OpeningFcn, ...
                   ‘gui_OutputFcn‘,  @MainGUI_OutputFcn, ...
                   ‘gui_LayoutFcn‘,  [] , ...
                   ‘gui_Callback‘,   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before MainGUI is made visible.
function MainGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to MainGUI (see VARARGIN)

% Choose default command line output for MainGUI
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes MainGUI wait for user response (see UIRESUME)
% uiwait(handles.MainFig);

% 日期时间显示
set(handles.timestr,‘string‘,datestr(now,0));
htimer = timer(‘StartDelay‘,1,‘TimerFcn‘,...
    ‘htimestr=findall(0,‘‘tag‘‘,‘‘timestr‘‘);set(htimestr,‘‘string‘‘,datestr(now,0));‘,...
    ‘Period‘,1,‘ExecutionMode‘,‘fixedSpacing‘,‘tag‘,‘showtime‘);
start(htimer);



% --- Outputs from this function are returned to the command line.
function varargout = MainGUI_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes during object creation, after setting all properties.
function hslider_CreateFcn(hObject, eventdata, handles)
% hObject    handle to hslider (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,‘BackgroundColor‘), get(0,‘defaultUicontrolBackgroundColor‘))
    set(hObject,‘BackgroundColor‘,[.9 .9 .9]);
end



% --- Executes during object creation, after setting all properties.
function hedit_fname_CreateFcn(hObject, eventdata, handles)
% hObject    handle to hedit_fname (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,‘BackgroundColor‘), get(0,‘defaultUicontrolBackgroundColor‘))
    set(hObject,‘BackgroundColor‘,‘white‘);
end


% --- Executes during object creation, after setting all properties.
function hedit_heb_CreateFcn(hObject, eventdata, handles)
% hObject    handle to hedit_heb (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,‘BackgroundColor‘), get(0,‘defaultUicontrolBackgroundColor‘))
    set(hObject,‘BackgroundColor‘,‘white‘);
end


% --- Executes during object creation, after setting all properties.
function hedit_xuhao_CreateFcn(hObject, eventdata, handles)
% hObject    handle to hedit_xuhao (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,‘BackgroundColor‘), get(0,‘defaultUicontrolBackgroundColor‘))
    set(hObject,‘BackgroundColor‘,‘white‘);
end


% --- Executes during object creation, after setting all properties.
function hedit_zhishu_CreateFcn(hObject, eventdata, handles)
% hObject    handle to hedit_zhishu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,‘BackgroundColor‘), get(0,‘defaultUicontrolBackgroundColor‘))
    set(hObject,‘BackgroundColor‘,‘white‘);
end


% --- Executes during object creation, after setting all properties.
function hedit_zuixiao_CreateFcn(hObject, eventdata, handles)
% hObject    handle to hedit_zuixiao (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,‘BackgroundColor‘), get(0,‘defaultUicontrolBackgroundColor‘))
    set(hObject,‘BackgroundColor‘,‘white‘);
end



% --- Executes during object creation, after setting all properties.
function hedit_cishu_CreateFcn(hObject, eventdata, handles)
% hObject    handle to hedit_cishu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,‘BackgroundColor‘), get(0,‘defaultUicontrolBackgroundColor‘))
    set(hObject,‘BackgroundColor‘,‘white‘);
end


% --- Executes during object creation, after setting all properties.
function hedit_leibie_CreateFcn(hObject, eventdata, handles)
% hObject    handle to hedit_leibie (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,‘BackgroundColor‘), get(0,‘defaultUicontrolBackgroundColor‘))
    set(hObject,‘BackgroundColor‘,‘white‘);
end



% --- Executes during object creation, after setting all properties.
function hmenu_CreateFcn(hObject, eventdata, handles)
% hObject    handle to hmenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,‘BackgroundColor‘), get(0,‘defaultUicontrolBackgroundColor‘))
    set(hObject,‘BackgroundColor‘,‘white‘);
end

三、运行结果

技术图片
技术图片
技术图片
技术图片
技术图片

四、备注

版本:2014a

完整代码或代写加1564658423

【图像分割】基于GUI FCM+KFCM MRI图像分割【含Matlab源码 582期】

标签:分析方法   版本   image   cut   initial   指正   如何   nim   filename   

原文地址:https://www.cnblogs.com/homeofmatlab/p/14932906.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!