Wednesday, May 10, 2017

Cara Membuat GUI MATLAB Untuk PENAPISAN BUTTERWORTH UNTUK CITRA DIGITAL






Berikut adalah semua fungsi callback GUI MATLAB:

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

% Last Modified by GUIDE v2.5 26-Mar-2017 11:54:37

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

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

% Update handles structure
guidata(hObject, handles);

set(handles.tombolDerau,'Enable','off');
set(handles.tombolKabur,'Enable','off');
set(handles.tombolRotasi,'Enable','off');
set(handles.tombolIntensitas,'Enable','off');
set(handles.tombolReset,'Enable','off');
set(handles.tombolEvaluasiLowPass,'Enable','off');
set(handles.tombolEvaluasiBandPass,'Enable','off');
set(handles.tombolEvaluasiHighPass,'Enable','off');
set(handles.tombolEvaluasiBandStop,'Enable','off');
%set(handles.tombolDerau, 'Visible', 'Off');

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


% --- Outputs from this function are returned to the command line.
function varargout = Restorasi_Citra_TAPIS_BUTTERWORTH_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)


set(handles.tombolDerau,'Enable','off');
set(handles.tombolKabur,'Enable','on');
set(handles.tombolRotasi,'Enable','off');
set(handles.tombolIntensitas,'Enable','off');
set(handles.tombolReset,'Enable','on');
set(handles.tombolEvaluasiLowPass,'Enable','off');


[namafile namapath]=uigetfile('*.jpg;*.bmp;*.jpeg;*.png;*.tif;','Pilih Sebuah Citra');
namacitra=[namapath namafile];


if(size(namacitra,3) == 3)
    namacitra = rgb2gray(namacitra);
end


axes(handles.axes1)
imshow(namacitra); title('Citra Semula');

global I
I = getimage(handles.axes1);


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

global I
size(I)
switch get(handles.popupmenu1,'Value')
    case 1
       kabur = I;
    case 2
       H = fspecial('average',11);
       kabur = imfilter(I,H,'replicate');
    case 3
       H = fspecial('motion',20,45);
       kabur = imfilter(I,H,'replicate');
    case 4
       H = fspecial('disk',10);
       kabur = imfilter(I,H,'replicate');
    case 5
       H = fspecial('gaussian',[11 11], 10);
       kabur = imfilter(I,H,'replicate');
end

axes(handles.axes3)
imshow(uint8(kabur));
%axes(handles.axes3)
%imhist(uint8(kabur),128);

global I_kabur
I_kabur = getimage(handles.axes3);

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

global I_kabur
size(I_kabur)

% Mendefinisikan variansi derau
variansi = str2double(get(handles.editVariansi,'String'));

switch get(handles.popupmenu2,'Value')
    case 1
       derau = imnoise(I_kabur,'gaussian', 0,variansi);
    case 2
       derau = imnoise(I_kabur, 'poisson');
    case 3
       derau = imnoise(I_kabur,'salt & pepper',variansi);
    case 4
       derau = imnoise(I_kabur,'speckle',variansi);
end

axes(handles.axes3)
imshow(uint8(derau));
%axes(handles.axes3)
%imhist(uint8(derau),128);

global I_derau
I_derau = derau;

% --- Executes on button press in tapis inverse.
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)

%global I_derau
%global I_kabur
global I

%kasus 1
% Mendefinisikan variansi derau
variansi = str2double(get(handles.editVariansi,'String'));
mu=20;
lambda=1;
[M,N]=size(I);
H1 = fspecial('average',11);
kabur1 = imfilter(I,H1,'replicate');
derau1 = imnoise(kabur1,'gaussian', 0,variansi);

