Function varargout = NaiveBayesClassifier(varargin) returns the handle to a new NaiveBayesClassifier or the handle to the existing singleton. An % unrecognized property name or invalid value makes property application % stop.
Function varargout = NaiveBayesClassifier(varargin) returns the handle to a new NaiveBayesClassifier or the handle to the existing singleton. An % unrecognized property name or invalid value makes property application % stop.
Function varargout = NaiveBayesClassifier(varargin) returns the handle to a new NaiveBayesClassifier or the handle to the existing singleton. An % unrecognized property name or invalid value makes property application % stop.
function varargout = NaiveBayesClassifier(varargin)
% NAIVEBAYESCLASSIFIER M-file for NaiveBayesClassifier.fig
% NAIVEBAYESCLASSIFIER, by itself, creates a new NAIVEBAYESCLASSIFIER or raises the existing % singleton*. % % H = NAIVEBAYESCLASSIFIER returns the handle to a new NAIVEBAYESCLASSIFIER or the handle to % the existing singleton*. % % NAIVEBAYESCLASSIFIER('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in NAIVEBAYESCLASSIFIER.M with the given input arguments. % % NAIVEBAYESCLASSIFIER('Property','Value',...) creates a new NAIVEBAYESCLASSIFIER or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before NaiveBayesClassifier_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to NaiveBayesClassifier_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 NaiveBayesClassifier
% Last Modified by GUIDE v2.5 16-Mar-2013 13:34:53
% Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @NaiveBayesClassifier_OpeningFcn, ... 'gui_OutputFcn', @NaiveBayesClassifier_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); clc;
% set posisi window (get_size_layar/gsl_) gsl_ = get(0,'ScreenSize');
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 NaiveBayesClassifier is made visible. function NaiveBayesClassifier_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 NaiveBayesClassifier (see VARARGIN)
% Choose default command line output for NaiveBayesClassifier handles.output = hObject;
% UIWAIT makes NaiveBayesClassifier wait for user response (see UIRESUME) % uiwait(handles.NaiveBayesClassifier);
% --- Outputs from this function are returned to the command line. function varargout = NaiveBayesClassifier_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 NaiveBayesClassifier. function trainingdata_Callback(hObject, eventdata, handles) % hObject handle to NaiveBayesClassifier (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) NaiveBayesClassifierProject=guidata(gcbo); GetCitraTraining=get(NaiveBayesClassifierProject.CitraTraining,'Userdata');
% menentukan path data training path_data_train=strrep(cd,... 'Matlab_Code_Rempah','CitraRempah\Data Training');
% data training citra jahe byk_data_train_jn=20;
% data training citra kunyit byk_data_train_jl=15;
% data training citra temukunci byk_data_train_jm=7;
%% membuat citra max filter dari citra biner %windowing_size harus bernilai ganjil >=3 windowing_size=5; max_filter_I_biner=Function_MaxFilterBiner_(I_biner,windowing_size);
%% menghitung diameter dengan satuan panjang per piksel % menentukan index yang memuat nilai 1 [idx_,idy_]=find(max_filter_I_biner==1); diameter=idy_(numel(idy_))-idy_(1)+1;
mean_varian(:,i)=[mean_fitur_rgbd_jn,mean_fitur_rgbd_jl,... mean_fitur_rgbd_jm,varian_fitur_rgbd_jn,varian_fitur_rgbd_jl,... varian_fitur_rgbd_jm]; end
% --- Executes during object creation, after setting all properties. function UkuranCitraTraining_CreateFcn(hObject, eventdata, handles) % hObject handle to UkuranCitraTraining (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% --- Executes during object creation, after setting all properties. function UkuranCitraTesting_CreateFcn(hObject, eventdata, handles) % hObject handle to UkuranCitraTesting (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% --- Executes during object creation, after setting all properties. function NamaCitraTraining_CreateFcn(hObject, eventdata, handles) % hObject handle to NamaCitraTraining (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% --- Executes during object creation, after setting all properties. function uitabledataset_CreateFcn(hObject, eventdata, handles) % hObject handle to uitabledataset (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% --- Executes when entered data in editable cell(s) in uitabledataset. function uitabledataset_CellEditCallback(hObject, eventdata, handles) % hObject handle to uitabledataset (see GCBO) % eventdata structure with the following fields (see UITABLE) % Indices: row and column indices of the cell(s) edited % PreviousData: previous data for the cell(s) edited % EditData: string(s) entered by the user % NewData: EditData or its converted form set on the Data property. Empty if Data was not changed % Error: error string when failed to convert EditData to appropriate value for Data % handles structure with handles and user data (see GUIDATA)
% --- Executes when selected cell(s) is changed in uitabledataset. function uitabledataset_CellSelectionCallback(hObject, eventdata, handles) % hObject handle to uitabledataset (see GCBO) % eventdata structure with the following fields (see UITABLE) % Indices: row and column indices of the cell(s) currently selecteds % handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in testingdata. function testingdata_Callback(hObject, eventdata, handles) % hObject handle to testingdata (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) NaiveBayesClassifierProject=guidata(gcbo);
% data training citra jahe byk_data_train_jn=20;
% data training citra kunyit byk_data_train_jl=15;
% data training citra temukunci byk_data_train_jm=7;
byk_fitur=4; byk_kelas=3;
[basefilename,path]= uigetfile({'*.*'},'Open All Image File'); filename= fullfile(path, basefilename);
if sum(strfind(lower(basefilename), '.'))==0 else
I_testing = imread (filename);
% if I = [MxNx4] if(size(I_testing,3)==4) I_testing(:,:,1)=[]; % convert to I = [MxNx3] end
% hitung mean Red, Green, Blue mean_red_testing=mean(mean(I_testing(:,:,1))); mean_green_testing=mean(mean(I_testing(:,:,2))); mean_blue_testing=mean(mean(I_testing(:,:,3)));
%% menghitung diameter dengan satuan panjang per piksel % menentukan index yang memuat nilai 1 [idx_,idy_]=find(max_filter_I_biner_testing==1); diameter_testing=idy_(numel(idy_))-idy_(1)+1;
function var_mean_red_testing_Callback(hObject, eventdata, handles) % hObject handle to var_mean_red_testing (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 var_mean_red_testing as text % str2double(get(hObject,'String')) returns contents of var_mean_red_testing as a double NaiveBayesClassifierProject = guidata(gcbo); var_mean_red_testing = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.var_mean_red_testing = var_mean_red_testing;
% --- Executes during object creation, after setting all properties. function var_mean_red_testing_CreateFcn(hObject, eventdata, handles) % hObject handle to var_mean_red_testing (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 var_mean_green_testing_Callback(hObject, eventdata, handles) % hObject handle to var_mean_green_testing (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 var_mean_green_testing as text % str2double(get(hObject,'String')) returns contents of var_mean_green_testing as a double NaiveBayesClassifierProject = guidata(gcbo); var_mean_green_testing = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.var_mean_green_testing = var_mean_green_testing;
% --- Executes during object creation, after setting all properties. function var_mean_green_testing_CreateFcn(hObject, eventdata, handles) % hObject handle to var_mean_green_testing (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 var_mean_blue_testing_Callback(hObject, eventdata, handles) % hObject handle to var_mean_blue_testing (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 var_mean_blue_testing as text % str2double(get(hObject,'String')) returns contents of var_mean_blue_testing as a double NaiveBayesClassifierProject = guidata(gcbo); var_mean_blur_testing = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.var_mean_blue_testing = var_mean_blue_testing;
% --- Executes during object creation, after setting all properties. function var_mean_blue_testing_CreateFcn(hObject, eventdata, handles) % hObject handle to var_mean_blue_testing (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 var_diameter_testing_Callback(hObject, eventdata, handles) % hObject handle to var_diameter_testing (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 var_diameter_testing as text % str2double(get(hObject,'String')) returns contents of var_diameter_testing as a double NaiveBayesClassifierProject = guidata(gcbo); var_diameter_testing = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.var_diameter_testing = var_diameter_testing;
% --- Executes during object creation, after setting all properties. function var_diameter_testing_CreateFcn(hObject, eventdata, handles) % hObject handle to var_diameter_testing (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 var_kelas_testing_Callback(hObject, eventdata, handles) % hObject handle to var_kelas_testing (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 var_kelas_testing as text % str2double(get(hObject,'String')) returns contents of var_kelas_testing as a double %NaiveBayesClassifierProject = guidata(gcbo); %var_kelas_testing = str2double(get(hObject, 'String')); %NaiveBayesClassifierProject.var_kelas_testing = var_kelas_testing;
% --- Executes during object creation, after setting all properties. function var_kelas_testing_CreateFcn(hObject, eventdata, handles) % hObject handle to var_kelas_testing (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 posterior_kelas_jn_Callback(hObject, eventdata, handles) % hObject handle to posterior_kelas_jn (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 posterior_kelas_jn as text % str2double(get(hObject,'String')) returns contents of posterior_kelas_jn as a double %NaiveBayesClassifierProject = guidata(gcbo); %var_kelas_jn = str2double(get(hObject, 'String')); %NaiveBayesClassifierProject.var_kelas_jn = var_kelas_jn;
% --- Executes during object creation, after setting all properties. %function posterior_kelas_jn_CreateFcn(hObject, eventdata, handles) % hObject handle to posterior_kelas_jn (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 posterior_kelas_jl_Callback(hObject, eventdata, handles) % hObject handle to posterior_kelas_jl (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 posterior_kelas_jl as text % str2double(get(hObject,'String')) returns contents of posterior_kelas_jl as a double NaiveBayesClassifierProject = guidata(gcbo); var_kelas_jl = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.var_kelas_jl = var_kelas_jl;
% --- Executes during object creation, after setting all properties. %function posterior_kelas_jl_CreateFcn(hObject, eventdata, handles) % hObject handle to posterior_kelas_jl (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 posterior_kelas_jm_Callback(hObject, eventdata, handles) % hObject handle to posterior_kelas_jm (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 posterior_kelas_jm as text % str2double(get(hObject,'String')) returns contents of posterior_kelas_jm as a double NaiveBayesClassifierProject = guidata(gcbo); var_kelas_jm = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.var_kelas_jm = var_kelas_jm;
% --- Executes during object creation, after setting all properties. %function posterior_kelas_jm_CreateFcn(hObject, eventdata, handles) % hObject handle to posterior_kelas_jm (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 mean_kelas_jn_Callback(hObject, eventdata, handles) % hObject handle to txt_mean_var (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 txt_mean_var as text % str2double(get(hObject,'String')) returns contents of txt_mean_var as a double NaiveBayesClassifierProject = guidata(gcbo); mean_kelas_jn = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.mean_kelas_jn = mean_kelas_jn;
% --- Executes during object creation, after setting all properties. %function mean_kelas_jn_CreateFcn(hObject, eventdata, handles) % hObject handle to txt_mean_var (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 varian_kelas_jn_Callback(hObject, eventdata, handles) % hObject handle to varian_kelas_jn (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 varian_kelas_jn as text % str2double(get(hObject,'String')) returns contents of varian_kelas_jn as a double NaiveBayesClassifierProject = guidata(gcbo); varian_kelas_jn = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.varian_kelas_jn = varian_kelas_jn;
% --- Executes during object creation, after setting all properties. function varian_kelas_jn_CreateFcn(hObject, eventdata, handles) % hObject handle to varian_kelas_jn (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 mean_kelas_jl_Callback(hObject, eventdata, handles) % hObject handle to mean_kelas_jl (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 mean_kelas_jl as text % str2double(get(hObject,'String')) returns contents of mean_kelas_jl as a double NaiveBayesClassifierProject = guidata(gcbo); mean_kelas_jl = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.mean_kelas_jl = mean_kelas_jl;
% --- Executes during object creation, after setting all properties. function mean_kelas_jl_CreateFcn(hObject, eventdata, handles) % hObject handle to mean_kelas_jl (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 varian_kelas_jl_Callback(hObject, eventdata, handles) % hObject handle to varian_kelas_jl (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 varian_kelas_jl as text % str2double(get(hObject,'String')) returns contents of varian_kelas_jl as a double NaiveBayesClassifierProject = guidata(gcbo); varian_kelas_jl = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.varian_kelas_jl = varian_kelas_jl;
% --- Executes during object creation, after setting all properties. function varian_kelas_jl_CreateFcn(hObject, eventdata, handles) % hObject handle to varian_kelas_jl (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 mean_kelas_jm_Callback(hObject, eventdata, handles) % hObject handle to mean_kelas_jm (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 mean_kelas_jm as text % str2double(get(hObject,'String')) returns contents of mean_kelas_jm as a double NaiveBayesClassifierProject = guidata(gcbo); mean_kelas_jm = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.mean_kelas_jm = mean_kelas_jm;
% --- Executes during object creation, after setting all properties. function mean_kelas_jm_CreateFcn(hObject, eventdata, handles) % hObject handle to mean_kelas_jm (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 varian_kelas_jm_Callback(hObject, eventdata, handles) % hObject handle to varian_kelas_jm (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 varian_kelas_jm as text % str2double(get(hObject,'String')) returns contents of varian_kelas_jm as a double %NaiveBayesClassifierProject = guidata(gcbo); %varian_kelas_jm = str2double(get(hObject, 'String')); %NaiveBayesClassifierProject.varian_kelas_jm = varian_kelas_jm;
% --- Executes during object creation, after setting all properties. %function varian_kelas_jm_CreateFcn(hObject, eventdata, handles) % hObject handle to varian_kelas_jm (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','red'); %end
function hasil_klasifikasi_Callback(hObject, eventdata, handles) % hObject handle to hasil_klasifikasi (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 hasil_klasifikasi as text % str2double(get(hObject,'String')) returns contents of hasil_klasifikasi as a double
% --- Executes during object creation, after setting all properties. function hasil_klasifikasi_CreateFcn(hObject, eventdata, handles) % hObject handle to hasil_klasifikasi (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