EDA365电子论坛网
标题:
基于matlab FCM和改进的FCM脑部CT图像聚类
[打印本页]
作者:
mutougeda
时间:
2021-4-22 13:24
标题:
基于matlab FCM和改进的FCM脑部CT图像聚类
' @% S; n+ Z& u% ?; u
一、源代码
/ C( O* A0 I2 { g8 i
function varargout = CT_image_FCM(varargin)
% CT_IMAGE_FCM MATLAB code for CT_image_FCM.fig
% CT_IMAGE_FCM, by itself, creates a new CT_IMAGE_FCM or raises the existing
% singleton*.
%
% H = CT_IMAGE_FCM returns the handle to a new CT_IMAGE_FCM or the handle to
% the existing singleton*.
%
% CT_IMAGE_FCM('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CT_IMAGE_FCM.M with the given input arguments.
%
% CT_IMAGE_FCM('Property','Value',...) creates a new CT_IMAGE_FCM or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before CT_image_FCM_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to CT_image_FCM_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
) s6 e0 t4 D: |9 d: H9 p. L; b
% Edit the above text to modify the response to help CT_image_FCM
3 \3 |1 b! x1 @, U, t7 p% D
% Last Modified by GUIDE v2.5 17-Apr-2020 00:06:23
/ F( k0 J, H% q! R. v( @
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @CT_image_FCM_OpeningFcn, ...
'gui_OutputFcn', @CT_image_FCM_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
( L$ y' u2 P" d" |
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
C# _8 D2 V/ @
% D ~' l' |3 R6 F
% --- Executes just before CT_image_FCM is made visible.
function CT_image_FCM_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 CT_image_FCM (see VARARGIN)
% s* ^& @7 X6 ^7 E3 M
% Choose default command line output for CT_image_FCM
handles.output = hObject;
8 e! ]% O F. D2 o2 R
% Update handles structure
guidata(hObject, handles);
& c! D# a- p- @% d7 K
% UIWAIT makes CT_image_FCM wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% [- ?4 B" x6 h0 N+ b
: z# A" U2 G4 \" h; L2 {) r
% --- Outputs from this function are returned to the command line.
function varargout = CT_image_FCM_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)
" w; _+ ~ ^& w- v" g
% Get default command line output from handles structure
varargout{1} = handles.output;
! H, ~, f1 Z: F, m" H
6 r8 i) j/ }$ B3 Z5 l3 E
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I
[filename, pathname]= ...
uigetfile({'*.*';'*.bmp';'*.tif';'*.png';'*.jpg'},'select picture');
str= [pathname filename];
I= imread(str);
axes(handles.axes1);
imshow(I);
title('原图');
. Q- ~" e) B2 R4 A: D- K
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
2 O. P, |! y* }2 ]
8 z/ w4 O, q$ D
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I I0 A
[I2,clusterResult] = FCM1(I, 4,[0 80 160 255],2,150,1e-5);
axes(handles.axes3);
imshow(I2)
I0=I2;
A=unique(I0);
" Q/ Z: Y) v' j. p! p5 F3 Z
! C; i0 h1 k4 @5 x7 j
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I0 A
I0_2=zeros(size(I0,1),size(I0,2));
for i=1:size(I0,1)
for j=1:size(I0,2)
if I0(i,j)==A(2)
I0_2(i,j)=255;
else I0_2(i,j)=0;
end
end
end
I0_2=uint8(I0_2);
axes(handles.axes4);
imshow(I0_2);
' T* D% T# H$ A* b6 `" |. W' v
4 {+ I. v7 h; F5 E# l
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I0 A
I0_3=zeros(size(I0,1),size(I0,2));
for i=1:size(I0,1)
for j=1:size(I0,2)
if I0(i,j)==A(3)
I0_3(i,j)=255;
else I0_3(i,j)=0;
end
end
end
I0_3=uint8(I0_3);
axes(handles.axes5);
imshow(I0_3);
, [. k; a8 q' v* {& s
! a. P7 L- e; X! b7 A( Q& e3 U! X
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I0 A
I0_4=zeros(size(I0,1),size(I0,2));
for i=1:size(I0,1)
for j=1:size(I0,2)
if I0(i,j)==A(4)
I0_4(i,j)=255;
else I0_4(i,j)=0;
end
end
end
I0_4=uint8(I0_4);
axes(handles.axes6);
imshow(I0_4);
8 A- ]% ^6 m" D
9 |4 P3 m! m) t- _2 D
/ f4 u+ v2 r+ h" c# S; f8 t
: O+ l; N4 k" C) T; d: e$ ?8 D
function varargout = CT_image_GFCM(varargin)
% CT_IMAGE_GFCM MATLAB code for CT_image_GFCM.fig
% CT_IMAGE_GFCM, by itself, creates a new CT_IMAGE_GFCM or raises the existing
% singleton*.
%
% H = CT_IMAGE_GFCM returns the handle to a new CT_IMAGE_GFCM or the handle to
% the existing singleton*.
%
% CT_IMAGE_GFCM('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CT_IMAGE_GFCM.M with the given input arguments.
%
% CT_IMAGE_GFCM('Property','Value',...) creates a new CT_IMAGE_GFCM or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before CT_image_GFCM_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to CT_image_GFCM_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
, u/ q( g$ Z$ W9 U! }4 P9 x. w( h
% Edit the above text to modify the response to help CT_image_GFCM
# u# k5 `1 [5 B: X9 d% `
% Last Modified by GUIDE v2.5 13-Apr-2020 21:47:11
: ^- E$ z5 |) \) E& s2 e$ \; @/ O
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @CT_image_GFCM_OpeningFcn, ...
'gui_OutputFcn', @CT_image_GFCM_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
4 D2 t6 p" k. V9 e! [7 S
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
! t# w7 }6 T8 L
$ H3 ?. T5 {, ~* L: L
% --- Executes just before CT_image_GFCM is made visible.
function CT_image_GFCM_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 CT_image_GFCM (see VARARGIN)
& D3 j5 c C; V: e
% Choose default command line output for CT_image_GFCM
handles.output = hObject;
~! K* Q/ n; b& |( w( D
% Update handles structure
guidata(hObject, handles);
+ g/ x% N# x: U' r D. J& |7 F% B
% UIWAIT makes CT_image_GFCM wait for user response (see UIRESUME)
% uiwait(handles.figure1);
! L- @5 O+ v3 p+ ?0 V% W, ]
5 P" D% n o" X3 n
% --- Outputs from this function are returned to the command line.
function varargout = CT_image_GFCM_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)
6 I% D( ~( D- ~1 S
% Get default command line output from handles structure
varargout{1} = handles.output;
- J* L- |0 X0 k. l" x" l3 n4 O
- U. _: ^" P1 f& e& N
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I
[filename, pathname]= ...
uigetfile({'*.*';'*.bmp';'*.tif';'*.png';'*.jpg'},'select picture');
str= [pathname filename];
I= imread(str);
axes(handles.axes1);
imshow(I);
title('原图');
) W1 z1 Z' r4 ~1 U
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I
I=medfilt2(I,[3,3]);
axes(handles.axes2);
imshow(I)
" }# k+ w7 b1 u
7 v, P3 E3 X5 J7 h, ^
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I r c U
[r,c] = size(I);
data = zeros(r*c,1);
for i = 1:r
for j = 1:c
data((i-1)*c+j,1) = double(I(i,j));
end
end
[center, U, obj_fcn] = GFCM(data,4,0.9);
& o5 n9 K; }" O/ m) G$ Y9 A2 N: T
for i = 1 : r
for j = 1 : c
temp = (double(I(i, j)) - center) .^ 2;
[fmin pos] = min(temp);
I(i, j) = uint8(pos * 255 / 4);
end
end
axes(handles.axes3);
imshow(I)
, [8 v6 s4 [; N) ~& ^' @
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I r c U
I_seg2 = I*0;
for i = 1:r
for j = 1:c
if U(1,(i-1)*c+j)<U(2,(i-1)*c+j)
I_seg2(i,j) =0 ;
else
I_seg2(i,j) =255;
end
end
end
axes(handles.axes4);
imshow(I_seg2)
' p8 D/ ]8 Z! S9 a3 n9 ?
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I r c U
I_seg3 = I*0;
for i = 1:r
for j = 1:c
if U(1,(i-1)*c+j)<U(3,(i-1)*c+j)
I_seg3(i,j) =0 ;
else
I_seg3(i,j) =255;
end
end
end
axes(handles.axes5);
imshow(I_seg3)
- _0 U( }2 Y9 |, J
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I r c U
I_seg4 = I*0;
for i = 1:r
for j = 1:c
if U(1,(i-1)*c+j)<U(4,(i-1)*c+j)
I_seg4(i,j) =0 ;
else
I_seg4(i,j) =255;
end
end
end
axes(handles.axes6);
imshow(I_seg4)
/ V# |9 F( y/ T: j
9 T, ^% }& D" T& K0 ]$ t, y$ ^
& K& Y0 A" O' g4 L5 Z% t
$ O+ n* M0 g3 H8 `
二、运行结果
- L4 E1 F: [! b3 u9 c! k2 g
6 _8 o5 z; n: }8 v
2.png
(150.19 KB, 下载次数: 8)
下载附件
保存到相册
2021-4-22 13:23 上传
0 v; V: Z9 ~3 v9 W
6 y; Z5 z, [% e: c v4 z) \
3.png
(106.83 KB, 下载次数: 8)
下载附件
保存到相册
2021-4-22 13:23 上传
( c6 w3 R3 e( N- P8 y1 L, E
作者:
NNNei256
时间:
2021-4-22 14:50
基于matlab FCM和改进的FCM脑部CT图像聚类
作者:
twel2e
时间:
2021-4-25 17:05
收藏到源代码库
2 e4 n" O6 n7 m. u: b
欢迎光临 EDA365电子论坛网 (https://bbs.eda365.com/)
Powered by Discuz! X3.2