Matlab 1.docx

  • Uploaded by: Rafi Haidar
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Matlab 1.docx as PDF for free.

More details

  • Words: 1,445
  • Pages: 16
Pemrograman Matlab Pengolahan Citra Digital, Pengolahan Video, Pengenalan Pola, dan Data Mining

Pengolahan Citra CT Scan Paru-Paru dengan Metode Segmentasi Active Contour Pengolahan citra medis telah banyak dilakukan dengan mengembangkan berbagai macam metode. Pengolahan 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 ParuParu 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 1. Membaca citra asli

pemrogramannya

1clc; clear; close all; warning off all; 2 3Img = dicomread('1'); 4figure,imshow(Img,[]) 5title('Citra Asli')

adalah

sebagai

berikut:

2. Inisialisasi masking untuk proses segmentasi 1h = imrect; 2setColor(h,'b') 3mask = createMask(h);

3. Segmentasi daerah paru dengan metode active contour 1bw = activecontour(Img,mask,1000); 2bw = imfill(bw,'holes'); 3bw = bwareaopen(bw,500); 4bw = imclearborder(bw); 5 6figure, imshow(bw); title('Citra Biner') 7

4. Menampilkan citra hasil segmentasi 1 2 figure, imshow(Img,[]) title('Hasil Segmentasi') 3 axis off 4 hold on 5 [c,~] = bwboundaries(bw,'noholes'); 6 for k = 1:length(c) boundary = c{k}; 7 plot(boundary(:,2), boundary(:,1),'y','LineWidth',3) 8 end 9 hold off 10

5. Menghitung luas dan keliling daerah paru hasil segmentasi 1s = regionprops(bw, 'area','perimeter'); 2area_bw = cat(1, s.Area); 3perim_bw = cat(1, s.Perimeter); 4 5res = 1.362; % resolusi spasial 1.362 pixel/mm 6area = area_bw/(res^2)/100 perimeter = perim_bw/res/10 7

6. a.

Mengimplementasikan sistem Tampilan

pengolahan

citra

ke dalam awal

GUI

MATLAB GUI

b.

c.

Membuka

Inisialisasi

masking

citra

untuk

asli

proses

segmentasi

d.

Proses

e.

Menghitung

segmentasi

luas

dan

dengan

keliling

metode

daerah

paru

active

contour

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: 1 2 3 4

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*.

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

% % 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.

51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

% hObject % eventdata % handles % varargin VARARGIN)

handle to figure reserved - to be defined in a future version of MATLAB structure with handles and user data (see GUIDATA) command line arguments to pengolahan_citra_paru (see

% 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)); 97 axes(handles.axes1) 98 imshow(Img,[]) 99 title('Citra Asli') 100 set(handles.pushbutton2,'Enable','on') set(handles.pushbutton3,'Enable','off') 101 102else 103end return 104 105handles.Img = Img; 106guidata(hObject, handles) 107 108% --- Executes on button press in pushbutton2. 109function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) 110% eventdata reserved - to be defined in a future version of MATLAB 111% handles structure with handles and user data (see GUIDATA) 112Img = handles.Img; 113 114axes(handles.axes2) reset 115cla set(gca,'XTick',[]) 116set(gca,'YTick',[]) 117 118axes(handles.axes3) 119cla reset 120set(gca,'XTick',[]) set(gca,'YTick',[]) 121 122set(handles.pushbutton3,'Enable','off') 123set(handles.edit1,'String',[]) 124set(handles.edit2,'String',[]) 125 126axes(handles.axes1) 127cla reset imshow(Img,[]) 128title('Citra Asli') 129h = imrect; 130setColor(h,'b') 131mask = createMask(h); 132%bwdelete(h); = activecontour(Img,mask,1000); 133bw = imfill(bw,'holes'); 134bw = bwareaopen(bw,500); 135bw = imclearborder(bw); 136 137axes(handles.axes2) cla reset 138imshow(Img,[]) 139title('Hasil Segmentasi') 140axis off 141hold on = bwboundaries(bw,'noholes'); 142[c,~] for k = 1:length(c)

boundary = c{k}; 143 plot(boundary(:,2), boundary(:,1),'y','LineWidth',3) 144 end 145hold off 146 147axes(handles.axes3) 148cla reset 149imshow(bw) 150title('Citra Biner') 151set(handles.pushbutton3,'Enable','on') 152 153handles.bw = bw; 154guidata(hObject, handles) 155 156% --- Executes on button press in pushbutton3. 157function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) 158% eventdata reserved - to be defined in a future version of MATLAB 159% handles structure with handles and user data (see GUIDATA) 160bw = handles.bw; 161 162s = regionprops(bw, 'area','perimeter'); = cat(1, s.Area); 163area_bw perim_bw = cat(1, s.Perimeter); 164 165res = 1.362; % resolusi spasial 1.362 pixel/mm 166area = area_bw/(res^2)/100; 167perimeter = perim_bw/res/10; 168 169set(handles.edit1,'String',[num2str(area),' cm2']) set(handles.edit2,'String',[num2str(perimeter),' cm']) 170 171% --- Executes on button press in pushbutton4. 172function pushbutton4_Callback(hObject, eventdata, handles) 173% hObject handle to pushbutton4 (see GCBO) 174% eventdata reserved - to be defined in a future version of MATLAB structure with handles and user data (see GUIDATA) 175% handles axes(handles.axes1) 176cla reset 177set(gca,'XTick',[]) 178set(gca,'YTick',[]) 179 180axes(handles.axes2) reset 181cla set(gca,'XTick',[]) 182set(gca,'YTick',[]) 183 184axes(handles.axes3) 185cla reset 186set(gca,'XTick',[]) set(gca,'YTick',[]) 187 188set(handles.edit1,'String',[])

189set(handles.edit2,'String',[]) 190 191set(handles.pushbutton2,'Enable','off') set(handles.pushbutton3,'Enable','off') 192 193function edit1_Callback(hObject, eventdata, handles) 194% hObject handle to edit1 (see GCBO) 195% eventdata reserved - to be defined in a future version of MATLAB structure with handles and user data (see GUIDATA) 196% handles 197 get(hObject,'String') returns contents of edit1 as text 198%% Hints: str2double(get(hObject,'String')) returns contents of edit1 as a 199double 200 201 202% --- Executes during object creation, after setting all properties. 203function edit1_CreateFcn(hObject, eventdata, handles) handle to edit1 (see GCBO) 204% hObject % eventdata reserved - to be defined in a future version of MATLAB 205% handles empty - handles not created until after all CreateFcns called 206 207% Hint: edit controls usually have a white background on Windows. See ISPC and COMPUTER. 208% 209if ispc && isequal(get(hObject,'BackgroundColor'), 210get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); 211end 212 213 214 215function edit2_Callback(hObject, eventdata, handles) handle to edit2 (see GCBO) 216% hObject % eventdata reserved - to be defined in a future version of MATLAB 217 % handles structure with handles and user data (see GUIDATA) 218 219% Hints: get(hObject,'String') returns contents of edit2 as text 220% str2double(get(hObject,'String')) returns contents of edit2 as a 221double 222 223 224% --- Executes during object creation, after setting all properties. 225function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) 226% eventdata reserved - to be defined in a future version of MATLAB 227% handles empty - handles not created until after all CreateFcns called 228 229% Hint: edit controls usually have a white background on Windows. See ISPC and COMPUTER. 230% if ispc && isequal(get(hObject,'BackgroundColor'), 231get(0,'defaultUicontrolBackgroundColor')) 232 set(hObject,'BackgroundColor','white'); 233end 234

235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 Source code dan citra pada pemrograman di atas dapat diunduh pada halaman berikut ini: Source Code

Segmentasi Citra dengan Metode Thresholding In "Pengolahan Citra"

Pengolahan Citra Digital

In "Pengolahan Citra"

Pengolahan Citra Biner

Related Documents

Matlab
July 2020 24
Matlab
May 2020 31
Matlab
April 2020 36
Matlab
May 2020 39
Matlab
August 2019 56
Matlab
November 2019 32

More Documents from ""

Matlab 1.docx
June 2020 13
Silabus-tik
June 2020 28
Klasifikasi Polimer
May 2020 26
Cocard
August 2019 37