Pengolahan Citra CT Scan Paru-Paru dengan Metode Segmentasi Active Contour


Penelitian mengenai pengolahan citra medis telah banyak dilakukan dengan mengembangkan berbagai macam metode. Penelitian yang dilakukan di antaranya bertujuan untuk meningkatkan kualitas citra agar citra lebih mudah diinterpretasi dan untuk menganalisis citra secara objektif. Berikut ini merupakan contoh pemrograman MATLAB untuk melakukan pengolahan citra CT Scan Paru-Paru dengan metode segmentasi active contour. Citra diakuisisi dengan modalitas pesawat CT Scan berformat DICOM (Digital Imaging and Communications in Medicine). Pengolahan citra dilakukan untuk menghitung luas dan keliling daerah paru-paru.

Langkah-langkah pemrogramannya adalah sebagai berikut:
1. Membaca citra asli

clc; clear; close all; warning off all;

Img = dicomread('1');
figure,imshow(Img,[])
title('Citra Asli')

2. Inisialisasi masking untuk proses segmentasi

h = imrect;
setColor(h,'b')
mask = createMask(h);

3. Segmentasi daerah paru dengan metode active contour

bw = activecontour(Img,mask,1000);
bw = imfill(bw,'holes');
bw = bwareaopen(bw,500);
bw = imclearborder(bw);

figure, imshow(bw);
title('Citra Biner')

4. Menampilkan citra hasil segmentasi

figure, imshow(Img,[])
title('Hasil Segmentasi')
axis off
hold on
[c,~] = bwboundaries(bw,'noholes');
for k = 1:length(c)
    boundary = c{k};
    plot(boundary(:,2), boundary(:,1),'y','LineWidth',3)
end
hold off

5. Menghitung luas dan keliling daerah paru hasil segmentasi

s = regionprops(bw, 'area','perimeter');
area_bw = cat(1, s.Area);
perim_bw = cat(1, s.Perimeter);

res = 1.362; % resolusi spasial 1.362 pixel/mm
area = area_bw/(res^2)/100
perimeter = perim_bw/res/10

6. Mengimplementasikan sistem pengolahan citra ke dalam GUI MATLAB
a. Tampilan awal GUI

b. Membuka citra asli

c. Inisialisasi masking untuk proses segmentasi

d. Proses segmentasi dengan metode active contour

e. Menghitung luas dan keliling daerah paru hasil segmentasi

f. Melakukan segmentasi pada daerah yang lain

g. Melakukan segmentasi pada daerah yang lain

Tampilan source code matlab untuk pengolahan citra CT Scan paru-paru adalah sebagai berikut:


function varargout = pengolahan_citra_paru(varargin)
% PENGOLAHAN_CITRA_PARU MATLAB code for pengolahan_citra_paru.fig
%      PENGOLAHAN_CITRA_PARU, by itself, creates a new PENGOLAHAN_CITRA_PARU or raises the existing
%      singleton*.
%
%      H = PENGOLAHAN_CITRA_PARU returns the handle to a new PENGOLAHAN_CITRA_PARU or the handle to
%      the existing singleton*.
%
%      PENGOLAHAN_CITRA_PARU('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in PENGOLAHAN_CITRA_PARU.M with the given input arguments.
%
%      PENGOLAHAN_CITRA_PARU('Property','Value',...) creates a new PENGOLAHAN_CITRA_PARU or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before pengolahan_citra_paru_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to pengolahan_citra_paru_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 pengolahan_citra_paru

% Last Modified by GUIDE v2.5 23-Feb-2018 18:41:08

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @pengolahan_citra_paru_OpeningFcn, ...
    'gui_OutputFcn',  @pengolahan_citra_paru_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 pengolahan_citra_paru is made visible.
function pengolahan_citra_paru_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 pengolahan_citra_paru (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);
movegui(hObject,'center');

% UIWAIT makes pengolahan_citra_paru wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = pengolahan_citra_paru_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)
% 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)
[filename, pathname] = uigetfile('*.*');

if ~isequal(filename,0)
    set(handles.pushbutton2,'Enable','on')
    
    axes(handles.axes1)
    cla reset
    set(gca,'XTick',[])
    set(gca,'YTick',[])
    
    axes(handles.axes2)
    cla reset
    set(gca,'XTick',[])
    set(gca,'YTick',[])
    
    axes(handles.axes3)
    cla reset
    set(gca,'XTick',[])
    set(gca,'YTick',[])
    
    Img = dicomread(fullfile(pathname, filename));
    axes(handles.axes1)
    imshow(Img,[])
    title('Citra Asli')
    set(handles.pushbutton2,'Enable','on')
    set(handles.pushbutton3,'Enable','off')
else
    return
end

handles.Img = Img;
guidata(hObject, handles)

% --- 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)
Img = handles.Img;

axes(handles.axes2)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])

axes(handles.axes3)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])

set(handles.pushbutton3,'Enable','off')
set(handles.edit1,'String',[])
set(handles.edit2,'String',[])

axes(handles.axes1)
cla reset
imshow(Img,[])
title('Citra Asli')
h = imrect;
setColor(h,'b')
mask = createMask(h);
% delete(h);
bw = activecontour(Img,mask,1000);
bw = imfill(bw,'holes');
bw = bwareaopen(bw,500);
bw = imclearborder(bw);

axes(handles.axes2)
cla reset
imshow(Img,[])
title('Hasil Segmentasi')
axis off
hold on
[c,~] = bwboundaries(bw,'noholes');
for k = 1:length(c)
    boundary = c{k};
    plot(boundary(:,2), boundary(:,1),'y','LineWidth',3)
end
hold off

axes(handles.axes3)
cla reset
imshow(bw)
title('Citra Biner')

set(handles.pushbutton3,'Enable','on')

handles.bw = bw;
guidata(hObject, handles)

% --- 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)
bw = handles.bw;

s  = regionprops(bw, 'area','perimeter');
area_bw = cat(1, s.Area);
perim_bw = cat(1, s.Perimeter);

res = 1.362; % resolusi spasial 1.362 pixel/mm
area = area_bw/(res^2)/100;
perimeter = perim_bw/res/10;

set(handles.edit1,'String',[num2str(area),' cm2'])
set(handles.edit2,'String',[num2str(perimeter),' cm'])

% --- 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)
axes(handles.axes1)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])

axes(handles.axes2)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])

axes(handles.axes3)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])

set(handles.edit1,'String',[])
set(handles.edit2,'String',[])

set(handles.pushbutton2,'Enable','off')
set(handles.pushbutton3,'Enable','off')

function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (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



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (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

Source code dan citra pada pemrograman di atas dapat diperoleh pada halaman berikut ini: Source Code

Posted on February 24, 2018, in Pengolahan Citra and tagged , , , , , , , , , , , , , , , . Bookmark the permalink. 5 Comments.

  1. permisi mas adi,
    saya mau tanya mas, itu untuk imagenya untuk ekstensinya file gitu ya mas, kalo saya ingin menginput gambar lain selain disitu caranya gimana ya biar bisa ke detect? terimakasih mas adi

  2. Mas Adi, untuk mendapatkan dataset citra medis seperti itu dari website mana ya mas? Soalnya saya butuh untuk thesis saya. Karena kalau meminta data dari pihak rumah sakitnya, prosesnya agak lama. Thx mas.

  1. Pingback: Pengolahan Citra CT Scan Paru-Paru dengan Metode Segmentasi Active Contour – Images Processing

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: