LISTING PROGRAM
1.
Form Cover
function varargout = cover(varargin) % COVER MATLAB code for cover.fig
% COVER, by itself, creates a new COVER or raises the existing % singleton*.
%
% H = COVER returns the handle to a new COVER or the handle to % the existing singleton*.
%
% COVER('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in COVER.M with the given input arguments.
%
% COVER('Property','Value',...) creates a new COVER or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before cover_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application
% stop. All inputs are passed to cover_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 cover
% Last Modified by GUIDE v2.5 20-Jun-2014 12:24:43
% Begin initialization code - DO NOT EDIT gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @cover_OpeningFcn, ... 'gui_OutputFcn', @cover_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
% --- Executes just before cover is made visible.
function cover_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 cover (see VARARGIN)
% Choose default command line output for cover handles.Axes1 = imshow('logo.jpg');
handles.output = hObject;
% Update handles structure guidata(hObject, handles);
% UIWAIT makes cover wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = cover_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;
% ---
% ---
function Untitled_2_Callback(hObject, eventdata, handles) % hObject handle to Untitled_2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) Skripsi
delete(handles.figure1)
% ---
function Untitled_3_Callback(hObject, eventdata, handles) % hObject handle to Untitled_3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) Help
delete(handles.figure1)
% ---
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) close;
2.
Form Procces
function varargout = Skripsi(varargin) % SKRIPSI MATLAB code for Skripsi.fig
% SKRIPSI, by itself, creates a new SKRIPSI or raises the existing
% singleton*. %
% H = SKRIPSI returns the handle to a new SKRIPSI or the handle to
% the existing singleton*. %
% SKRIPSI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SKRIPSI.M with the given input arguments.
%
% SKRIPSI('Property','Value',...) creates a new SKRIPSI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Skripsi_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Skripsi_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 Skripsi
% Last Modified by GUIDE v2.5 20-Jun-2014 11:25:37
% Begin initialization code - DO NOT EDIT gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Skripsi_OpeningFcn, ... 'gui_OutputFcn', @Skripsi_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
% --- Executes just before Skripsi is made visible.
function Skripsi_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 Skripsi (see VARARGIN)
% Choose default command line output for Skripsi handles.output = hObject;
% Update handles structure guidata(hObject, handles);
% UIWAIT makes Skripsi wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = Skripsi_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) [nama_file,nama_path] = uigetfile({'*.jpg'},'Buka File Citra'); if ~isequal(nama_file,0)
handles.citra = imread(fullfile(nama_path,nama_file)); guidata(hObject,handles);
axes(handles.axes1); imshow(handles.citra); else
return; end;
% --- 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) gambar = getimage(handles.axes1);
red = gambar(:,:,1); if red <= 255
msgbox('Gambar yang diproses harus berwarna(RGB)','Peringatan','warn'); else
grayscale = 0.3*red + 0.3*green + 0.3*blue; axes(handles.axes2);
imshow(grayscale); end;
function slider2_Callback(hObject, eventdata, handles) % hObject handle to slider2 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
F = getimage(handles.axes2); prob = get(hObject,'value'); probabilitas = + prob /100 %end;
%if probabilitas < 0 || probabilitas > 1
% error ('nilai probabilitas harus antara 0 sd 1'); %end
[m, n] = size(F);
G = double(F); %&& double membuat rentang nilai 0-1 for i=1 : m
for j=1 : n
nilai_acak = rand;
if nilai_acak <= probabilitas/2 G(i,j) = 0;
elseif(nilai_acak > probabilitas/2) && (nilai_acak <= probabilitas) G(i,j) = 255;
%&& adalah kondisi untuk semua sama dan benar end
end end
G = uint8(G); handles.gui.G = G; citranoise = G;
guidata(hObject, handles) axes(handles.axes3); imshow(citranoise);
set(handles.text10,'string',probabilitas*100);
% --- Executes during object creation, after setting all properties. function slider2_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end
% --- 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) tic;
I=getimage(handles.axes3); temp=I;
[b k c]=size(temp); for x=1:1:b for y=1:1:k for z=1:1:c try
matriks(1,1)=temp(x-1,y-1,z); catch
matriks(1,1)=0; end
try
matriks(1,2)=temp(x-1,y,z); catch
matriks(1,2)=0; end
try
matriks(1,3)=temp(x-1,y+1,z); catch
matriks(1,3)=0; end
try
matriks(2,1)=temp(x,y-1,z); catch
matriks(2,1)=0; end
try
matriks(2,2)=temp(x,y,z); catch
matriks(2,2)=0; end
try
matriks(2,3)=temp(x,y+1,z); catch
matriks(2,3)=0; end
try
matriks(3,1)=temp(x+1,y-1,z); catch
matriks(3,1)=0; end
try
matriks(3,2)=temp(x+1,y,z); catch
matriks(3,2)=0; end
try
matriks(3,3)=temp(x+1,y+1,z); catch
matriks(3,3)=0; end
for j=1:3
filtered(x,y,z)=filtered(x,y,z)+matriks(i,j); end
end
arithmatik(x,y,z) = (filtered(x,y,z)/9); end
end
arithmatik=uint8(arithmatik);
handles.gui.arithmatik = arithmatik; guidata(hObject, handles)
axes(handles.axes4); imshow(arithmatik); toc;
set(handles.text21,'string',toc);
% --- Executes on slider movement.
function slider3_Callback(hObject, eventdata, handles) % hObject handle to slider3 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
tic;
I=getimage(handles.axes4); temp=I;
[b k c]=size(temp); for x=1:1:b for y=1:1:k for z=1:1:c try
matriks(1,1)=temp(x-1,y-1,z); catch
matriks(1,1)=0; end
try
matriks(1,2)=temp(x-1,y,z); catch
matriks(1,2)=0; end
try
matriks(1,3)=temp(x-1,y+1,z); catch
matriks(1,3)=0; end
try
matriks(2,1)=temp(x,y-1,z); catch
matriks(2,1)=0; end
try
matriks(2,2)=temp(x,y,z); catch
matriks(2,2)=0; end
try
catch
matriks(2,3)=0; end
try
matriks(3,1)=temp(x+1,y-1,z); catch
matriks(3,1)=0; end
try
matriks(3,2)=temp(x+1,y,z); catch
matriks(3,2)=0; end
try
matriks(3,3)=temp(x+1,y+1,z); catch
matriks(3,3)=0; end
nilai = get(hObject,'value'); A = + nilai;
H=(1/9)*[-1 -1 -1; -1 8 -1; -1 -1 -1]; K=[0 0 0; 0 1 0; 0 0 0];
HB= ((A-1).*K) + H;
for i = 1:3 for j = 1:3
sharpened(i,j)= matriks(i,j)*HB(i,j); end
end
sharpened=uint8(sharpened); filtered(x,y,z)=0;
for i=1:3 for j=1:3
filtered(x,y,z)=filtered(x,y,z)+sharpened(i,j );
end end end
end end
filtered=uint8(filtered);
handles.gui.filtered = filtered; guidata(hObject, handles)
set(handles.text11,'string',A); axes(handles.axes5);
imshow(filtered); toc;
set(handles.text16,'string',toc);
% --- Executes during object creation, after setting all properties. function slider3_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end
% --- 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) gray = getimage(handles.axes2);
noise = getimage(handles.axes3); citra_gray = double(gray);
citra_noise = double(noise); [M N] = size(gray);
error = citra_gray - citra_noise;
MSE = sum(sum(error .* error)) / (M * N);
if(MSE > 0)
PSNR = 10*log(255*255/MSE) / log(10) else
PSNR = 99 end
set(handles.text12,'string',PSNR);
% --- 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) gray = getimage(handles.axes2);
noise = getimage(handles.axes3); citra_gray = double(gray);
citra_noise = double(noise); [M N] = size(gray);
error = citra_gray - citra_noise;
MSE = sum(sum(error .* error)) / (M * N)
if(MSE > 0)
PSNR = 10*log(255*255/MSE) / log(10) else
PSNR = 99 end
set(handles.text13,'string',MSE);
% --- 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) noise = getimage(handles.axes2);
arithmetic = getimage(handles.axes4); citra_noise = double(noise);
citra_arithmetic = double(arithmetic); [M N] = size(noise);
MSE = sum(sum(error .* error)) / (M * N)
if(MSE > 0)
PSNR = 10*log(255*255/MSE) / log(10) else
PSNR = 99 end
set(handles.text17,'string',PSNR);
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles) % 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) noise = getimage(handles.axes2);
arithmetic = getimage(handles.axes4); citra_noise = double(noise);
citra_arithmetic = double(arithmetic); [M N] = size(noise);
error = citra_noise - citra_arithmetic; MSE = sum(sum(error .* error)) / (M * N)
if(MSE > 0)
PSNR = 10*log(255*255/MSE) / log(10) else
PSNR = 99 end
set(handles.text18,'string',MSE);
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles) % hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) arithmetic = getimage(handles.axes2);
highboost = getimage(handles.axes5); citra_arithmetic = double(arithmetic); citra_highboost = double(highboost); [M N] = size(arithmetic);
error = citra_arithmetic - citra_highboost; MSE = sum(sum(error .* error)) / (M * N)
if(MSE > 0)
PSNR = 10*log(255*255/MSE) / log(10) else
PSNR = 99 end
set(handles.text14,'string',PSNR);
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles) % hObject handle to pushbutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) arithmetic = getimage(handles.axes2);
error = citra_arithmetic - citra_highboost; MSE = sum(sum(error .* error)) / (M * N)
if(MSE > 0)
PSNR = 10*log(255*255/MSE) / log(10) else
PSNR = 99 end
set(handles.text15,'string',MSE);
% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles) % hObject handle to pushbutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% --- Executes on slider movement.
function slider5_Callback(hObject, eventdata, handles) % hObject handle to slider5 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
F = getimage(handles.axes2);
mu = 0; % Nilai bawaan mu
deviasi = get(hObject,'value'); sigma = + deviasi
[m n p] = size(F); noise = double(F); for i=1 : m
for j=1 : n for k=1 : p
derau = randn * sigma + mu;
G(i,j,k) = round(noise(i,j,k) + derau); if G(i,j,k) > 255
G(i,j,k) = 255; elseif G(i,j,k) < 0 G(i,j,k) = 0;
G = uint8(G); end;
end; end; end;
handles.gui.G = G; citranoise = G;
guidata(hObject, handles) axes(handles.axes3); imshow(citranoise);
set(handles.text9,'string',sigma);
% --- Executes during object creation, after setting all properties. function slider5_CreateFcn(hObject, eventdata, handles)
% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end
% ---
function Untitled_1_Callback(hObject, eventdata, handles) % hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) cover
delete(handles.figure1)
% ---
function Untitled_2_Callback(hObject, eventdata, handles) % hObject handle to Untitled_2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) Help
delete(handles.figure1)
% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles) % hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) [nama_file_simpan, path_simpan]=uiputfile(...
{'*.jpg','(*.jpg)';
'*.*','Semua File(*.*)'},... 'Menyimpan Citra Hasil'); G=getimage(handles.axes5);
imwrite(G,fullfile(path_simpan,nama_file_simpan),'JPG');
% ---
function Untitled_3_Callback(hObject, eventdata, handles) % hObject handle to Untitled_3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) close;
3.
Form Help
function varargout = Help(varargin) % HELP MATLAB code for Help.fig
%
% H = HELP returns the handle to a new HELP or the handle to % the existing singleton*.
%
% HELP('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in HELP.M with the given input
arguments. %
% HELP('Property','Value',...) creates a new HELP or raises the % existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Help_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Help_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 Help
% Last Modified by GUIDE v2.5 16-Jul-2014 13:43:48
% Begin initialization code - DO NOT EDIT 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
% End initialization code - DO NOT EDIT
% --- Executes just before Help is made visible.
function Help_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 Help (see VARARGIN)
% Choose default command line output for Help handles.output = hObject;
% UIWAIT makes Help wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = Help_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 selection change in listbox2.
function listbox2_Callback(hObject, eventdata, handles) % hObject handle to listbox2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns listbox2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox2
% --- Executes during object creation, after setting all properties. function listbox2_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: listbox 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 Untitled_1_Callback(hObject, eventdata, handles) % hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) cover
delete(handles.figure1)
% ---
function Untitled_2_Callback(hObject, eventdata, handles) % hObject handle to Untitled_2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) Skripsi
% ---
function Untitled_3_Callback(hObject, eventdata, handles) % hObject handle to Untitled_3 (see GCBO)