g_denoise_atv = SB_ATV(double(derau1),mu,0.1,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
MSE1 = sum(sum(error .* error)) / (M * M);
set(handles.edit1, 'String', num2str(MSE1));




%kasus 2
H2 = fspecial('gaussian',[11 11], 10);
kabur2 = imfilter(I,H2,'replicate');
derau2 = imnoise(kabur2, 'poisson');
g_denoise_atv = SB_ATV(double(derau2),mu,0.1,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
MSE2 = sum(sum(error .* error)) / (M * M);
set(handles.edit5, 'String', num2str(MSE2));


%kasus 3
H3 = fspecial('disk',10);
kabur3 = imfilter(I,H3,'replicate');
derau3 = imnoise(kabur3,'salt & pepper',variansi);
g_denoise_atv = SB_ATV(double(derau3),mu,0.1,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
        MSE3 = sum(sum(error .* error)) / (M * M);
        set(handles.edit9, 'String', num2str(MSE3));


%kasus 4
H4 = fspecial('motion',20,45);
kabur4 = imfilter(I,H4,'replicate');
derau4 = imnoise(kabur4,'speckle',variansi);
g_denoise_atv = SB_ATV(double(derau4),mu,0.1,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
        MSE4 = sum(sum(error .* error)) / (M * M);
        set(handles.edit13, 'String', num2str(MSE4));


MSE_1 = [MSE1 MSE2 MSE3 MSE4];

global MSE_1

% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (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 popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1


% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu 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


% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (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 popupmenu2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu2


% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu 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


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

global I

%kasus 1
% Mendefinisikan variansi derau
variansi = str2double(get(handles.editVariansi,'String'));
mu=20;
lambda=1;
tol=0.05;
[M,N]=size(I);
H1 = fspecial('average',11);
kabur1 = imfilter(I,H1,'replicate');
derau1 = imnoise(kabur1,'gaussian', 0,variansi);

g_denoise_atv = SB_ATV(double(derau1),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
MSE1 = sum(sum(error .* error)) / (M * M);
set(handles.edit2, 'String', num2str(MSE1));




%kasus 2
H2 = fspecial('gaussian',[11 11], 10);
kabur2 = imfilter(I,H2,'replicate');
derau2 = imnoise(kabur2, 'poisson');
g_denoise_atv = SB_ATV(double(derau2),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
MSE2 = sum(sum(error .* error)) / (M * M);
set(handles.edit6, 'String', num2str(MSE2));


%kasus 3
H3 = fspecial('disk',10);
kabur3 = imfilter(I,H3,'replicate');
derau3 = imnoise(kabur3,'salt & pepper',variansi);
g_denoise_atv = SB_ATV(double(derau3),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
        MSE3 = sum(sum(error .* error)) / (M * M);
        set(handles.edit10, 'String', num2str(MSE3));


%kasus 4
H4 = fspecial('motion',20,45);
kabur4 = imfilter(I,H4,'replicate');
derau4 = imnoise(kabur4,'speckle',variansi);
g_denoise_atv = SB_ATV(double(derau4),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
        MSE4 = sum(sum(error .* error)) / (M * M);
        set(handles.edit14, 'String', num2str(MSE4));


MSE_2 = [MSE1 MSE2 MSE3 MSE4];

global MSE_2


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

global I

%kasus 1
% Mendefinisikan variansi derau
variansi = str2double(get(handles.editVariansi,'String'));
mu=20;
lambda=1;
tol=0.01
[M,N]=size(I);
H1 = fspecial('average',11);
kabur1 = imfilter(I,H1,'replicate');
derau1 = imnoise(kabur1,'gaussian', 0,variansi);

g_denoise_atv = SB_ATV(double(derau1),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
MSE1 = sum(sum(error .* error)) / (M * M);
set(handles.edit3, 'String', num2str(MSE1));




%kasus 2
H2 = fspecial('gaussian',[11 11], 10);
kabur2 = imfilter(I,H2,'replicate');
derau2 = imnoise(kabur2, 'poisson');
g_denoise_atv = SB_ATV(double(derau2),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
MSE2 = sum(sum(error .* error)) / (M * M);
set(handles.edit7, 'String', num2str(MSE2));


%kasus 3
H3 = fspecial('disk',10);
kabur3 = imfilter(I,H3,'replicate');
derau3 = imnoise(kabur3,'salt & pepper',variansi);
g_denoise_atv = SB_ATV(double(derau3),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
        MSE3 = sum(sum(error .* error)) / (M * M);
        set(handles.edit11, 'String', num2str(MSE3));


%kasus 4
H4 = fspecial('motion',20,45);
kabur4 = imfilter(I,H4,'replicate');
derau4 = imnoise(kabur4,'speckle',variansi);
g_denoise_atv = SB_ATV(double(derau4),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
        MSE4 = sum(sum(error .* error)) / (M * M);
        set(handles.edit15, 'String', num2str(MSE4));


MSE_3 = [MSE1 MSE2 MSE3 MSE4];

global MSE_3


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

global I

%kasus 1
% Mendefinisikan variansi derau
variansi = str2double(get(handles.editVariansi,'String'));
mu=20;
lambda=1;
tol=0.005
[M,N]=size(I);
H1 = fspecial('average',11);
kabur1 = imfilter(I,H1,'replicate');
derau1 = imnoise(kabur1,'gaussian', 0,variansi);

g_denoise_atv = SB_ATV(double(derau1),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
MSE1 = sum(sum(error .* error)) / (M * M);
set(handles.edit4, 'String', num2str(MSE1));




%kasus 2
H2 = fspecial('gaussian',[11 11], 10);
kabur2 = imfilter(I,H2,'replicate');
derau2 = imnoise(kabur2, 'poisson');
g_denoise_atv = SB_ATV(double(derau2),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
MSE2 = sum(sum(error .* error)) / (M * M);
set(handles.edit8, 'String', num2str(MSE2));


%kasus 3
H3 = fspecial('disk',10);
kabur3 = imfilter(I,H3,'replicate');
derau3 = imnoise(kabur3,'salt & pepper',variansi);
g_denoise_atv = SB_ATV(double(derau3),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
        MSE3 = sum(sum(error .* error)) / (M * M);
        set(handles.edit12, 'String', num2str(MSE3));


%kasus 4
H4 = fspecial('motion',20,45);
kabur4 = imfilter(I,H4,'replicate');
derau4 = imnoise(kabur4,'speckle',variansi);
g_denoise_atv = SB_ATV(double(derau4),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
        MSE4 = sum(sum(error .* error)) / (M * M);
        set(handles.edit16, 'String', num2str(MSE4));


MSE_4 = [MSE1 MSE2 MSE3 MSE4];

global MSE_4
% --- 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)



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



function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (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 edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (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 edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (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 edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double


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


% --- Executes on selection change in popupmenu4.
function popupmenu4_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu4 (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 popupmenu4 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu4


% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu 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


% --- Executes on selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu3 (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 popupmenu3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu3


% --- Executes during object creation, after setting all properties.
function popupmenu3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu 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


% --- Executes on button press in pushbutton14.
function pushbutton14_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton14 (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 pushbutton13.
function pushbutton13_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton13 (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 pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton12 (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 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)



function edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (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 edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (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 edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit6 (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 edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double


% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (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 edit7_Callback(hObject, eventdata, handles)
% hObject    handle to edit7 (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 edit7 as text
%        str2double(get(hObject,'String')) returns contents of edit7 as a double


% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit7 (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 edit8_Callback(hObject, eventdata, handles)
% hObject    handle to edit8 (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 edit8 as text
%        str2double(get(hObject,'String')) returns contents of edit8 as a double


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


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



function edit9_Callback(hObject, eventdata, handles)
% hObject    handle to edit9 (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 edit9 as text
%        str2double(get(hObject,'String')) returns contents of edit9 as a double


% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit9 (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 edit10_Callback(hObject, eventdata, handles)
% hObject    handle to edit10 (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 edit10 as text
%        str2double(get(hObject,'String')) returns contents of edit10 as a double


% --- Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit10 (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 edit11_Callback(hObject, eventdata, handles)
% hObject    handle to edit11 (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 edit11 as text
%        str2double(get(hObject,'String')) returns contents of edit11 as a double


% --- Executes during object creation, after setting all properties.
function edit11_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit11 (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 edit12_Callback(hObject, eventdata, handles)
% hObject    handle to edit12 (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 edit12 as text
%        str2double(get(hObject,'String')) returns contents of edit12 as a double


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


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



function edit13_Callback(hObject, eventdata, handles)
% hObject    handle to edit13 (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 edit13 as text
%        str2double(get(hObject,'String')) returns contents of edit13 as a double


% --- Executes during object creation, after setting all properties.
function edit13_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit13 (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 edit14_Callback(hObject, eventdata, handles)
% hObject    handle to edit14 (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 edit14 as text
%        str2double(get(hObject,'String')) returns contents of edit14 as a double


% --- Executes during object creation, after setting all properties.
function edit14_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit14 (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 edit15_Callback(hObject, eventdata, handles)
% hObject    handle to edit15 (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 edit15 as text
%        str2double(get(hObject,'String')) returns contents of edit15 as a double


% --- Executes during object creation, after setting all properties.
function edit15_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit15 (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 edit16_Callback(hObject, eventdata, handles)
% hObject    handle to edit16 (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 edit16 as text
%        str2double(get(hObject,'String')) returns contents of edit16 as a double


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


% --- Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton15 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

cla(handles.axes1,'reset');
cla(handles.axes2,'reset');
cla(handles.axes3,'reset');
cla(handles.axes4,'reset');
cla(handles.axes5,'reset');

set(handles.edit1, 'String', num2str(0));
set(handles.edit2, 'String', num2str(0));
set(handles.edit3, 'String', num2str(0));
set(handles.edit4, 'String', num2str(0));

set(handles.edit5, 'String', num2str(0));
set(handles.edit6, 'String', num2str(0));
set(handles.edit7, 'String', num2str(0));
set(handles.edit8, 'String', num2str(0));

set(handles.edit9, 'String', num2str(0));
set(handles.edit10, 'String', num2str(0));
set(handles.edit11, 'String', num2str(0));
set(handles.edit12, 'String', num2str(0));

set(handles.edit13, 'String', num2str(0));
set(handles.edit14, 'String', num2str(0));
set(handles.edit15, 'String', num2str(0));
set(handles.edit16, 'String', num2str(0));

set(handles.edit18, 'String', num2str(0));

% --- Executes on button press in pushbutton16.
function pushbutton16_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton16 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

close(denoising_adaptif_wavelet);

% --- Executes when selected object is changed in uipanel4.
function uipanel4_SelectionChangeFcn(hObject, eventdata, handles)
% hObject    handle to the selected object in uipanel4
% eventdata  structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles    structure with handles and user data (see GUIDATA)

global I_derau
global I
g = I_derau;
[N,M]=size(g);


     
switch get(eventdata.NewValue,'Tag') % Mendapatkan tag dari objek terseleksi
    case 'radiobutton1'
     
        % Mendefinisikan level dekomposisi
        level = str2double(get(handles.editLevel,'String'));

        % Mendefinisikan variansi derau
        variansi = str2double(get(handles.editVariansi,'String'));

        % Mendefinisikan wavelet
        switch get(handles.popupmenu5,'Value')
           case 1
              wavelet = 'db4';
           case 2
              wavelet = 'db8';
           case 3
              wavelet = 'coif4';
           case 4
              wavelet = 'sym3';
           case 5
              wavelet = 'bior3.7';
        end
     
        %Melakukan dekomposisi wavelet
        [C,S]=wavedec2(g,level,wavelet);
     
        %Universal Shrink (US)
        M=size(g,1)^2;
        US=variansi*sqrt(2*log(M))

        %Ambang-batas halus
        %Hanya pada koefisien-koefisien aproksimasi
        softC=[wthresh(C(1:S(1,1)^2),'s',US), C(S(1,1)^2+1:length(C))];
     
        %Pada koefisien-koefisien detil
        %softC=[C(1:S(1,1)^2), wthresh(C(S(1,1)^2+1:length(C)),'s',US)];

        %Merekonstruksi citra dari koefisien-koefisien hasil ambang-batas
        citraBaru=waverec2(softC,S,wavelet);

        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imagesc(citraBaru); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / (M * N);
        set(handles.edit18, 'String', num2str(MSE1));

    case 'radiobutton2'
        % Mendefinisikan level dekomposisi
        level = str2double(get(handles.editLevel,'String'));

        % Mendefinisikan variansi derau
        variansi = str2double(get(handles.editVariansi,'String'));

        % Mendefinisikan wavelet
        switch get(handles.popupmenu5,'Value')
           case 1
              wavelet = 'db4';
           case 2
              wavelet = 'db8';
           case 3
              wavelet = 'coif4';
           case 4
              wavelet = 'sym3';
           case 5
              wavelet = 'bior3.7';
        end
     
        %Melakukan dekomposisi wavelet
        [C,S]=wavedec2(g,level,wavelet);

        %Visu Shrink (VS)
        N=size(g,1)^2;
        VS=variansi*sqrt(2*log(N*N)) + 0.25*max(C);

        %Ambang-batas halus
        %Hanya pada koefisien-koefisien aproksimasi
        softC=[wthresh(C(1:S(1,1)^2),'h',VS), C(S(1,1)^2+1:length(C))];
     
        %Pada koefisien-koefisien detil
        %softC=[C(1:S(1,1)^2), wthresh(C(S(1,1)^2+1:length(C)),'s',US)];

        %Merekonstruksi citra dari koefisien-koefisien hasil ambang-batas
        citraBaru=waverec2(softC,S,wavelet);

        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imagesc(citraBaru); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / (M * N);
        set(handles.edit18, 'String', num2str(MSE1));
     
    case 'radiobutton3'
        % Mendefinisikan level dekomposisi
        level = str2double(get(handles.editLevel,'String'));

        % Mendefinisikan variansi derau
        variansi = str2double(get(handles.editVariansi,'String'));

        % Mendefinisikan wavelet
        switch get(handles.popupmenu5,'Value')
           case 1
              wavelet = 'db4';
           case 2
              wavelet = 'db8';
           case 3
              wavelet = 'coif4';
           case 4
              wavelet = 'sym3';
           case 5
              wavelet = 'bior3.7';
        end
     
        %Melakukan dekomposisi wavelet
        [C,S]=wavedec2(g,level,wavelet);

        %Minimax Shrink (MS)
        N=size(g,1)^2;
        MS=0.394+0.264*log(N)+ 0.5*max(C);

        %Ambang-batas halus
        %Hanya pada koefisien-koefisien aproksimasi
        softC=[wthresh(C(1:S(1,1)^2),'h',MS), C(S(1,1)^2+1:length(C))];
     
        %Pada koefisien-koefisien detil
        %softC=[C(1:S(1,1)^2), wthresh(C(S(1,1)^2+1:length(C)),'s',US)];

        %Merekonstruksi citra dari koefisien-koefisien hasil ambang-batas
        citraBaru=waverec2(softC,S,wavelet);

        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imagesc(citraBaru); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / (M * N);
        set(handles.edit18, 'String', num2str(MSE1));
     
     
    case 'radiobutton4'
        % Mendefinisikan level dekomposisi
        level = str2double(get(handles.editLevel,'String'));

        % Mendefinisikan variansi derau
        variansi = str2double(get(handles.editVariansi,'String'));

        % Mendefinisikan wavelet
        switch get(handles.popupmenu5,'Value')
           case 1
              wavelet = 'db4';
           case 2
              wavelet = 'db8';
           case 3
              wavelet = 'coif4';
           case 4
              wavelet = 'sym3';
           case 5
              wavelet = 'bior3.7';
        end
     
        %Melakukan dekomposisi wavelet
        %[C,S]=wavedec2(g,level,wavelet);

        % Ambang-batas SURE Shrink (SS)
        citraBaru = NeighShrinkSUREdenoise(g, variansi, wavelet, level);

        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imagesc(citraBaru); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / ((M * N)*N);
        set(handles.edit18, 'String', num2str(MSE1));
     
     
    case 'radiobutton9'
        % Mendefinisikan level dekomposisi
        level = str2double(get(handles.editLevel,'String'));

        % Mendefinisikan variansi derau
        variansi = str2double(get(handles.editVariansi,'String'));

        % Mendefinisikan wavelet
        switch get(handles.popupmenu5,'Value')
           case 1
              wavelet = 'db4';
           case 2
              wavelet = 'db8';
           case 3
              wavelet = 'coif4';
           case 4
              wavelet = 'sym3';
           case 5
              wavelet = 'bior3.7';
        end
     
        %Melakukan dekomposisi wavelet
        [C,S]=wavedec2(g,level,wavelet);

        % Ambang-batas Bayes Shrink (SS)
        SS = bayesthf(g,variansi) + 0.25*max(C);

        %Ambang-batas halus
        %Hanya pada koefisien-koefisien aproksimasi
        softC=[wthresh(C(1:S(1,1)^2),'h',SS), C(S(1,1)^2+1:length(C))];
     
        %Pada koefisien-koefisien detil
        %softC=[C(1:S(1,1)^2), wthresh(C(S(1,1)^2+1:length(C)),'s',US)];

        %Merekonstruksi citra dari koefisien-koefisien hasil ambang-batas
        citraBaru=waverec2(softC,S,wavelet);
     
        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imagesc(citraBaru); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / ((M * N)*N);
        set(handles.edit18, 'String', num2str(MSE1));
end



function edit17_Callback(hObject, eventdata, handles)
% hObject    handle to edit17 (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 edit17 as text
%        str2double(get(hObject,'String')) returns contents of edit17 as a double


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


% --- Executes on slider movement.
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


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



function edit18_Callback(hObject, eventdata, handles)
% hObject    handle to edit18 (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 edit18 as text
%        str2double(get(hObject,'String')) returns contents of edit18 as a double


% --- Executes during object creation, after setting all properties.
function edit18_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit18 (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 edit19_Callback(hObject, eventdata, handles)
% hObject    handle to edit19 (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 edit19 as text
%        str2double(get(hObject,'String')) returns contents of edit19 as a double


% --- Executes during object creation, after setting all properties.
function edit19_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit19 (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 edit20_Callback(hObject, eventdata, handles)
% hObject    handle to edit20 (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 edit20 as text
%        str2double(get(hObject,'String')) returns contents of edit20 as a double


% --- Executes during object creation, after setting all properties.
function edit20_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit20 (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 edit21_Callback(hObject, eventdata, handles)
% hObject    handle to edit21 (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 edit21 as text
%        str2double(get(hObject,'String')) returns contents of edit21 as a double


% --- Executes during object creation, after setting all properties.
function edit21_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit21 (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 edit22_Callback(hObject, eventdata, handles)
% hObject    handle to edit22 (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 edit22 as text
%        str2double(get(hObject,'String')) returns contents of edit22 as a double


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


% --- Executes on button press in pushbutton17.
function pushbutton17_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton17 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


global MSE_1
global MSE_2
global MSE_3
global MSE_4
global MSE_5


axes(handles.axes5)
plot(MSE_1,'-.r*')
hold on
plot(MSE_2,'--mo')
plot(MSE_3,':bs')
plot(MSE_4,'-kd')
plot(MSE_5,'--kd')
hold off
legend('0.1','0.05', '0.01', '0.005', '0.001');
title('Perbandingan MSE dari lima teknik ambang-batas adaptif');
axis([1 4 -1 500])


% --- Executes on button press in pushbutton18.
function pushbutton18_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton18 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

tol = str2double(get(handles.editKunci,'String'));
lambda = str2double(get(handles.editLambda,'String'));

mu = str2double(get(handles.editMu,'String'));

% Memuat citra
X=im2double(getimage(handles.axes3));
[N,M] = size(X);
H       = fspecial('gaussian', [9 9], 2);

g_denoise_itv = SB_ITV(X,mu,tol,lambda);

% Menampilkan hasil
axes(handles.axes4); imagesc(reshape(g_denoise_itv,N,N)); axis image;
title('Denoising Tv Isotropis');



function editLevel_Callback(hObject, eventdata, handles)
% hObject    handle to editLevel (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 editLevel as text
%        str2double(get(hObject,'String')) returns contents of editLevel as a double


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


% --- Executes during object creation, after setting all properties.
function uipanel4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to uipanel4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called



function edit32_Callback(hObject, eventdata, handles)
% hObject    handle to edit32 (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 edit32 as text
%        str2double(get(hObject,'String')) returns contents of edit32 as a double


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


% --- Executes on selection change in popupmenu5.
function popupmenu5_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu5 (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 popupmenu5 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu5


% --- Executes during object creation, after setting all properties.
function popupmenu5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu 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 editVariansi_Callback(hObject, eventdata, handles)
% hObject    handle to editVariansi (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 editVariansi as text
%        str2double(get(hObject,'String')) returns contents of editVariansi as a double


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


% --- Executes when selected object is changed in uipanel10.
function uipanel10_SelectionChangeFcn(hObject, eventdata, handles)
% hObject    handle to the selected object in uipanel10
% eventdata  structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles    structure with handles and user data (see GUIDATA)

global I_derau
global I
g = I_derau;
[N,M]=size(g);

% Mendefinisikan level dekomposisi
level = str2double(get(handles.editLevel,'String'));

% Mendefinisikan variansi derau
variansi = str2double(get(handles.editVariansi,'String'));

% Mendefinisikan wavelet
        switch get(handles.popupmenu5,'Value')
           case 1
              wavelet = 'db4';
           case 2
              wavelet = 'db8';
           case 3
              wavelet = 'coif4';
           case 4
              wavelet = 'sym3';
           case 5
              wavelet = 'bior3.7';
        end
     
switch get(eventdata.NewValue,'Tag') % Mendapatkan tag dari objek terseleksi
    case 'radiobutton20'
        %Melakukan dekomposisi wavelet
        [C,S]=wavedec2(g,level,wavelet);

        %Universal Shrink (US)
        M=size(g,1)^2;
        US=variansi*sqrt(2*log(M))+ 0.01*max(C);

        %Ambang-batas halus
        %Hanya pada koefisien-koefisien aproksimasi
        %softC=[wthresh(C(1:S(1,1)^2),'s',US), C(S(1,1)^2+1:length(C))];
     
        %Pada koefisien-koefisien detil
        softC=[C(1:S(1,1)^2), wthresh(C(S(1,1)^2+1:length(C)),'s',US)];

        %Merekonstruksi citra dari koefisien-koefisien hasil ambang-batas
        citraBaru=waverec2(softC,S,wavelet);

        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imagesc(citraBaru); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / (M * N);
        set(handles.edit32, 'String', num2str(MSE1));

    case 'radiobutton21'
        % Mendefinisikan level dekomposisi
        level = str2double(get(handles.editLevel,'String'));

        % Mendefinisikan variansi derau
        variansi = str2double(get(handles.editVariansi,'String'));

        % Mendefinisikan wavelet
        switch get(handles.popupmenu5,'Value')
           case 1
              wavelet = 'db4';
           case 2
              wavelet = 'db8';
           case 3
              wavelet = 'coif4';
           case 4
              wavelet = 'sym3';
           case 5
              wavelet = 'bior3.7';
        end
     
        %Melakukan dekomposisi wavelet
        [C,S]=wavedec2(g,level,wavelet);

        %Visu Shrink (VS)
        N=size(g,1)^2;
        VS=variansi*sqrt(2*log(N*N)) + 0.75*max(C);

        %Ambang-batas halus
        %Hanya pada koefisien-koefisien aproksimasi
        %softC=[wthresh(C(1:S(1,1)^2),'h',VS), C(S(1,1)^2+1:length(C))];
     
        %Pada koefisien-koefisien detil
        softC=[C(1:S(1,1)^2), wthresh(C(S(1,1)^2+1:length(C)),'s',VS)];

        %Merekonstruksi citra dari koefisien-koefisien hasil ambang-batas
        citraBaru=waverec2(softC,S,wavelet);

        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imagesc(citraBaru); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / (M * N);
        set(handles.edit32, 'String', num2str(MSE1));
     
    case 'radiobutton22'
        % Mendefinisikan level dekomposisi
        level = str2double(get(handles.editLevel,'String'));

        % Mendefinisikan variansi derau
        variansi = str2double(get(handles.editVariansi,'String'));

        % Mendefinisikan wavelet
        switch get(handles.popupmenu5,'Value')
           case 1
              wavelet = 'db4';
           case 2
              wavelet = 'db8';
           case 3
              wavelet = 'coif4';
           case 4
              wavelet = 'sym3';
           case 5
              wavelet = 'bior3.7';
        end
     
        %Melakukan dekomposisi wavelet
        [C,S]=wavedec2(g,level,wavelet);

        %Minimax Shrink (MS)
        N=size(g,1)^2;
        MS=0.394+0.264*log(N)+ 0.5*max(C);

        %Ambang-batas halus
        %Hanya pada koefisien-koefisien aproksimasi
        %softC=[wthresh(C(1:S(1,1)^2),'h',MS), C(S(1,1)^2+1:length(C))];
     
        %Pada koefisien-koefisien detil
        softC=[C(1:S(1,1)^2), wthresh(C(S(1,1)^2+1:length(C)),'s',MS)];

        %Merekonstruksi citra dari koefisien-koefisien hasil ambang-batas
        citraBaru=waverec2(softC,S,wavelet);

        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imagesc(citraBaru); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / (M * N);
        set(handles.edit32, 'String', num2str(MSE1));
     
     
    case 'radiobutton23'
        % Mendefinisikan level dekomposisi
        level = str2double(get(handles.editLevel,'String'));

        % Mendefinisikan variansi derau
        variansi = str2double(get(handles.editVariansi,'String'));

        % Mendefinisikan wavelet
        switch get(handles.popupmenu5,'Value')
           case 1
              wavelet = 'db4';
           case 2
              wavelet = 'db8';
           case 3
              wavelet = 'coif4';
           case 4
              wavelet = 'sym3';
           case 5
              wavelet = 'bior3.7';
        end
     
        %Melakukan dekomposisi wavelet
        %[C,S]=wavedec2(g,level,wavelet);

        % Ambang-batas SURE Shrink (SS)
        citraBaru = NeighShrinkSUREdenoise_approksimasi(g, variansi, wavelet, level);

        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imagesc(citraBaru); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / ((M * N)*N);
        set(handles.edit32, 'String', num2str(MSE1));
     
  case 'radiobutton24'    
        % Mendefinisikan level dekomposisi
        level = str2double(get(handles.editLevel,'String'));

        % Mendefinisikan variansi derau
        variansi = str2double(get(handles.editVariansi,'String'));

        % Mendefinisikan wavelet
        switch get(handles.popupmenu5,'Value')
           case 1
              wavelet = 'db4';
           case 2
              wavelet = 'db8';
           case 3
              wavelet = 'coif4';
           case 4
              wavelet = 'sym3';
           case 5
              wavelet = 'bior3.7';
        end
     
        %Melakukan dekomposisi wavelet
        [C,S]=wavedec2(g,level,wavelet);

        % Ambang-batas Bayes Shrink (SS)
        SS = bayesthf(g,variansi) + 0.25*max(C);

        %Ambang-batas halus
        %Hanya pada koefisien-koefisien aproksimasi
        %softC=[wthresh(C(1:S(1,1)^2),'h',SS), C(S(1,1)^2+1:length(C))];
     
        %Pada koefisien-koefisien detil
        softC=[C(1:S(1,1)^2), wthresh(C(S(1,1)^2+1:length(C)),'s',SS)];

        %Merekonstruksi citra dari koefisien-koefisien hasil ambang-batas
        citraBaru=waverec2(softC,S,wavelet);
     
        %Menampilkan hasil citra ambang-batas
        axes(handles.axes4)
        imagesc(citraBaru); axis off;
     
        error = double(I) - citraBaru;
     
        MSE1 = sum(sum(error .* error)) / ((M * N)*N);
        set(handles.edit32, 'String', num2str(MSE1));
end


% --------------------------------------------------------------------
function uipanel4_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to uipanel4 (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 pushbutton19.
function pushbutton19_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton19 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global I

%kasus 1
% Mendefinisikan variansi derau
variansi = str2double(get(handles.editVariansi,'String'));
mu=20;
lambda=1;
tol=0.001;
[M,N]=size(I);
H1 = fspecial('average',11);
kabur1 = imfilter(I,H1,'replicate');
derau1 = imnoise(kabur1,'gaussian', 0,variansi);

g_denoise_atv = SB_ATV(double(derau1),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
MSE1 = sum(sum(error .* error)) / (M * M);
set(handles.edit34, 'String', num2str(MSE1));




%kasus 2
H2 = fspecial('gaussian',[11 11], 10);
kabur2 = imfilter(I,H2,'replicate');
derau2 = imnoise(kabur2, 'poisson');
g_denoise_atv = SB_ATV(double(derau2),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
MSE2 = sum(sum(error .* error)) / (M * M);
set(handles.edit35, 'String', num2str(MSE2));


%kasus 3
H3 = fspecial('disk',10);
kabur3 = imfilter(I,H3,'replicate');
derau3 = imnoise(kabur3,'salt & pepper',variansi);
g_denoise_atv = SB_ATV(double(derau3),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
        MSE3 = sum(sum(error .* error)) / (M * M);
        set(handles.edit36, 'String', num2str(MSE3));


%kasus 4
H4 = fspecial('motion',20,45);
kabur4 = imfilter(I,H4,'replicate');
derau4 = imnoise(kabur4,'speckle',variansi);
g_denoise_atv = SB_ATV(double(derau4),mu,tol,lambda);
error = double(I) - reshape(g_denoise_atv,M,M);
     
        MSE4 = sum(sum(error .* error)) / (M * M);
        set(handles.edit37, 'String', num2str(MSE4));


MSE_5 = [MSE1 MSE2 MSE3 MSE4];
global MSE_5


function edit34_Callback(hObject, eventdata, handles)
% hObject    handle to edit34 (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 edit34 as text
%        str2double(get(hObject,'String')) returns contents of edit34 as a double


% --- Executes during object creation, after setting all properties.
function edit34_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit34 (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 edit35_Callback(hObject, eventdata, handles)
% hObject    handle to edit35 (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 edit35 as text
%        str2double(get(hObject,'String')) returns contents of edit35 as a double


% --- Executes during object creation, after setting all properties.
function edit35_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit35 (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 edit36_Callback(hObject, eventdata, handles)
% hObject    handle to edit36 (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 edit36 as text
%        str2double(get(hObject,'String')) returns contents of edit36 as a double


% --- Executes during object creation, after setting all properties.
function edit36_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit36 (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 edit37_Callback(hObject, eventdata, handles)
% hObject    handle to edit37 (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 edit37 as text
%        str2double(get(hObject,'String')) returns contents of edit37 as a double


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


% --- Executes on button press in pushbutton20.
function pushbutton20_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton20 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

a = double(getimage(handles.axes3));
imt = double(getimage(handles.axes1));

%menampilkan citra berderau
axes(handles.axes2); imshow(a,[]); title('Citra Semula');

% Parameter-parameter NLEM
sigma = str2num(get(handles.editSigma,'String'));
P = str2num(get(handles.editP,'String'));
S = str2num(get(handles.editS,'String'));

%S  = 10;
%P  = 3;
%sigma = 70;
h  = 10 * sigma;

% memanggil NELM (atau NLEM_kNN)
imf = NLEM(a, h, P, S);
im1=a;
im2=a;

%menampilkan hasil
axes(handles.axes4); imshow(imf,[]); title('Hasil NLEM');



% metrik-metrik eveluasi kualitas fusi
[RMSE,PFE,MAE,CORR,SNR,PSNR,MI,QI,SSIM] = pereval(double(imt),im1,im2,imf);

t = handles.uitable4;

d = [RMSE,PFE,MAE,CORR,SNR,PSNR,MI,QI,SSIM,IMF, SF];

set(t,'Data',d);

set(t,'ColumnName',{'RMSE |(Root Mean Square Error)';'PFE |(Persentage Fit Error)';'MAE |(Mean Absolute Error)'; 'CORR| (Correlation)';...
    'SNR |(Signal to Noise Ratio'; 'PSNR |(Peak Signal to Noise Ratio)';'MI | (Mutual Information)'; 'QI| (Quality Index)';...
    'SSIM| (Measure of Structural Similarity)'; 'IMF | (Mutual Information)'; 'SF | (Spatial Information)'})


function editKunci_Callback(hObject, eventdata, handles)
% hObject    handle to editKunci (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 editKunci as text
%        str2double(get(hObject,'String')) returns contents of editKunci as a double


% --- Executes during object creation, after setting all properties.
function editKunci_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editKunci (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 editLambda_Callback(hObject, eventdata, handles)
% hObject    handle to editLambda (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 editLambda as text
%        str2double(get(hObject,'String')) returns contents of editLambda as a double


% --- Executes during object creation, after setting all properties.
function editLambda_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editLambda (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 edit40_Callback(hObject, eventdata, handles)
% hObject    handle to edit40 (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 edit40 as text
%        str2double(get(hObject,'String')) returns contents of edit40 as a double


% --- Executes during object creation, after setting all properties.
function edit40_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit40 (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 edit41_Callback(hObject, eventdata, handles)
% hObject    handle to edit41 (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 edit41 as text
%        str2double(get(hObject,'String')) returns contents of edit41 as a double


% --- Executes during object creation, after setting all properties.
function edit41_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit41 (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 edit42_Callback(hObject, eventdata, handles)
% hObject    handle to edit42 (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 edit42 as text
%        str2double(get(hObject,'String')) returns contents of edit42 as a double


% --- Executes during object creation, after setting all properties.
function edit42_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit42 (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 edit43_Callback(hObject, eventdata, handles)
% hObject    handle to edit43 (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 edit43 as text
%        str2double(get(hObject,'String')) returns contents of edit43 as a double


% --- Executes during object creation, after setting all properties.
function edit43_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit43 (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 edit44_Callback(hObject, eventdata, handles)
% hObject    handle to edit44 (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 edit44 as text
%        str2double(get(hObject,'String')) returns contents of edit44 as a double


% --- Executes during object creation, after setting all properties.
function edit44_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit44 (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 editMu_Callback(hObject, eventdata, handles)
% hObject    handle to editMu (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 editMu as text
%        str2double(get(hObject,'String')) returns contents of editMu as a double


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


% --- Executes on button press in pushbutton21.
function pushbutton21_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton21 (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 pushbutton22.
function pushbutton22_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton22 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

[namafile namapath]=uigetfile('*.jpg;*.bmp;*.jpeg;*.png;*.tif;','Pilih Sebuah Citra');
namacitra=[namapath namafile];


if(size(namacitra,3) == 3)
    namacitra = rgb2gray(namacitra);
end


axes(handles.axes3)
imshow(namacitra);title('Citra Fusi 1');

global I1
I1 = getimage(handles.axes3);


% --- Executes on button press in pushbutton24.
function pushbutton24_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton24 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

[namafile namapath]=uigetfile('*.jpg;*.bmp;*.jpeg;*.png;*.tif;','Pilih Sebuah Citra');
namacitra=[namapath namafile];


if(size(namacitra,3) == 3)
    namacitra = rgb2gray(namacitra);
end


axes(handles.axes10)
imshow(namacitra); title('Citra Fusi 2');

global I2
I2 = getimage(handles.axes10);


% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to axes1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate axes1


% --- Executes on button press in tombolKabur.
function tombolKabur_Callback(hObject, eventdata, handles)
% hObject    handle to tombolKabur (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.tombolDerau,'Enable','on');
set(handles.tombolKabur,'Enable','off');
set(handles.tombolRotasi,'Enable','off');
set(handles.tombolIntensitas,'Enable','off');
set(handles.tombolReset,'Enable','on');
set(handles.tombolEvaluasiLowPass,'Enable','on');
set(handles.tombolEvaluasiBandPass,'Enable','on');
set(handles.tombolEvaluasiHighPass,'Enable','on');
set(handles.tombolEvaluasiBandStop,'Enable','on');
I = getimage(handles.axes1);

I=getimage(handles.axes1);
[baris, kolom, banyakKanal] = size(I);

 if banyakKanal ==1
        imggray=I;
 else
    imggray=rgb2gray(I);
 end
I = imggray;



%axes(handles.axes1)
%imshow(imggray);title('Citra Semula')

switch get(handles.popupmenu7,'Value')
    case 1
       kabur = I;
       set(handles.tombolKabur,'Enable','on');
    case 2
       H = fspecial('average',11);
       kabur = imfilter(I,H,'replicate');
       set(handles.tombolKabur,'Enable','on');
    case 3
       H = fspecial('motion',20,45);
       kabur = imfilter(I,H,'replicate');
       set(handles.tombolKabur,'Enable','on');
    case 4
       H = fspecial('disk',10);
       kabur = imfilter(I,H,'replicate');
       set(handles.tombolKabur,'Enable','on');
    case 5
       H = fspecial('gaussian',[11 11], 10);
       kabur = imfilter(I,H,'replicate');
       set(handles.tombolKabur,'Enable','on');
end

axes(handles.axes3)
imshow(uint8(kabur)); title('Citra Hasil Pengaburan')


% --- Executes on button press in tombolDerau.
function tombolDerau_Callback(hObject, eventdata, handles)
% hObject    handle to tombolDerau (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.tombolDerau,'Enable','off');
set(handles.tombolKabur,'Enable','off');
set(handles.tombolRotasi,'Enable','on');
set(handles.tombolIntensitas,'Enable','on');
set(handles.tombolReset,'Enable','on');
set(handles.tombolEvaluasiLowPass,'Enable','on');
set(handles.tombolEvaluasiBandPass,'Enable','on');
set(handles.tombolEvaluasiHighPass,'Enable','on');
set(handles.tombolEvaluasiBandStop,'Enable','on');
I_kabur = getimage(handles.axes3);

% Mendefinisikan variansi derau
variansi = str2double(get(handles.editVariansi,'String'));

switch get(handles.popupmenu8,'Value')
    case 1
       derau = imnoise(I_kabur,'gaussian', 0,variansi);
    case 2
       derau = imnoise(I_kabur, 'poisson');
    case 3
       derau = imnoise(I_kabur,'salt & pepper',variansi);
    case 4
       derau = imnoise(I_kabur,'speckle',variansi);
end

axes(handles.axes3)
imshow(uint8(derau)); title('Citra Pengaburan dan Derau')


% --- Executes on selection change in popupmenu7.
function popupmenu7_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu7 (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 popupmenu7 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu7


% --- Executes during object creation, after setting all properties.
function popupmenu7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu 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


% --- Executes on selection change in popupmenu8.
function popupmenu8_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu8 (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 popupmenu8 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu8


% --- Executes during object creation, after setting all properties.
function popupmenu8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu 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


% --- Executes on button press in pushbutton27.
function pushbutton27_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton27 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global I_derau1
global I_derau2
global I

im1 = double(I_derau1);
im2 = double(I_derau2);
imt = double(I);

% Mendefinisikan ukuran blok
bs = str2num(get(handles.editJendela,'String'));
%bs = 8;
class(bs)
%%
mode = [0 1 3 4 5 6 7 8]; % mode direksional
lmode = length(mode);

    h1 = waitbar(0,'Silahkan tunggu...');
    for j=1:lmode
        imf1{j} = DDCTIFmax(im1,im2,bs,mode(j));
        waitbar(j/lmode,h1);
    end
    close(h1);
 
%%
% fusi dengan PCA
imf = fuse_pca(imf1{1},imf1{2},imf1{3},imf1{4},imf1{5},imf1{6},imf1{7},imf1{8});

%%
%menampilkan citra terfusi
axes(handles.axes2); imshow(imf,[]); title('Citra Terfusi');

%citra error
imd = double(imt)-double(imf);
axes(handles.axes4); imshow(imd,[]); title('Citra Error');

% metrik-metrik eveluasi kualitas fusi
[RMSE,PFE,MAE,CORR,SNR,PSNR,MI,QI,SSIM] = pereval(double(imt),im1,im2,imf);

t = handles.uitable1;

d = [RMSE,PFE,MAE,CORR,SNR,PSNR,MI,QI,SSIM];

set(t,'Data',d);

set(t,'ColumnName',{'RMSE |(Root Mean Square Error)';'PFE |(Persentage Fit Error)';'MAE |(Mean Absolute Error)'; 'CORR| (Correlation)';...
    'SNR |(Signal to Noise Ratio'; 'PSNR |(Peak Signal to Noise Ratio)';'MI | (Mutual Information)'; 'QI| (Quality Index)';...
    'SSIM| (Measure of Structural Similarity)';})


% --- Executes on button press in pushbutton28.
function pushbutton28_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton28 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global I_derau1
global I_derau2
global I

im1 = double(I_derau1);
im2 = double(I_derau2);
imt = double(I);

% Mendefinisikan ukuran blok
bs = str2num(get(handles.editJendela,'String'));
%bs = 8;
class(bs)
%%
mode = [0 1 3 4 5 6 7 8]; % mode direksional
lmode = length(mode);

    h1 = waitbar(0,'Silahkan tunggu...');
    for j=1:lmode
        imf1{j} = DDCTIFek(im1,im2,bs,mode(j));
        waitbar(j/lmode,h1);
    end
    close(h1);
 
%%
% fusi dengan PCA
imf = fuse_pca(imf1{1},imf1{2},imf1{3},imf1{4},imf1{5},imf1{6},imf1{7},imf1{8});

%%
%menampilkan citra terfusi
axes(handles.axes2); imshow(imf,[]); title('Citra Terfusi');

%citra error
imd = double(imt)-double(imf);
axes(handles.axes4); imshow(imd,[]); title('Citra Error');

% metrik-metrik eveluasi kualitas fusi
[RMSE,PFE,MAE,CORR,SNR,PSNR,MI,QI,SSIM] = pereval(double(imt),im1,im2,imf);

t = handles.uitable1;

d = [RMSE,PFE,MAE,CORR,SNR,PSNR,MI,QI,SSIM];

set(t,'Data',d);

set(t,'ColumnName',{'RMSE |(Root Mean Square Error)';'PFE |(Persentage Fit Error)';'MAE |(Mean Absolute Error)'; 'CORR| (Correlation)';...
    'SNR |(Signal to Noise Ratio'; 'PSNR |(Peak Signal to Noise Ratio)';'MI | (Mutual Information)'; 'QI| (Quality Index)';...
    'SSIM| (Measure of Structural Similarity)';})




function editJendela_Callback(hObject, eventdata, handles)
% hObject    handle to editJendela (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 editJendela as text
%        str2double(get(hObject,'String')) returns contents of editJendela as a double


% --- Executes during object creation, after setting all properties.
function editJendela_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editJendela (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 editAlfa_Callback(hObject, eventdata, handles)
% hObject    handle to editAlfa (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 editAlfa as text
%        str2double(get(hObject,'String')) returns contents of editAlfa as a double


% --- Executes during object creation, after setting all properties.
function editAlfa_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editAlfa (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 editBeta_Callback(hObject, eventdata, handles)
% hObject    handle to editBeta (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 editBeta as text
%        str2double(get(hObject,'String')) returns contents of editBeta as a double


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


% --- Executes on button press in pushbutton29.
function pushbutton29_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton29 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

b = getimage(handles.axes3);
a = getimage(handles.axes1);


[kpl1,i2a] = sift(a);
[kpl2,i2b] = sift(b);

axes(handles.axes2); imshow(i2a,[]); title('Citra 1 Dengan Titik-Titik Kunci');
axes(handles.axes4); imshow(i2b,[]); title('Citra 2 Dengan Titik-Titik Kunci');

%% Perbandingan titik-titik kunci pada kedua citra
tic
cacah=0;
for i=1:2:length(kpl1)
    for j=1:2:length(kpl2)
        if (kpl1(i)==kpl2(j))  &&   (kpl1(i+1)==kpl2(j+1))
            cacah=cacah+1;
            break;
        end
    end
end
mp=(cacah/(0.5*length(kpl1)))*100;
set(handles.editSigma,'String',mp);



function editSigma_Callback(hObject, eventdata, handles)
% hObject    handle to editSigma (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 editSigma as text
%        str2double(get(hObject,'String')) returns contents of editSigma as a double


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


% --- Executes on button press in tombolRotasi.
function tombolRotasi_Callback(hObject, eventdata, handles)
% hObject    handle to tombolRotasi (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

I_derau = getimage(handles.axes3);

% Mendefinisikan sudut
sudut = str2double(get(handles.editSudut,'String'));

derau =imrotate(I_derau,sudut);

axes(handles.axes3)
imshow(derau); title('Citra Hasil Rotasi');

% --- Executes on button press in tombolIntensitas.
function tombolIntensitas_Callback(hObject, eventdata, handles)
% hObject    handle to tombolIntensitas (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

I_kabur1 = getimage(handles.axes3);

% Mendefinisikan faktor
faktor = str2double(get(handles.editFaktor,'String'));

derau2 =I_kabur1/faktor;

axes(handles.axes3)
imshow(derau2); title('Citra 2');

function editFaktor_Callback(hObject, eventdata, handles)
% hObject    handle to editFaktor (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 editFaktor as text
%        str2double(get(hObject,'String')) returns contents of editFaktor as a double


% --- Executes during object creation, after setting all properties.
function editFaktor_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editFaktor (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 editSudut_Callback(hObject, eventdata, handles)
% hObject    handle to editSudut (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 editSudut as text
%        str2double(get(hObject,'String')) returns contents of editSudut as a double


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


% --- Executes on button press in tombolReset.
function tombolReset_Callback(hObject, eventdata, handles)
% hObject    handle to tombolReset (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.tombolDerau,'Enable','off');
set(handles.tombolKabur,'Enable','on');
set(handles.tombolRotasi,'Enable','off');
set(handles.tombolIntensitas,'Enable','off');
set(handles.tombolReset,'Enable','on');
set(handles.tombolEvaluasiLowPass,'Enable','off');
set(handles.tombolEvaluasiBandPass,'Enable','off');
set(handles.tombolEvaluasiHighPass,'Enable','off');
set(handles.tombolEvaluasiBandStop,'Enable','off');
I1 = getimage(handles.axes1);

axes(handles.axes3)
imshow(I1); title('Citra 2');



function editS_Callback(hObject, eventdata, handles)
% hObject    handle to editS (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 editS as text
%        str2double(get(hObject,'String')) returns contents of editS as a double


% --- Executes during object creation, after setting all properties.
function editS_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editS (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 editP_Callback(hObject, eventdata, handles)
% hObject    handle to editP (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 editP as text
%        str2double(get(hObject,'String')) returns contents of editP as a double


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


% --- Executes on button press in tombolEvaluasiLowPass.
function tombolEvaluasiLowPass_Callback(hObject, eventdata, handles)
% hObject    handle to tombolEvaluasiLowPass (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

I=im2double(getimage(handles.axes1));
[baris, kolom, banyakKanal] = size(I);

 if banyakKanal ==1
        Semula=I;
 else
    Semula=rgb2gray(I);
 end

% Frek Cut-Off 50
oimg1=getimage(handles.axes3);
[fftI1, filterKeluaran1, hasil1] = butterworthlpf(oimg1,50,4);

% Frek Cut-Off 100
[fftI2, filterKeluaran2, hasil2] = butterworthlpf(oimg1,100,4);

% Frek Cut-Off 150
[fftI3, filterKeluaran3, hasil3] = butterworthlpf(oimg1,150,4);

% Frek Cut-Off 200
[fftI4, filterKeluaran4, hasil4] = butterworthlpf(oimg1,200,4);

% Frek Cut-Off 250
[fftI5, filterKeluaran5, hasil5] = butterworthlpf(oimg1,250,4);

% Frek Cut-Off 500
[fftI6, filterKeluaran6, hasil6] = butterworthlpf(oimg1,500,4);

% Frek Cut-Off 1000
[fftI7, filterKeluaran7, hasil7] = butterworthlpf(oimg1,1000,4);


% metrik-metrik evaluasi kualitas citra
[m,n]=size(Semula);
hasil1 = imresize(hasil1,[m n]);
hasil2 = imresize(hasil2,[m n]);
hasil3 = imresize(hasil3,[m n]);
hasil4 = imresize(hasil4,[m n]);
hasil5 = imresize(hasil5,[m n]);
hasil6 = imresize(hasil6,[m n]);
hasil7 = imresize(hasil7,[m n]);

oimg1 = imresize(oimg1,[m n]);

size(oimg1)
size(Semula)
size(hasil1)
[RMSE1,PFE1,MAE1,CORR1,SNR1,PSNR1,MI1,QI1,SSIM1] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil1));
[RMSE2,PFE2,MAE2,CORR2,SNR2,PSNR2,MI2,QI2,SSIM2] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil2));
[RMSE3,PFE3,MAE3,CORR3,SNR3,PSNR3,MI3,QI3,SSIM3] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil3));
[RMSE4,PFE4,MAE4,CORR4,SNR4,PSNR4,MI4,QI4,SSIM4] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil4));
[RMSE5,PFE5,MAE5,CORR5,SNR5,PSNR5,MI5,QI5,SSIM5] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil5));
[RMSE6,PFE6,MAE6,CORR6,SNR6,PSNR6,MI6,QI6,SSIM6] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil6));
[RMSE7,PFE7,MAE7,CORR7,SNR7,PSNR7,MI7,QI7,SSIM7] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil7));

t = handles.uitable4;

d1 = [RMSE1,PFE1,MAE1,CORR1,SNR1,PSNR1,MI1,QI1,SSIM1];
d2 = [RMSE2,PFE2,MAE2,CORR2,SNR2,PSNR2,MI2,QI2,SSIM2];
d3 = [RMSE3,PFE3,MAE3,CORR3,SNR3,PSNR3,MI3,QI3,SSIM3];
d4 = [RMSE4,PFE4,MAE4,CORR4,SNR4,PSNR4,MI4,QI4,SSIM4];
d5 = [RMSE5,PFE5,MAE5,CORR5,SNR5,PSNR5,MI5,QI5,SSIM5];
d6 = [RMSE6,PFE6,MAE6,CORR6,SNR6,PSNR6,MI6,QI6,SSIM6];
d7 = [RMSE7,PFE7,MAE7,CORR7,SNR7,PSNR7,MI7,QI7,SSIM7];

d = [d1;d2; d3; d4; d5; d6; d7];

set(t,'Data',d);

set(t,'ColumnName',{'RMSE |(Root Mean Square Error)';'PFE |(Persentage Fit Error)';'MAE |(Mean Absolute Error)'; 'CORR| (Correlation)';...
    'SNR |(Signal to Noise Ratio'; 'PSNR |(Peak Signal to Noise Ratio)';'MI | (Mutual Information)'; 'QI| (Quality Index)';...
    'SSIM| (Measure of Structural Similarity)';})

set(t,'RowName',{'50 Hz'; '100 Hz'; '150 Hz'; '200 Hz'; '250 Hz'; '500 Hz'; '1000 Hz'});

%Menampilkan grafik
z=1:9;
axes(handles.axes11);
plot(z',d1, z',d2, z',d3, z',d4, z',d5, z',d6, z',d7); title('Grafik Kinerja TAPIS BUTTERWORTH LOWPASS'); grid on;
legend('50 Hz', '100 Hz', '150 Hz', '200 Hz', '250 Hz', '500 Hz', '1000 Hz')
set(gca,'XTick',1:9)
set(gca,'XTickLabel',{'RMSE','PFE','MAE','CORR','SNR','PSNR','MI','QI','SSIM'});



% --- Executes when selected object is changed in uipanel21.
function uipanel21_SelectionChangeFcn(hObject, eventdata, handles)
% hObject    handle to the selected object in uipanel21
% eventdata  structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles    structure with handles and user data (see GUIDATA)

%Semula = getimage(handles.axes1);
set(handles.tombolEvaluasiHighPass,'Enable','off');
set(handles.tombolEvaluasiBandStop,'Enable','off');
set(handles.tombolEvaluasiBandPass,'Enable','off');
set(handles.tombolEvaluasiLowPass,'Enable','on');

I=getimage(handles.axes1);
[baris, kolom, banyakKanal] = size(I);

 if banyakKanal ==1
        Semula=I;
 else
    Semula=rgb2gray(I);
 end

oimg1=getimage(handles.axes3);

switch get(eventdata.NewValue, 'Tag')
    case 'rad50'
        judul='Hasil Butterworth Lowpass Frek Cut-off 50 Hz';
        [fftI, filterKeluaran, hasil] = butterworthlpf(oimg1,50,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
    case 'rad100'
        judul='Hasil Butterworth Lowpass Frek Cut-off 100 Hz';
        [fftI, filterKeluaran, hasil] = butterworthlpf(oimg1,100,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
    case 'rad150'
        judul='Hasil Butterworth Lowpass Frek Cut-off 150 Hz';
        [fftI, filterKeluaran, hasil] = butterworthlpf(oimg1,150,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
    case 'rad200'
        judul='Hasil Butterworth Lowpass Frek Cut-off 200 Hz'
        [fftI, filterKeluaran, hasil] = butterworthlpf(oimg1,200,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
     
        case 'rad250'
        judul='Hasil Butterworth Lowpass Frek Cut-off 250 Hz'
        [fftI, filterKeluaran, hasil] = butterworthlpf(oimg1,250,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
     
        case 'rad500'
        judul='Hasil Butterworth Lowpass Frek Cut-off 500 Hz'
        [fftI, filterKeluaran, hasil] = butterworthlpf(oimg1,500,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
     
        case 'rad1000'
        judul='Hasil Butterworth Lowpass Frek Cut-off 1000 Hz'
        [fftI, filterKeluaran, hasil] = butterworthlpf(oimg1,1000,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
end


%citra error
[m,n]=size(Semula);
hasil = imresize(hasil,[m n]);
% Normalisasi dari double ke uint8
%hasil = 255*hasil;
imd = double(Semula)-double(hasil);
axes(handles.axes4); imshow(imd,[]); title('Citra Error');

figure,
subplot(2,2,1)
imshow(I,[]);
title('Citra Masukan')
subplot(2,2,2)
imshow(fftI,[])
title('Citra Pada Domain Frekuensi')
subplot(2,2,3)
imshow(filterKeluaran,[])
title('Citra Tapis')
subplot(2,2,4)
imshow(hasil,[])
title('Citra Tertapis')



% --- Executes during object creation, after setting all properties.
function uipanel21_CreateFcn(hObject, eventdata, handles)
% hObject    handle to uipanel21 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called


% --- Executes on button press in tombolEvaluasiBandPass.
function tombolEvaluasiBandPass_Callback(hObject, eventdata, handles)
% hObject    handle to tombolEvaluasiBandPass (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%set(handles.tombolEvaluasiLowPass,'Enable','on');
%set(handles.tombolEvaluasiBandPass,'Enable','off');

I=im2double(getimage(handles.axes1));
[baris, kolom, banyakKanal] = size(I);

 if banyakKanal ==1
        Semula=I;
 else
    Semula=rgb2gray(I);
 end

% Frek Cut-Off 5|100
oimg1=getimage(handles.axes3);
[fftI1, filterKeluaran1, hasil1] = butterworthbpf(oimg1,5,100,4);

% Frek Cut-Off 100|200
[fftI2, filterKeluaran2, hasil2] = butterworthbpf(oimg1,100,200,4);

% Frek Cut-Off 150|250
[fftI3, filterKeluaran3, hasil3] = butterworthbpf(oimg1,150,250,4);

% Frek Cut-Off 200|350
[fftI4, filterKeluaran4, hasil4] = butterworthbpf(oimg1,200,350,4);

% Frek Cut-Off 250|400
[fftI5, filterKeluaran5, hasil5] = butterworthbpf(oimg1,250,400,4);

% Frek Cut-Off 500|700
[fftI6, filterKeluaran6, hasil6] = butterworthbpf(oimg1,500,700,4);

% Frek Cut-Off 1000|1500
[fftI7, filterKeluaran7, hasil7] = butterworthbpf(oimg1,1000,1500,4);


% metrik-metrik evaluasi kualitas citra
[m,n]=size(Semula);
hasil1 = imresize(hasil1,[m n]);
hasil2 = imresize(hasil2,[m n]);
hasil3 = imresize(hasil3,[m n]);
hasil4 = imresize(hasil4,[m n]);
hasil5 = imresize(hasil5,[m n]);
hasil6 = imresize(hasil6,[m n]);
hasil7 = imresize(hasil7,[m n]);

oimg1 = imresize(oimg1,[m n]);

size(oimg1)
size(Semula)
size(hasil1)
[RMSE1,PFE1,MAE1,CORR1,SNR1,PSNR1,MI1,QI1,SSIM1] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil1));
[RMSE2,PFE2,MAE2,CORR2,SNR2,PSNR2,MI2,QI2,SSIM2] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil2));
[RMSE3,PFE3,MAE3,CORR3,SNR3,PSNR3,MI3,QI3,SSIM3] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil3));
[RMSE4,PFE4,MAE4,CORR4,SNR4,PSNR4,MI4,QI4,SSIM4] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil4));
[RMSE5,PFE5,MAE5,CORR5,SNR5,PSNR5,MI5,QI5,SSIM5] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil5));
[RMSE6,PFE6,MAE6,CORR6,SNR6,PSNR6,MI6,QI6,SSIM6] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil6));
[RMSE7,PFE7,MAE7,CORR7,SNR7,PSNR7,MI7,QI7,SSIM7] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil7));

t = handles.uitable4;

d1 = [RMSE1,PFE1,MAE1,CORR1,SNR1,PSNR1,MI1,QI1,SSIM1];
d2 = [RMSE2,PFE2,MAE2,CORR2,SNR2,PSNR2,MI2,QI2,SSIM2];
d3 = [RMSE3,PFE3,MAE3,CORR3,SNR3,PSNR3,MI3,QI3,SSIM3];
d4 = [RMSE4,PFE4,MAE4,CORR4,SNR4,PSNR4,MI4,QI4,SSIM4];
d5 = [RMSE5,PFE5,MAE5,CORR5,SNR5,PSNR5,MI5,QI5,SSIM5];
d6 = [RMSE6,PFE6,MAE6,CORR6,SNR6,PSNR6,MI6,QI6,SSIM6];
d7 = [RMSE7,PFE7,MAE7,CORR7,SNR7,PSNR7,MI7,QI7,SSIM7];

d = [d1;d2; d3; d4; d5; d6; d7];

set(t,'Data',d);

set(t,'ColumnName',{'RMSE |(Root Mean Square Error)';'PFE |(Persentage Fit Error)';'MAE |(Mean Absolute Error)'; 'CORR| (Correlation)';...
    'SNR |(Signal to Noise Ratio'; 'PSNR |(Peak Signal to Noise Ratio)';'MI | (Mutual Information)'; 'QI| (Quality Index)';...
    'SSIM| (Measure of Structural Similarity)';})

set(t,'RowName',{'5|100 Hz'; '100|200 Hz'; '150|250 Hz'; '200|350 Hz'; '250|400 Hz'; '500|700 Hz'; '1000|1500 Hz'});

%Menampilkan grafik
z=1:9;
axes(handles.axes11);
plot(z',d1, z',d2, z',d3, z',d4, z',d5, z',d6, z',d7); title('Grafik Kinerja TAPIS BUTTERWORTH BANDPASS'); grid on;
legend('5|100 Hz', '100|200 Hz', '150|250 Hz', '200|350 Hz', '250|400 Hz', '500|700 Hz', '1000|1500 Hz')
set(gca,'XTick',1:9)
set(gca,'XTickLabel',{'RMSE','PFE','MAE','CORR','SNR','PSNR','MI','QI','SSIM'});


% --- Executes on button press in tombolEvaluasiHighPass.
function tombolEvaluasiHighPass_Callback(hObject, eventdata, handles)
% hObject    handle to tombolEvaluasiHighPass (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

I=im2double(getimage(handles.axes1));
[baris, kolom, banyakKanal] = size(I);

 if banyakKanal ==1
        Semula=I;
 else
    Semula=rgb2gray(I);
 end

% Frek Cut-Off 50
oimg1=getimage(handles.axes3);
[fftI1, filterKeluaran1, hasil1] = butterworthhpf(oimg1,50,4);

% Frek Cut-Off 100
[fftI2, filterKeluaran2, hasil2] = butterworthhpf(oimg1,100,4);

% Frek Cut-Off 150
[fftI3, filterKeluaran3, hasil3] = butterworthhpf(oimg1,150,4);

% Frek Cut-Off 200
[fftI4, filterKeluaran4, hasil4] = butterworthhpf(oimg1,200,4);

% Frek Cut-Off 250
[fftI5, filterKeluaran5, hasil5] = butterworthhpf(oimg1,250,4);

% Frek Cut-Off 500
[fftI6, filterKeluaran6, hasil6] = butterworthhpf(oimg1,500,4);

% Frek Cut-Off 1000
[fftI7, filterKeluaran7, hasil7] = butterworthhpf(oimg1,1000,4);


% metrik-metrik evaluasi kualitas citra
[m,n]=size(Semula);
hasil1 = imresize(hasil1,[m n]);
hasil2 = imresize(hasil2,[m n]);
hasil3 = imresize(hasil3,[m n]);
hasil4 = imresize(hasil4,[m n]);
hasil5 = imresize(hasil5,[m n]);
hasil6 = imresize(hasil6,[m n]);
hasil7 = imresize(hasil7,[m n]);

oimg1 = imresize(oimg1,[m n]);

size(oimg1)
size(Semula)
size(hasil1)
[RMSE1,PFE1,MAE1,CORR1,SNR1,PSNR1,MI1,QI1,SSIM1] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil1));
[RMSE2,PFE2,MAE2,CORR2,SNR2,PSNR2,MI2,QI2,SSIM2] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil2));
[RMSE3,PFE3,MAE3,CORR3,SNR3,PSNR3,MI3,QI3,SSIM3] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil3));
[RMSE4,PFE4,MAE4,CORR4,SNR4,PSNR4,MI4,QI4,SSIM4] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil4));
[RMSE5,PFE5,MAE5,CORR5,SNR5,PSNR5,MI5,QI5,SSIM5] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil5));
[RMSE6,PFE6,MAE6,CORR6,SNR6,PSNR6,MI6,QI6,SSIM6] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil6));
[RMSE7,PFE7,MAE7,CORR7,SNR7,PSNR7,MI7,QI7,SSIM7] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil7));

t = handles.uitable4;

d1 = [RMSE1,PFE1,MAE1,CORR1,SNR1,PSNR1,MI1,QI1,SSIM1];
d2 = [RMSE2,PFE2,MAE2,CORR2,SNR2,PSNR2,MI2,QI2,SSIM2];
d3 = [RMSE3,PFE3,MAE3,CORR3,SNR3,PSNR3,MI3,QI3,SSIM3];
d4 = [RMSE4,PFE4,MAE4,CORR4,SNR4,PSNR4,MI4,QI4,SSIM4];
d5 = [RMSE5,PFE5,MAE5,CORR5,SNR5,PSNR5,MI5,QI5,SSIM5];
d6 = [RMSE6,PFE6,MAE6,CORR6,SNR6,PSNR6,MI6,QI6,SSIM6];
d7 = [RMSE7,PFE7,MAE7,CORR7,SNR7,PSNR7,MI7,QI7,SSIM7];

d = [d1;d2; d3; d4; d5; d6; d7];

set(t,'Data',d);

set(t,'ColumnName',{'RMSE |(Root Mean Square Error)';'PFE |(Persentage Fit Error)';'MAE |(Mean Absolute Error)'; 'CORR| (Correlation)';...
    'SNR |(Signal to Noise Ratio'; 'PSNR |(Peak Signal to Noise Ratio)';'MI | (Mutual Information)'; 'QI| (Quality Index)';...
    'SSIM| (Measure of Structural Similarity)';})

set(t,'RowName',{'50 Hz'; '100 Hz'; '150 Hz'; '200 Hz'; '250 Hz'; '500 Hz'; '1000 Hz'});

%Menampilkan grafik
z=1:9;
axes(handles.axes11);
plot(z',d1, z',d2, z',d3, z',d4, z',d5, z',d6, z',d7); title('Grafik Kinerja TAPIS BUTTERWORTH HIGHPASS'); grid on;
legend('50 Hz', '100 Hz', '150 Hz', '200 Hz', '250 Hz', '500 Hz', '1000 Hz')
set(gca,'XTick',1:9)
set(gca,'XTickLabel',{'RMSE','PFE','MAE','CORR','SNR','PSNR','MI','QI','SSIM'});


% --- Executes on button press in tombolEvaluasiBandStop.
function tombolEvaluasiBandStop_Callback(hObject, eventdata, handles)
% hObject    handle to tombolEvaluasiBandStop (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

I=im2double(getimage(handles.axes1));
[baris, kolom, banyakKanal] = size(I);

 if banyakKanal ==1
        Semula=I;
 else
    Semula=rgb2gray(I);
 end

% Frek Cut-Off 5|100
oimg1=getimage(handles.axes3);
[fftI1, filterKeluaran1, hasil1] = butterworthbspf(oimg1,5,100,4);

% Frek Cut-Off 100|200
[fftI2, filterKeluaran2, hasil2] = butterworthbspf(oimg1,100,200,4);

% Frek Cut-Off 150|250
[fftI3, filterKeluaran3, hasil3] = butterworthbspf(oimg1,150,250,4);

% Frek Cut-Off 200|350
[fftI4, filterKeluaran4, hasil4] = butterworthbspf(oimg1,200,350,4);

% Frek Cut-Off 250|400
[fftI5, filterKeluaran5, hasil5] = butterworthbspf(oimg1,250,400,4);

% Frek Cut-Off 500|700
[fftI6, filterKeluaran6, hasil6] = butterworthbspf(oimg1,500,700,4);

% Frek Cut-Off 1000|1500
[fftI7, filterKeluaran7, hasil7] = butterworthbspf(oimg1,1000,1500,4);


% metrik-metrik evaluasi kualitas citra
[m,n]=size(Semula);
hasil1 = imresize(hasil1,[m n]);
hasil2 = imresize(hasil2,[m n]);
hasil3 = imresize(hasil3,[m n]);
hasil4 = imresize(hasil4,[m n]);
hasil5 = imresize(hasil5,[m n]);
hasil6 = imresize(hasil6,[m n]);
hasil7 = imresize(hasil7,[m n]);

oimg1 = imresize(oimg1,[m n]);

size(oimg1)
size(Semula)
size(hasil1)
[RMSE1,PFE1,MAE1,CORR1,SNR1,PSNR1,MI1,QI1,SSIM1] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil1));
[RMSE2,PFE2,MAE2,CORR2,SNR2,PSNR2,MI2,QI2,SSIM2] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil2));
[RMSE3,PFE3,MAE3,CORR3,SNR3,PSNR3,MI3,QI3,SSIM3] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil3));
[RMSE4,PFE4,MAE4,CORR4,SNR4,PSNR4,MI4,QI4,SSIM4] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil4));
[RMSE5,PFE5,MAE5,CORR5,SNR5,PSNR5,MI5,QI5,SSIM5] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil5));
[RMSE6,PFE6,MAE6,CORR6,SNR6,PSNR6,MI6,QI6,SSIM6] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil6));
[RMSE7,PFE7,MAE7,CORR7,SNR7,PSNR7,MI7,QI7,SSIM7] = pereval(double(Semula),double(oimg1),double(oimg1),double(hasil7));

t = handles.uitable4;

d1 = [RMSE1,PFE1,MAE1,CORR1,SNR1,PSNR1,MI1,QI1,SSIM1];
d2 = [RMSE2,PFE2,MAE2,CORR2,SNR2,PSNR2,MI2,QI2,SSIM2];
d3 = [RMSE3,PFE3,MAE3,CORR3,SNR3,PSNR3,MI3,QI3,SSIM3];
d4 = [RMSE4,PFE4,MAE4,CORR4,SNR4,PSNR4,MI4,QI4,SSIM4];
d5 = [RMSE5,PFE5,MAE5,CORR5,SNR5,PSNR5,MI5,QI5,SSIM5];
d6 = [RMSE6,PFE6,MAE6,CORR6,SNR6,PSNR6,MI6,QI6,SSIM6];
d7 = [RMSE7,PFE7,MAE7,CORR7,SNR7,PSNR7,MI7,QI7,SSIM7];

d = [d1;d2; d3; d4; d5; d6; d7];

set(t,'Data',d);

set(t,'ColumnName',{'RMSE |(Root Mean Square Error)';'PFE |(Persentage Fit Error)';'MAE |(Mean Absolute Error)'; 'CORR| (Correlation)';...
    'SNR |(Signal to Noise Ratio'; 'PSNR |(Peak Signal to Noise Ratio)';'MI | (Mutual Information)'; 'QI| (Quality Index)';...
    'SSIM| (Measure of Structural Similarity)';})

set(t,'RowName',{'5|100 Hz'; '100|200 Hz'; '150|250 Hz'; '200|350 Hz'; '250|400 Hz'; '500|700 Hz'; '1000|1500 Hz'});

%Menampilkan grafik
z=1:9;
axes(handles.axes11);
plot(z',d1, z',d2, z',d3, z',d4, z',d5, z',d6, z',d7); title('Grafik Kinerja TAPIS BUTTERWORTH BANDSTOP'); grid on;
legend('5|100 Hz', '100|200 Hz', '150|250 Hz', '200|350 Hz', '250|400 Hz', '500|700 Hz', '1000|1500 Hz')
set(gca,'XTick',1:9)
set(gca,'XTickLabel',{'RMSE','PFE','MAE','CORR','SNR','PSNR','MI','QI','SSIM'});




% --- Executes when selected object is changed in uipanel25.
function uipanel25_SelectionChangeFcn(hObject, eventdata, handles)
% hObject    handle to the selected object in uipanel25
% eventdata  structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles    structure with handles and user data (see GUIDATA)

set(handles.tombolEvaluasiLowPass,'Enable','off');
set(handles.tombolEvaluasiHighPass,'Enable','off');
set(handles.tombolEvaluasiBandStop,'Enable','off');
set(handles.tombolEvaluasiBandPass,'Enable','on');

I=getimage(handles.axes1);
[baris, kolom, banyakKanal] = size(I);

 if banyakKanal ==1
        Semula=I;
 else
    Semula=rgb2gray(I);
 end

oimg1=getimage(handles.axes3);

switch get(eventdata.NewValue, 'Tag')
    case 'rb5'
        judul='Hasil Butterworth Bandpass Frek Cut-off 5|100 Hz';
        [fftI, filterKeluaran,hasil] = butterworthbpf(oimg1,5,100,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
    case 'rb100'
        judul='Hasil Butterworth Bandpass Frek Cut-off 100|200 Hz';
        [fftI, filterKeluaran,hasil] = butterworthbpf(oimg1,100,200,4);
        axes(handles.axes2)
        imshow(uint8(hasil));title(judul)
    case 'rb150'
        judul='Hasil Butterworth Bandpass Frek Cut-off 150|250 Hz';
        [fftI, filterKeluaran,hasil] = butterworthbpf(oimg1,150,250,4);
        axes(handles.axes2)
        imshow(uint8(hasil));title(judul)
    case 'rb200'
        judul='Hasil Butterworth Bandpass Frek Cut-off 200|350 Hz'
        [fftI, filterKeluaran,hasil] = butterworthbpf(oimg1,200,350,4);
        axes(handles.axes2)
        imshow(uint8(hasil));title(judul)
     
        case 'rb250'
        judul='Hasil Butterworth Bandpass Frek Cut-off 250|400 Hz'
        [fftI, filterKeluaran,hasil] = butterworthbpf(oimg1,250,400,4);
        axes(handles.axes2)
        imshow(uint8(hasil));title(judul)
     
        case 'rb500'
        judul='Hasil Butterworth Bandpass Frek Cut-off 400|700 Hz'
        [fftI, filterKeluaran,hasil] = butterworthbpf(oimg1,400,700,4);
        axes(handles.axes2)
        imshow(uint8(hasil));title(judul)
     
        case 'rb1000'
        judul='Hasil Butterworth Bandpass Frek Cut-off 1000|1500 Hz'
        [fftI, filterKeluaran,hasil] = butterworthbpf(oimg1,1000,1500,4);
        axes(handles.axes2)
        imshow(uint8(hasil));title(judul)
end


%citra error
[m,n]=size(Semula);
hasil = imresize(hasil,[m n]);
% Normalisasi dari double ke uint8
imd = double(Semula)-double(hasil);
axes(handles.axes4); imshow(imd,[]); title('Citra Error');

figure,
subplot(2,2,1)
imshow(I,[]);
title('Citra Masukan')
subplot(2,2,2)
imshow(fftI,[])
title('Citra Pada Domain Frekuensi')
subplot(2,2,3)
imshow(filterKeluaran,[])
title('Citra Tapis')
subplot(2,2,4)
imshow(uint8(hasil),[])
title('Citra Tertapis')


% --- Executes when selected object is changed in uipanel27.
function uipanel27_SelectionChangeFcn(hObject, eventdata, handles)
% hObject    handle to the selected object in uipanel27
% eventdata  structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles    structure with handles and user data (see GUIDATA)

set(handles.tombolEvaluasiLowPass,'Enable','off');
set(handles.tombolEvaluasiHighPass,'Enable','on');
set(handles.tombolEvaluasiBandStop,'Enable','off');
set(handles.tombolEvaluasiBandPass,'Enable','off');

I=getimage(handles.axes1);
[baris, kolom, banyakKanal] = size(I);

 if banyakKanal ==1
        Semula=I;
 else
    Semula=rgb2gray(I);
 end

switch get(eventdata.NewValue, 'Tag')
    case 'rd33'
        judul='Citra Penapisan Maksimum 3 x 3';
        oimg1=im2double(getimage(handles.axes3));
        hasil = ordfilt2(oimg1, 9, ones(3,3));
        axes(handles.axes2)
        imshow(hasil);title(judul)
    case 'rd55'
        judul='Citra Penapisan Maksimum 5 x 5';
        oimg1=im2double(getimage(handles.axes3));
        hasil = ordfilt2(oimg1, 15, ones(5,5));
        axes(handles.axes2)
        imshow(hasil);title(judul)
    case 'rd77'
        judul='Citra Penapisan Maksimum 7 x 7';
        oimg1=im2double(getimage(handles.axes3));
        hasil = ordfilt2(oimg1, 49, ones(7,7));
        axes(handles.axes2)
        imshow(hasil);title(judul)
    case 'rd11'
        judul='Citra Penapisan Maksimum 11 x 11'
        oimg1=im2double(getimage(handles.axes3));
        hasil = ordfilt2(oimg1, 121, ones(11,11));
        axes(handles.axes2)
        imshow(hasil);title(judul)
     
        case 'rd13'
        judul='Citra Penapisan Maksimum 13 x 13'
        oimg1=im2double(getimage(handles.axes3));
        hasil = ordfilt2(oimg1, 169, ones(13,13));
        axes(handles.axes2)
        imshow(hasil);title(judul)
     
        case 'rd15'
        judul='Citra Penapisan Maksimum 15 x 15'
        oimg1=im2double(getimage(handles.axes3));
        hasil = ordfilt2(oimg1, 225, ones(15,15));
        axes(handles.axes2)
        imshow(hasil);title(judul)
     
        case 'rd19'
        judul='Citra Penapisan Median  19 x 19'
        oimg1=im2double(getimage(handles.axes3));
        hasil = ordfilt2(oimg1, 361, ones(19,19));
        axes(handles.axes2)
        imshow(hasil);title(judul)
end


%citra error
[m,n]=size(Semula);
hasil = imresize(hasil,[m n]);
% Normalisasi dari double ke uint8
hasil = 255*hasil;
imd = double(Semula)-double(hasil);
axes(handles.axes4); imshow(imd,[]); title('Citra Error');


% --- Executes when selected object is changed in uipanel29.
function uipanel29_SelectionChangeFcn(hObject, eventdata, handles)
% hObject    handle to the selected object in uipanel29
% eventdata  structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles    structure with handles and user data (see GUIDATA)

set(handles.tombolEvaluasiLowPass,'Enable','off');
set(handles.tombolEvaluasiHighPass,'Enable','off');
set(handles.tombolEvaluasiBandStop,'Enable','on');
set(handles.tombolEvaluasiBandPass,'Enable','off');

I=getimage(handles.axes1);
[baris, kolom, banyakKanal] = size(I);

 if banyakKanal ==1
        Semula=I;
 else
    Semula=rgb2gray(I);
 end

oimg1=getimage(handles.axes3);

switch get(eventdata.NewValue, 'Tag')
    case 'rt5'
        judul='Hasil Butterworth Bandstop Frek Cut-off 5|100 Hz';
        [fftI, filterKeluaran,hasil] = butterworthbspf(oimg1,5,100,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
    case 'rt100'
        judul='Hasil Butterworth Bandstop Frek Cut-off 100|200 Hz';
        [fftI, filterKeluaran,hasil] = butterworthbspf(oimg1,100,200,4);
        axes(handles.axes2)
        imshow(uint8(hasil));title(judul)
    case 'rt150'
        judul='Hasil Butterworth Bandstop Frek Cut-off 150|250 Hz';
        [fftI, filterKeluaran,hasil] = butterworthbspf(oimg1,150,250,4);
        axes(handles.axes2)
        imshow(uint8(hasil));title(judul)
    case 'rt200'
        judul='Hasil Butterworth Bandstop Frek Cut-off 200|350 Hz'
        [fftI, filterKeluaran,hasil] = butterworthbspf(oimg1,200,350,4);
        axes(handles.axes2)
        imshow(uint8(hasil));title(judul)
     
        case 'rt250'
        judul='Hasil Butterworth Bandstop Frek Cut-off 250|400 Hz'
        [fftI, filterKeluaran,hasil] = butterworthbspf(oimg1,250,400,4);
        axes(handles.axes2)
        imshow(uint8(hasil));title(judul)
     
        case 'rt500'
        judul='Hasil Butterworth Bandstop Frek Cut-off 400|700 Hz'
        [fftI, filterKeluaran,hasil] = butterworthbspf(oimg1,400,700,4);
        axes(handles.axes2)
        imshow(uint8(hasil));title(judul)
     
        case 'rt1000'
        judul='Hasil Butterworth Bandstop Frek Cut-off 1000|1500 Hz'
        [fftI, filterKeluaran,hasil] = butterworthbspf(oimg1,1000,1500,4);
        axes(handles.axes2)
        imshow(uint8(hasil));title(judul)
end


%citra error
[m,n]=size(Semula);
hasil = imresize(hasil,[m n]);
% Normalisasi dari double ke uint8
imd = double(Semula)-double(hasil);
axes(handles.axes4); imshow(imd,[]); title('Citra Error');

figure,
subplot(2,2,1)
imshow(I,[]);
title('Citra Masukan')
subplot(2,2,2)
imshow(fftI,[])
title('Citra Pada Domain Frekuensi')
subplot(2,2,3)
imshow(filterKeluaran,[])
title('Citra Tapis')
subplot(2,2,4)
imshow(uint8(hasil),[])
title('Citra Tertapis')


% --- Executes when selected object is changed in uipanel31.
function uipanel31_SelectionChangeFcn(hObject, eventdata, handles)
% hObject    handle to the selected object in uipanel31
% eventdata  structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles    structure with handles and user data (see GUIDATA)

%Semula = getimage(handles.axes1);
set(handles.tombolEvaluasiHighPass,'Enable','on');
set(handles.tombolEvaluasiBandStop,'Enable','off');
set(handles.tombolEvaluasiBandPass,'Enable','off');
set(handles.tombolEvaluasiLowPass,'Enable','off');

I=getimage(handles.axes1);
[baris, kolom, banyakKanal] = size(I);

 if banyakKanal ==1
        Semula=I;
 else
    Semula=rgb2gray(I);
 end

oimg1=getimage(handles.axes3);

switch get(eventdata.NewValue, 'Tag')
    case 'rm50'
        judul='Hasil Butterworth HighPass Frek Cut-off 50 Hz';
        [fftI, filterKeluaran, hasil] = butterworthhpf(oimg1,50,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
    case 'rm100'
        judul='Hasil Butterworth HighPass Frek Cut-off 100 Hz';
        [fftI, filterKeluaran, hasil] = butterworthhpf(oimg1,100,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
    case 'rm150'
        judul='Hasil Butterworth HighPass Frek Cut-off 150 Hz';
        [fftI, filterKeluaran, hasil] = butterworthhpf(oimg1,150,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
    case 'rm200'
        judul='Hasil Butterworth HighPass Frek Cut-off 200 Hz'
        [fftI, filterKeluaran, hasil] = butterworthhpf(oimg1,200,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
     
        case 'rm250'
        judul='Hasil Butterworth HighPass Frek Cut-off 250 Hz'
        [fftI, filterKeluaran, hasil] = butterworthhpf(oimg1,250,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
     
        case 'rm500'
        judul='Hasil Butterworth HighPass Frek Cut-off 500 Hz'
        [fftI, filterKeluaran, hasil] = butterworthhpf(oimg1,500,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
     
        case 'rm1000'
        judul='Hasil Butterworth HighPass Frek Cut-off 1000 Hz'
        [fftI, filterKeluaran, hasil] = butterworthhpf(oimg1,1000,4);
        axes(handles.axes2)
        imshow(hasil);title(judul)
end


%citra error
[m,n]=size(Semula);
hasil = imresize(hasil,[m n]);
% Normalisasi dari double ke uint8
%hasil = 255*hasil;
imd = double(Semula)-double(hasil);
axes(handles.axes4); imshow(imd,[]); title('Citra Error');

figure,
subplot(2,2,1)
imshow(I,[]);
title('Citra Masukan')
subplot(2,2,2)
imshow(fftI,[])
title('Citra Pada Domain Frekuensi')
subplot(2,2,3)
imshow(filterKeluaran,[])
title('Citra Tapis')
subplot(2,2,4)
imshow(hasil,[])
title('Citra Tertapis')


No comments: