Implementasi Dan Perbandingan Metode Geometric Mean Filter Dan Alpha-Trimmed Mean Filter Untuk Mereduksi Exponential Noise Pada Citra Digital

  

LAMPIRAN A

LISTING PROGRAM

  1. Kode Program Figure Mainform

  function varargout = Mainform(varargin) gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Mainform_OpeningFcn, ... 'gui_OutputFcn', @Mainform_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 function Mainform_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; guidata(hObject, handles); function varargout = Mainform_OutputFcn(hObject, eventdata, handles) citra = imread('USU.JPEG'); axes(handles.logo); imshow(citra); varargout{1} = handles.output; function about_Callback(hObject, eventdata, handles) About function help_Callback(hObject, eventdata, handles) Help function exit_Callback(hObject, eventdata, handles) pilihan=questdlg(['Do You Want to Exit ?'],['Exit'],'Yes','No','Yes'); if strcmp(pilihan,'No') return; else close all end function reduction1_Callback(hObject, eventdata, handles) Reduction1 close(gcbf);

  function figure1_DeleteFcn(hObject, eventdata, handles) function Reduction2_Callback(hObject, eventdata, handles) Reduction2 close(gcbf);

  2. Kode Program Figure Menu Reduction Undefined Noise + Exponential Noise

  function varargout = Reduction1(varargin) gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Reduction1_OpeningFcn, ... 'gui_OutputFcn', @Reduction1_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 global runtimeMed; function Reduction1_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; guidata(hObject, handles); function varargout = Reduction1_OutputFcn(hObject, eventdata, handles) varargout{1} = handles.output; function mse1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function reduce_noise1_Callback(hObject, eventdata, handles) global runtimeMed; runtimeMed = cputime; Citraasal = getimage(handles.axes1); A= getimage(handles.axes2); hObject = waitbar(0,'1','Name','Processing'); for step = 1:1000 waitbar(step/1000,hObject,sprintf('Processing...')) end delete(hObject)

  ukuran=3; B=geometric(A,ukuran); axes(handles.axes3); imshow(B) runtimeMed=cputime-runtimeMed; Citrahasil= getimage(handles.axes3); [NilaiMSE PSNR]=HitungMSE(Citraasal,Citrahasil); set(handles.mse1,'String',NilaiMSE); set(handles.psnr1,'String',PSNR); set(handles.runtime1,'String',runtimeMed); set(handles.save1,'Enable','on'); function save1_Callback(hObject, eventdata, handles) [nama_file,nama_path] = uiputfile({'*.bmp';'*.*'},'Save Image'); if isequal([nama_file,nama_path],[0,0]); return else citra = getimage(handles.axes3); imwrite(citra,strcat(nama_path,nama_file)); warndlg('Succes save file','Warning') end function generate_noise1_Callback(hObject, eventdata, handles) indeks=get(handles.popupmenu1,'Value'); switch indeks case 1 a = helpdlg('Please choose noise probability'); case 2 a = 0.01; case 3 a = 0.02; case 4 a = 0.03; case 5 a = 0.04; case 6 a = 0.05; end handles.a=a; a=handles.a; if (0.05>=a>=0.01) A = getimage(handles.axes1); B=double(A); [m,n] = size(A); for i = 1:m for j = 1:n noise = -1/a*log(1-rand); B(i,j) = round(A(i,j)+noise); if B(i,j) > 255 B(i,j) = 255; end end end

  B=uint8(B); axes(handles.axes2); imshow(B) set(handles.reduce_noise1,'Enable','on'); end function browse_Callback(hObject, eventdata, handles) [nama_file,nama_path]=uigetfile({'*.bmp','Image File(*.bmp)'},'Browse Image'); if ~isequal(nama_file,0) info = imfinfo([nama_path, nama_file]); lokasi = info.Filename ukuran_file = info.FileSize/1024 height = info.Height; width = info.Width; handles.citra=imread(fullfile(nama_path,nama_file)); guidata(hObject,handles); axes(handles.axes1); imshow(handles.citra); set(handles.lokasi1, 'String', lokasi); set(handles.ukuran_file1, 'String', ukuran_file); set(handles.dimensi1,'String',width); set(handles.dimensi2,'String',height); set(handles.nama_file1,'String',nama_file); set(handles.generate_noise1,'Enable','on'); else return end; function reset_all_Callback(hObject, eventdata, handles) handles.citra = handles.reset; guidata(hObject,handles); axes(handles.axes1); imshow(handles.citra); axes(handles.axes2); imshow(handles.citra); axes(handles.axes3); imshow(handles.citra); axes(handles.axes4); imshow(handles.citra); axes(handles.axes5); imshow(handles.citra); axes(handles.axes6); imshow(handles.citra); set(handles.dimensi1,'string',''); set(handles.dimensi2,'string',''); set(handles.nama_file1,'string',''); set(handles.lokasi1,'string',''); set(handles.ukuran_file1,'string',''); set(handles.mse1,'string',''); set(handles.psnr1,'string',''); set(handles.runtime1,'string',''); set(handles.generate_noise1,'Enable','off'); set(handles.reduce_noise1,'Enable','off'); set(handles.save1,'Enable','off'); set(handles.dimensi3,'string',''); set(handles.dimensi4,'string',''); set(handles.nama_file2,'string',''); set(handles.lokasi2,'string',''); set(handles.ukuran_file2,'string',''); set(handles.mse2,'string',''); set(handles.psnr2,'string',''); set(handles.runtime2,'string',''); set(handles.generate_noise2,'Enable','off'); set(handles.reduce_noise2,'Enable','off'); set(handles.save2,'Enable','off'); set(handles.popupmenu1,'Value',1); set(handles.popupmenu2,'Value',1); set(handles.popupmenu3,'Value',1); function back_Callback(hObject, eventdata, handles) pilihan=questdlg(['Back to Main Menu ?'],['Exit'],'Yes','No','Yes'); if strcmp(pilihan,'No') return; else close(gcbf); Mainform; end function back_CreateFcn(hObject, eventdata, handles) function dimensi2_Callback(hObject, eventdata, handles) function dimensi2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function nama_file1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function psnr1_Callback(hObject, eventdata, handles) function psnr1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function dimensi1_Callback(hObject, eventdata, handles) function dimensi1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end function lokasi1_Callback(hObject, eventdata, handles) function lokasi1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function ukuran_file1_Callback(hObject, eventdata, handles) function ukuran_file1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function popupmenu1_Callback(hObject, eventdata, handles) function popupmenu1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function reset_Callback(hObject, eventdata, handles) handles.citra = handles.reset; guidata(hObject,handles); axes(handles.axes1); imshow(handles.citra); axes(handles.axes2); imshow(handles.citra); axes(handles.axes3); imshow(handles.citra); set(handles.dimensi1,'string',''); set(handles.dimensi2,'string',''); set(handles.nama_file1,'string',''); set(handles.lokasi1,'string',''); set(handles.ukuran_file1,'string',''); set(handles.mse1,'string',''); set(handles.psnr1,'string',''); set(handles.runtime1,'string',''); set(handles.generate_noise1,'Enable','off'); set(handles.reduce_noise1,'Enable','off'); set(handles.save1,'Enable','off'); set(handles.popupmenu1,'Value',1) function runtime1_Callback(hObject, eventdata, handles) function runtime1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white'); end function dimensi3_Callback(hObject, eventdata, handles) function dimensi3_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function browse2_Callback(hObject, eventdata, handles) [nama_file,nama_path]=uigetfile({'*.bmp','Image File(*.bmp)'},'Browse Image'); if ~isequal(nama_file,0) info = imfinfo([nama_path, nama_file]); lokasi = info.Filename ukuran_file = info.FileSize/1024 height = info.Height; width = info.Width; handles.citra=imread(fullfile(nama_path,nama_file)); guidata(hObject,handles); axes(handles.axes4); imshow(handles.citra); set(handles.lokasi2, 'String', lokasi); set(handles.ukuran_file2, 'String', ukuran_file); set(handles.dimensi3,'String',width); set(handles.dimensi4,'String',height); set(handles.nama_file2,'String',nama_file); set(handles.generate_noise2,'Enable','on'); else return end; function dimensi4_Callback(hObject, eventdata, handles) function dimensi4_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function nama_file2_Callback(hObject, eventdata, handles) function nama_file2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function lokasi2_Callback(hObject, eventdata, handles) function lokasi2_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function ukuran_file2_Callback(hObject, eventdata, handles) function ukuran_file2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function runtime2_Callback(hObject, eventdata, handles) function runtime2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function mse2_Callback(hObject, eventdata, handles) function mse2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function reduce_noise2_Callback(hObject, eventdata, handles) indeks=get(handles.popupmenu3,'Value'); switch indeks case 1 d = helpdlg('Please choose value of d'); case 2 d = 0; case 3 d = 1; case 4 d = 2; case 5 d = 3; case 6 d = 4; case 7 d = 5; case 8 d = 6; case 9 d = 7; case 10 d = 8; end handles.d=d;

global runtimeMed; runtimeMed = cputime; if (8>=d>=1) Citraasal = getimage(handles.axes4); A= getimage(handles.axes5); hObject = waitbar(0,'1','Name','Processing'); for step = 1:1000 waitbar(step/1000,hObject,sprintf('Processing...')) end delete(hObject) ukuran =3; d = handles.d; B=alphatrimmed(A,ukuran,d); B=uint8(B); axes(handles.axes6); imshow(B) runtimeMed=cputime-runtimeMed; Citrahasil= getimage(handles.axes6); [NilaiMSE PSNR]=HitungMSE(Citraasal,Citrahasil); set(handles.mse2,'String',NilaiMSE); set(handles.psnr2,'String',PSNR); set(handles.runtime2,'String',runtimeMed); set(handles.save2,'Enable','on'); end function save2_Callback(hObject, eventdata, handles) [nama_file,nama_path] = uiputfile({'*.bmp';'*.*'},'Save Image'); if isequal([nama_file,nama_path],[0,0]); return else citra = getimage(handles.axes6); imwrite(citra,strcat(nama_path,nama_file)); warndlg('Success save file','Warning') end function psnr2_Callback(hObject, eventdata, handles) function psnr2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function popupmenu2_Callback(hObject, eventdata, handles) function popupmenu2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end function generate_noise2_Callback(hObject, eventdata, handles) indeks=get(handles.popupmenu2,'Value'); switch indeks case 1 a = helpdlg('Please choose noise probability'); case 2 a = 0.01; case 3 a = 0.02; case 4 a = 0.03; case 5 a = 0.04; case 6 a = 0.05; end handles.aa=a; a=handles.aa; if (0.05>=a>=0.01) A = getimage(handles.axes4); B=double(A); [m,n] = size(A); for i = 1:m for j = 1:n noise = -1/a*log(1-rand); B(i,j) = round(A(i,j)+ noise); if B(i,j) > 255 B(i,j) = 255; end end end B=uint8(B); axes(handles.axes5); imshow(B) set(handles.reduce_noise2,'Enable','on'); end function popupmenu3_Callback(hObject, eventdata, handles) function popupmenu3_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function mse1_Callback(hObject, eventdata, handles) function nama_file1_Callback(hObject, eventdata, handles) function reset2_Callback(hObject, eventdata, handles) handles.citra = handles.reset; guidata(hObject,handles);

  axes(handles.axes4); imshow(handles.citra); axes(handles.axes5); imshow(handles.citra); axes(handles.axes6); imshow(handles.citra); set(handles.dimensi3,'string',''); set(handles.dimensi4,'string',''); set(handles.nama_file2,'string',''); set(handles.lokasi2,'string',''); set(handles.ukuran_file2,'string',''); set(handles.mse2,'string',''); set(handles.psnr2,'string',''); set(handles.runtime2,'string',''); set(handles.generate_noise2,'Enable','off'); set(handles.reduce_noise2,'Enable','off'); set(handles.save2,'Enable','off'); set(handles.popupmenu2,'Value',1) set(handles.popupmenu3,'Value',1)

  3. Kode Program Figure Menu Reduction Exponential Noise

  function varargout = Reduction2(varargin) gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Reduction2_OpeningFcn, ... 'gui_OutputFcn', @Reduction2_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 global runtimeMed; function Reduction2_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; guidata(hObject, handles); function varargout = Reduction2_OutputFcn(hObject, eventdata, handles) varargout{1} = handles.output; function mse1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

  function reduce_noise1_Callback(hObject, eventdata, handles) global runtimeMed; runtimeMed = cputime; Citraasal = getimage(handles.axes1); A= getimage(handles.axes2); hObject = waitbar(0,'1','Name','Processing'); for step = 1:1000 waitbar(step/1000,hObject,sprintf('Processing...')) end delete(hObject) ukuran=3; B=geometric(A,ukuran); axes(handles.axes3); imshow(B) runtimeMed=cputime-runtimeMed; Citrahasil= getimage(handles.axes3); [NilaiMSE PSNR]=HitungMSE(Citraasal,Citrahasil); set(handles.mse1,'String',NilaiMSE); set(handles.psnr1,'String',PSNR); set(handles.runtime1,'String',runtimeMed); set(handles.save1,'Enable','on'); function save1_Callback(hObject, eventdata, handles) [nama_file,nama_path] = uiputfile({'*.bmp';'*.*'},'Save Image'); if isequal([nama_file,nama_path],[0,0]); return else citra = getimage(handles.axes3); imwrite(citra,strcat(nama_path,nama_file)); warndlg('Succes save file','Warning') end function generate_noise1_Callback(hObject, eventdata, handles) indeks=get(handles.popupmenu1,'Value'); switch indeks case 1 a = helpdlg('Please choose noise probability'); case 2 a = 0.01; case 3 a = 0.02; case 4 a = 0.03; case 5 a = 0.04; case 6 a = 0.05; end handles.a=a; a=handles.a; if (0.05>=a>=0.01) A = getimage(handles.axes1); B=double(A); [m,n] = size(A); for i = 1:m for j = 1:n noise = -1/a*log(1-rand); B(i,j) = round(A(i,j)+noise); if B(i,j) > 255 B(i,j) = 255; end end end B=uint8(B); axes(handles.axes2); imshow(B) set(handles.reduce_noise1,'Enable','on'); end function browse_Callback(hObject, eventdata, handles) [nama_file,nama_path]=uigetfile({'*.bmp','Image File(*.bmp)'},'Browse Image'); if ~isequal(nama_file,0) info = imfinfo([nama_path, nama_file]); lokasi = info.Filename ukuran_file = info.FileSize/1024 height = info.Height; width = info.Width; handles.citra=imread(fullfile(nama_path,nama_file)); guidata(hObject,handles); axes(handles.axes1); imshow(handles.citra); set(handles.lokasi1, 'String', lokasi); set(handles.ukuran_file1, 'String', ukuran_file); set(handles.dimensi1,'String',width); set(handles.dimensi2,'String',height); set(handles.nama_file1,'String',nama_file); set(handles.generate_noise1,'Enable','on'); else return end; function reset_all_Callback(hObject, eventdata, handles) handles.citra = handles.reset; guidata(hObject,handles); axes(handles.axes1); imshow(handles.citra); axes(handles.axes2); imshow(handles.citra); axes(handles.axes3); imshow(handles.citra); axes(handles.axes4); imshow(handles.citra); axes(handles.axes5); imshow(handles.citra);

axes(handles.axes6); imshow(handles.citra); set(handles.dimensi1,'string',''); set(handles.dimensi2,'string',''); set(handles.nama_file1,'string',''); set(handles.lokasi1,'string',''); set(handles.ukuran_file1,'string',''); set(handles.mse1,'string',''); set(handles.psnr1,'string',''); set(handles.runtime1,'string',''); set(handles.generate_noise1,'Enable','off'); set(handles.reduce_noise1,'Enable','off'); set(handles.save1,'Enable','off'); set(handles.dimensi3,'string',''); set(handles.dimensi4,'string',''); set(handles.nama_file2,'string',''); set(handles.lokasi2,'string',''); set(handles.ukuran_file2,'string',''); set(handles.mse2,'string',''); set(handles.psnr2,'string',''); set(handles.runtime2,'string',''); set(handles.generate_noise2,'Enable','off'); set(handles.reduce_noise2,'Enable','off'); set(handles.save2,'Enable','off'); set(handles.popupmenu1,'Value',1); set(handles.popupmenu2,'Value',1); set(handles.popupmenu3,'Value',1); function back_Callback(hObject, eventdata, handles) pilihan=questdlg(['Back to Main Menu ?'],['Exit'],'Yes','No','Yes'); if strcmp(pilihan,'No') return; else close(gcbf); Mainform; end function back_CreateFcn(hObject, eventdata, handles) function dimensi2_Callback(hObject, eventdata, handles) function dimensi2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function nama_file1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

function psnr1_Callback(hObject, eventdata, handles) function psnr1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function dimensi1_Callback(hObject, eventdata, handles) function dimensi1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function lokasi1_Callback(hObject, eventdata, handles) function lokasi1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function ukuran_file1_Callback(hObject, eventdata, handles) function ukuran_file1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function popupmenu1_Callback(hObject, eventdata, handles) function popupmenu1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function reset_Callback(hObject, eventdata, handles) handles.citra = handles.reset; guidata(hObject,handles); axes(handles.axes1); imshow(handles.citra); axes(handles.axes2); imshow(handles.citra); axes(handles.axes3); imshow(handles.citra); set(handles.dimensi1,'string',''); set(handles.dimensi2,'string',''); set(handles.nama_file1,'string',''); set(handles.lokasi1,'string',''); set(handles.ukuran_file1,'string','');

set(handles.mse1,'string',''); set(handles.psnr1,'string',''); set(handles.runtime1,'string',''); set(handles.generate_noise1,'Enable','off'); set(handles.reduce_noise1,'Enable','off'); set(handles.save1,'Enable','off'); set(handles.popupmenu1,'Value',1) function runtime1_Callback(hObject, eventdata, handles) function runtime1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function dimensi3_Callback(hObject, eventdata, handles) function dimensi3_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function browse2_Callback(hObject, eventdata, handles) [nama_file,nama_path]=uigetfile({'*.bmp','Image File(*.bmp)'},'Browse Image'); if ~isequal(nama_file,0) info = imfinfo([nama_path, nama_file]); lokasi = info.Filename ukuran_file = info.FileSize/1024 height = info.Height; width = info.Width; handles.citra=imread(fullfile(nama_path,nama_file)); guidata(hObject,handles); axes(handles.axes4); imshow(handles.citra); set(handles.lokasi2, 'String', lokasi); set(handles.ukuran_file2, 'String', ukuran_file); set(handles.dimensi3,'String',width); set(handles.dimensi4,'String',height); set(handles.nama_file2,'String',nama_file); set(handles.generate_noise2,'Enable','on'); else return end; function dimensi4_Callback(hObject, eventdata, handles) function dimensi4_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

function nama_file2_Callback(hObject, eventdata, handles) function nama_file2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function lokasi2_Callback(hObject, eventdata, handles) function lokasi2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function ukuran_file2_Callback(hObject, eventdata, handles) function ukuran_file2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function runtime2_Callback(hObject, eventdata, handles) function runtime2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function mse2_Callback(hObject, eventdata, handles) function mse2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function reduce_noise2_Callback(hObject, eventdata, handles) indeks=get(handles.popupmenu3,'Value'); switch indeks case 1 d = helpdlg('Please choose value of d'); case 2 d = 0; case 3 d = 1; case 4 d = 2; case 5 d = 3;

case 6 d = 4; case 7 d = 5; case 8 d = 6; case 9 d = 7; case 10 d = 8; end handles.d=d; global runtimeMed; runtimeMed = cputime; if (8>=d>=1) Citraasal = getimage(handles.axes4); A= getimage(handles.axes5); hObject = waitbar(0,'1','Name','Processing'); for step = 1:1000 waitbar(step/1000,hObject,sprintf('Processing...')) end delete(hObject) ukuran =3; d = handles.d; B=alphatrimmed(A,ukuran,d); B=uint8(B); axes(handles.axes6); imshow(B) runtimeMed=cputime-runtimeMed; Citrahasil= getimage(handles.axes6); [NilaiMSE PSNR]=HitungMSE(Citraasal,Citrahasil); set(handles.mse2,'String',NilaiMSE); set(handles.psnr2,'String',PSNR); set(handles.runtime2,'String',runtimeMed); set(handles.save2,'Enable','on'); end function save2_Callback(hObject, eventdata, handles) [nama_file,nama_path] = uiputfile({'*.bmp';'*.*'},'Save Image'); if isequal([nama_file,nama_path],[0,0]); return else citra = getimage(handles.axes6); imwrite(citra,strcat(nama_path,nama_file)); warndlg('Success save file','Warning') end function psnr2_Callback(hObject, eventdata, handles)

function psnr2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function popupmenu2_Callback(hObject, eventdata, handles) function popupmenu2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function generate_noise2_Callback(hObject, eventdata, handles) indeks=get(handles.popupmenu2,'Value'); switch indeks case 1 a = helpdlg('Please choose noise probability'); case 2 a = 0.01; case 3 a = 0.02; case 4 a = 0.03; case 5 a = 0.04; case 6 a = 0.05; end handles.aa=a; a=handles.aa; if (0.05>=a>=0.01) A = getimage(handles.axes4); B=double(A); [m,n] = size(A); for i = 1:m for j = 1:n noise = -1/a*log(1-rand); B(i,j) = round(A(i,j)+ noise); if B(i,j) > 255 B(i,j) = 255; end end end B=uint8(B); axes(handles.axes5); imshow(B) set(handles.reduce_noise2,'Enable','on'); end function popupmenu3_Callback(hObject, eventdata, handles) function popupmenu3_CreateFcn(hObject, eventdata, handles)

  if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function mse1_Callback(hObject, eventdata, handles) function nama_file1_Callback(hObject, eventdata, handles) function reset2_Callback(hObject, eventdata, handles) handles.citra = handles.reset; guidata(hObject,handles); axes(handles.axes4); imshow(handles.citra); axes(handles.axes5); imshow(handles.citra); axes(handles.axes6); imshow(handles.citra); set(handles.dimensi3,'string',''); set(handles.dimensi4,'string',''); set(handles.nama_file2,'string',''); set(handles.lokasi2,'string',''); set(handles.ukuran_file2,'string',''); set(handles.mse2,'string',''); set(handles.psnr2,'string',''); set(handles.runtime2,'string',''); set(handles.generate_noise2,'Enable','off'); set(handles.reduce_noise2,'Enable','off'); set(handles.save2,'Enable','off'); set(handles.popupmenu2,'Value',1) set(handles.popupmenu3,'Value',1)

  4. Kode Program Figure Help

  function varargout = Help(varargin) gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Help_OpeningFcn, ... 'gui_OutputFcn', @Help_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 function Help_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; guidata(hObject, handles);

  function varargout = Help_OutputFcn(hObject, eventdata, handles) varargout{1} = handles.output; function figure1_ResizeFcn(hObject, eventdata, handles) function listbox2_Callback(hObject, eventdata, handles) function listbox2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function listbox4_Callback(hObject, eventdata, handles) function listbox4_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function listbox5_Callback(hObject, eventdata, handles) function listbox5_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function home_Callback(hObject, eventdata, handles) function home_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function listbox7_Callback(hObject, eventdata, handles) function listbox7_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function reduction1_Callback(hObject, eventdata, handles) function reduction1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

  function reduction2_Callback(hObject, eventdata, handles) function reduction2_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function close_Callback(hObject, eventdata, handles) close

  5. Kode Program Figure About

  function varargout = About(varargin) gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @About_OpeningFcn, ... 'gui_OutputFcn', @About_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 function About_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; guidata(hObject, handles); function varargout = About_OutputFcn(hObject, eventdata, handles) citra = imread('Liza.JPG'); axes(handles.programmer); imshow(citra); varargout{1} = handles.output; function figure1_ResizeFcn(hObject, eventdata, handles) function pushbutton1_Callback(hObject, eventdata, handles) close

  6. Kode Program Function Geometric Mean Filter

  function [B] = geometric(A,ukuran) if nargin < 2 ukuran = 3; end

  [m,n] =size(A); cons = floor(ukuran/2); A=double(A); B=double(A); for i=1+cons : m-cons for j=1+cons : n-cons jumlah = 1; for p = -cons : cons for q= -cons : cons jumlah = jumlah * A(i+p, j+q); end end B(i, j) = jumlah ^ (1/(ukuran * ukuran)); end end B=uint8(B);

  function [B] = alphatrimmed(A, ukuran, d) if nargin < 2 ukuran = 3; end if nargin < 3 d = handles.d; end [m, n] = size(A); cons = floor(ukuran / 2); A = double(A); B = double(A); Nilai = zeros(1,ukuran * ukuran); for i=1+cons : m-cons for j=1+cons: n-cons index = 1; for p = -cons : cons for q = -cons : cons Nilai(index) = A(i+p, j+q); index = index + 1; end end index = index - 1; % jumlah data % Urutkan data pada array nilai for p = 2:index x = Nilai(p); % Sisipkan x ke dalam data[1..p-1] q = p - 1; ketemu = 0; while ((q >= 1) && (~ketemu)) if (x < Nilai(q)) Nilai(q+1) = Nilai(q); q = q - 1; else ketemu = 1; end Nilai(q+1) = x; end end if (d==0)

  B(i, j) = sum(Nilai(2:8)) * (1/((ukuran*ukuran)-d)); elseif (d == 1||d == 2||d== 3||d==4||d==5||d==6||d==7) B(i, j) = sum(Nilai(2:8)) * (1/((ukuran*ukuran)-d)); elseif (d==8) B(i, j) = Nilai(floor(ukuran * ukuran/2) + 1); end end end B = uint8(B);

  function [NilaiMSE PSNR] = HitungMSE(Citraasal,Citrahasil) a = double(Citraasal); b = double(Citrahasil); NilaiMSE=(a-b).^2; [tinggi lebar]= size(Citraasal); NilaiMSE=(sum(NilaiMSE(:))/(tinggi*lebar)); PSNR = 20*log10(255/sqrt(NilaiMSE)); end

