Sunday, June 25, 2017

Cara Membuat GUI MATLAB Untuk Enkripsi Citra Berbasis Algoritma Secyre Internet Of Things (SIT)









SEMUA EVENT CALLBACK GUI MATLAB:

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

% Last Modified by GUIDE v2.5 11-Mar-2017 14:36:41

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

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

% Update handles structure
guidata(hObject, handles);

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


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

[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);

axes(handles.axes3)
imhist(uint8(namacitra),128);

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)
addpath subFunctions
Test=0; % untuk enkripsi
% Test=1; % untuk sensitifitas kunci

% Memuat citra
Data=im2uint8(getimage(handles.axes3));
Data1=Data;
[brs,kol,dim]=size(Data);
if (dim>1)
Data=rgb2gray(Data); % konversi ke keabuan jika citra masukan adalah citra berwarna
end
IS=256;
Data=imresize(Data,[IS IS]); % Mengecilkan ukuran citra
%% Penskalaan dan konversi ke biner
% Penskalaan untuk mengkonversi citra menjadi sebuah array dengan 8 piksel; setiap
% piksel adalah 8 bit, oleh karena itu 8 piksel akan sama dengan 64 bit data
[brs,kol]=size(Data);
[Data,pengganjalan]=Scalling(Data,8);
data_biner=convert2bin(Data);

% Membangkitkan kunci
%kunci_heksa = '133457799bbcdff1';
kunci_heksa = get(handles.editKunci,'String');
[kunci_biner] = Hex2Bin(kunci_heksa);
[K1,K2,K3,K4,K5]=SF_Key_Gen(kunci_biner);

pesan_semula=[];
pesan_terenkripsi=[];
pesan_terdekripsi=[];


%% Proses Enkripsi
for kk=1:2
  for i=1:size(data_biner,1)
    semula=data_biner(i,:);
    tic
    [cipher]=SF_Encrypt(semula,K1,K2,K3,K4,K5);
    encryption_time(i)=toc;
    tK1=[K1(1:8),semula(1:8)];tK2=semula(9:24);tK3=semula(25:40);tK4=semula(41:56);tK5=[semula(57:64),K5(9:16)];
    K1=tK1;K2=tK2;K3=tK3;K4=tK4;K5=tK5;
 
    pesan_terenkripsi(:,i)=Binary2Dec(cipher);
    cipher_data(i,:)=double(cipher);
    if(kk<2)
    data_biner(i,:)=cipher_data(i,:);
    end
  end
if (kk==1)
D=reshape(pesan_terenkripsi,[brs,kol]);
D=D';
[brs,kol]=size(D);
[D,pengganjalan]=Scalling(D,8);
% Data=[Data Data];
data_biner=double(convert2bin(D));
    TT=[K1,K2,K3,K4,K5];
pesan_terenkripsi=[];
end
end

TTT=TT;
%% Dekripsi
if (Test==1)
 K1(end)=~K1(end);
 TT=[K1,K2,K3,K4,K5];
end

for kk=kk:-1:1
if(kk==2)
    K11=TT(1:16);K12=TT(17:32);K13=TT(33:48);K14=TT(49:64);K15=TT(65:80);
else
    [K11,K12,K13,K14,K15]=SF_Key_Gen(kunci_biner);
    D=reshape(pesan_terdekripsi,[brs,kol]);
D=D';
[brs,kol]=size(D);
[D,pengganjalan]=Scalling(D,8);
cipher_data=double(convert2bin(D));

pesan_terdekripsi=[];
end
for i=1:size(data_biner,1)
    cipher=cipher_data(i,:);
    [plaintext]=SF_Decryption(cipher,K11,K12,K13,K14,K15);
    K11=[K11(1:8),plaintext(1:8)];K12=plaintext(9:24);K13=plaintext(25:40);K14=plaintext(41:56);K15=[plaintext(57:64),K15(9:16)];

    pesan_terdekripsi(:,i)=Binary2Dec(plaintext);
    cipher_data(i,:)=double(plaintext);
end
end

% 5 Citra Semula
Semula=uint8(reshape(Data,[brs,kol]));
% 6 Citra Terenkripsi
Terenkripsi=uint8(reshape(pesan_terenkripsi,[brs,kol]));
% 7(Kunci Dekripsi Salah (Sensitivitas kunci))
Terdekripsi=uint8(reshape(pesan_terdekripsi,[brs,kol]));

%Simpan variabel
save('enkripsi.mat','Semula','Terenkripsi', 'Terdekripsi');

% Menampilkan hasil
axes(handles.axes2); imshow(Semula,[0 255]);
title('Citra Semula');

axes(handles.axes4); imshow(Terenkripsi,[0 255]);
title('Citra Terenkripsi');

axes(handles.axes7); imshow(Terdekripsi,[0 255]);
title('Citra Terdekripsi');


%% Menghitung Entropi Citra semula dan citra terenkripsi
axes(handles.axes5);
Y=(imhist(Terenkripsi)+0.00001)/(brs*kol);
Y1=-sum(Y.*log2(Y));

%imhist(uint8(Terenkripsi))
stem(Y)
title('Entropi Citra Terenkripsi');

axes(handles.axes6);
X=(imhist(Semula)+0.00001)/(brs*kol);
X1=-sum(X.*log2(X));
stem(X)

%imhist(uint8(X1))
title('Entropi Citra Semula');
Re=[X1 Y1]

% Menampilkan korelasi
axes(handles.axes9);
scatter(Semula(1:end-1),Semula(2:end),'.')
axis([0 255 0 255]);
title('Koefisien Korelasi Citra Semula');

axes(handles.axes8);
scatter(Terenkripsi(1:end-1),Terenkripsi(2:end),'.')
axis([0 255 0 255]);
title('Koefisien korelasi Citra Terenkripsi');


% % 1 NPCR(%)
NPCR=sum(sum(Terenkripsi~=Semula))*100/(brs*kol)
% 2 UACI(%)
UACI=sum(sum(abs(Terenkripsi-Semula)))*100/(brs*kol*255)

display(sprintf('Waktu total enkripsi: %f',sum(encryption_time)))

display('Koefisien korelasi atas citra semula')
corrcoef(double(Semula(1:end-1)),double(Semula(2:end)))
display('Koefisien korelasi atas citra terenkripsi')
corrcoef(double(Terenkripsi(1:end-1)),double(Terenkripsi(2:end)))


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)


No comments: