【細(xì)胞分割】基于形態(tài)學(xué)算法實(shí)現(xiàn)紅細(xì)胞計(jì)數(shù)matlab源碼含 GUI
一、簡介
很多臨床病癥表現(xiàn)為白細(xì)胞數(shù)目增多、腫大或者白細(xì)胞中細(xì)胞核形狀與數(shù)目發(fā)生變化,所以對白細(xì)胞數(shù)目和形狀的研究有著重要意義。但是由于染色條件、涂片制備、圖像來源、采樣光照條件的差異以及細(xì)胞間相互重疊、粘連情況的發(fā)生,使得對白細(xì)胞的計(jì)數(shù)和識別等后續(xù)分析變得困難。為此,將粘連細(xì)胞分割成為單個細(xì)胞,就成為醫(yī)學(xué)圖像處理中必須解決的問題。本文基于MATLAB語言進(jìn)行圖像的處理以及分割,準(zhǔn)確的處理圖片,采用分水嶺算法和閾值分割來實(shí)現(xiàn),在現(xiàn)有研究基礎(chǔ)之上,重點(diǎn)基于數(shù)字圖像處理技術(shù)解決顯微圖像細(xì)胞計(jì)數(shù)這一思路,結(jié)合血液紅細(xì)胞的主要特點(diǎn),設(shè)定所要達(dá)到的目標(biāo)和要求,設(shè)計(jì)和實(shí)現(xiàn)一個快速有效的血液顯微圖像紅細(xì)胞數(shù)量自動統(tǒng)計(jì)系統(tǒng)。
1 課程設(shè)計(jì)任務(wù)
細(xì)胞數(shù)目檢測在現(xiàn)實(shí)生活中的意義主要體現(xiàn)在醫(yī)學(xué)上的作用,可通過細(xì)胞數(shù)目的檢測來查看并估計(jì)病人或動物的血液中細(xì)胞數(shù),如估測血液中紅細(xì)胞、白細(xì)胞、血小板、淋巴細(xì)胞等細(xì)胞的數(shù)目,同時也可檢測癌細(xì)胞的數(shù)目來查看醫(yī)療效果,根據(jù)這一系列的指標(biāo)來對病人或動物進(jìn)行治療。
(1)對細(xì)胞圖像進(jìn)行預(yù)處理;
(2)進(jìn)行圖像分割;
(3)統(tǒng)計(jì)細(xì)胞數(shù)目;
(4)要求自行設(shè)計(jì)方案,編寫代碼實(shí)現(xiàn)上述功能,并設(shè)計(jì)細(xì)胞統(tǒng)計(jì)的軟件界面。
2 設(shè)計(jì)原理
圖像分割是根據(jù)醫(yī)學(xué)圖像的某個可以處理的特性(如光學(xué)密度值、灰度值、CT值、頻譜等),利用醫(yī)學(xué)圖像區(qū)域內(nèi)的相似性和區(qū)域間的差異性將醫(yī)學(xué)圖像分割成若干個互不連通區(qū)域的過程。
將圖像表示為物理上有意義的連通區(qū)域的集合,也就是根據(jù)目標(biāo)與背景的先驗(yàn)知識,對圖像中的目標(biāo)、背景進(jìn)行標(biāo)記、定位,然后將目標(biāo)從背景或其他偽目標(biāo)中分離出來。由于這些被分割的區(qū)域在某些特性上相近,因而,圖像分割常用于模式識別與圖像理解以及圖像壓縮與編碼兩大類不同的應(yīng)用目的。
3 設(shè)計(jì)流程
流程:首先將圖像依次轉(zhuǎn)化為灰度圖像,二值圖像。然后對二值圖像進(jìn)行中值濾波,并刪除小面積對象(刪除白色底面里面的黑色小點(diǎn))。 其次,將圖像反相,并刪除小面積對象(相當(dāng)于刪除了二值圖像里面黑色底面的白色小點(diǎn))。 再次,對圖像進(jìn)行形態(tài)學(xué)運(yùn)算處理。最后,標(biāo)記紅細(xì)胞,用貼標(biāo)簽的方法統(tǒng)計(jì)紅細(xì)胞數(shù)目,目標(biāo)實(shí)現(xiàn)。

二、源代碼
function varargout = untitled(varargin)
% UNTITLED M-file for untitled.fig
% ? ? ?UNTITLED, by itself, creates a new UNTITLED or raises the existing
% ? ? ?singleton*.
%
% ? ? ?H = UNTITLED returns the handle to a new UNTITLED or the handle to
% ? ? ?the existing singleton*.
%
% ? ? ?UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% ? ? ?function named CALLBACK in UNTITLED.M with the given input arguments.
%
% ? ? ?UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% ? ? ?existing singleton*. ?Starting from the left, property value pairs are
% ? ? ?applied to the GUI before untitled_OpeningFcn gets called. ?An
% ? ? ?unrecognized property name or invalid value makes property application
% ? ? ?stop. ?All inputs are passed to untitled_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
% Edit the above text to modify the response to help untitled
% Last Modified by GUIDE v2.5 02-Dec-2015 08:59:09
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', ? ? ? mfilename, ...
? ? ? ? ? ? ? ? ? 'gui_Singleton', ?gui_Singleton, ...
? ? ? ? ? ? ? ? ? 'gui_OpeningFcn', @untitled_OpeningFcn, ...
? ? ? ? ? ? ? ? ? 'gui_OutputFcn', ?@untitled_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 untitled is made visible.
function untitled_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 untitled (see VARARGIN)
% Choose default command line output for untitled
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_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 on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
axes(handles.axes1);
I=imread('blood.BMP');
imshow(I);
% 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)
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
axes(handles.axes2);
I=imread('blood.BMP');
imshow(I);
gg=im2bw(I);
imshow(gg)
% 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)
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
axes(handles.axes2);
I=imread('blood.BMP');
imshow(I);
gg=im2bw(I);
imshow(gg)
J=medfilt2(gg,[3 3]);
imshow(J);
% 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)
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
axes(handles.axes2);
I=imread('blood.BMP');
imshow(I);
gg=im2bw(I);
imshow(gg)
J=medfilt2(gg,[3 3]);
imshow(J);
M=gg|J;
imshow(M);
% 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)
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
axes(handles.axes2);
I=imread('blood.BMP');
imshow(I);
gg=im2bw(I);
imshow(gg)
J=medfilt2(gg,[3 3]);
imshow(J);
M=gg|J;
imshow(M);
R=~M;
imshow(R)
% hObject ? ?handle to pushbutton7 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ? ?structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
axes(handles.axes2);
I=imread('blood.BMP');
imshow(I);
gg=im2bw(I);
imshow(gg)
J=medfilt2(gg,[3 3]);
imshow(J);
M=gg|J;
imshow(M);
R=~M;
imshow(R)
F=bwfill(R,'holes');
imshow(F);
三、運(yùn)行結(jié)果


?