Dokumen yang terkait

Pengaruh Pendidikan dan Pelatihan terhadap Produktivitas Kerja Agen Jasa Asuransi Pada PT. Prudential Life Assurance Medan

0 1 11

BAB 2 TINJAUAN PUSTAKA - Perbedaan Kekasaran Permukaan Enamel Gigi Pada Penggunaan Karbamid Peroksida 16% Dan Jus Buah Stroberi (Fragaria x ananassa) sebagai Bahan Pemutih Gigi

0 0 16

Pengaruh Pupuk Kandang Kelinci Pada Pupuk Urea Terhadap Ketersediaan N-Total dan Pertumbuhan Tanaman Jagung ( Zea mays L. ) Pada Tanah Inceptisol Kwala Bekala

0 1 10

BAB II DASAR TEORI - Rancang Bangun Band Pass Filter Dengan Metode Hairpin Menggunakan Saluran Mikrostrip Untuk Frekuensi 2,4-2,5 GHZ

0 1 17

BAB II TINJAUAN PUSTAKA 2.1 Teori kepuasan 2.1.1 Pengertian Kepuasan Pelanggan - Pengukuran Indeks Kepuasan Masyarakat Pada Pelayanan Publik Di Badan Pelayanan Perizinan Terpadu, Dinas Pendapatan Daerah dan Dinas Kependudukan dan Catatan Sipil Kota Medan

0 0 31

BAB I PENDAHULUAN 1.1 Latar Belakang - Pengukuran Indeks Kepuasan Masyarakat Pada Pelayanan Publik Di Badan Pelayanan Perizinan Terpadu, Dinas Pendapatan Daerah dan Dinas Kependudukan dan Catatan Sipil Kota Medan

0 0 13

Pengukuran Indeks Kepuasan Masyarakat Pada Pelayanan Publik Di Badan Pelayanan Perizinan Terpadu, Dinas Pendapatan Daerah dan Dinas Kependudukan dan Catatan Sipil Kota Medan

0 0 14

1. Tanggal wawancara dilaksanakan - Gambaran Ketersediaan Pangan dan Status Gizi Anak Balita Pada Keluarga Perokok di Desa Trans Pirnak Marenu Kecamatan Aek Nabara Barumun Kabupaten Padang Lawas

0 0 27

Gambaran Ketersediaan Pangan dan Status Gizi Anak Balita Pada Keluarga Perokok di Desa Trans Pirnak Marenu Kecamatan Aek Nabara Barumun Kabupaten Padang Lawas

0 0 13

BAB I PENDAHULUAN 1.1 Latar Belakang - Gambaran Ketersediaan Pangan dan Status Gizi Anak Balita Pada Keluarga Perokok di Desa Trans Pirnak Marenu Kecamatan Aek Nabara Barumun Kabupaten Padang Lawas

0 0 6