【图像识别】基于贝叶斯分类器实现柑橘识别matlab源码

  1. 贝叶斯决策论: 贝叶斯决策论考虑如何基于已知的概率和误判损失来选择最优的类别标记。

  2. 先验概率(prior probability): 是指根据以往经验和分析得到的概率。即没有考虑原因,在获得数据和依据之前就对概率进行了猜测,得到了概率。

  3. 似然函数(likelihood function): 似然用来描述已知随机变量输出结果时,未知参数的可能取值。似然函数关注的是由已知的结果和某固有属性的关系,而不是结果或者原因的概率,所以称似然是对固有属性的拟合,所以不能称之为概率。

  4. 后验概率(Posterior probability): 是在相关证据或者背景给定并纳入考虑之后的条件概率。是由因及果的概率。

  5. 先验分布: 根据一般的经验认为随机变量应该满足的分布

    后验分布: 通过当前训练数据修正的随机变量的分布,比先验分布更符合当前数据

    似然估计: 已知训练数据,给定了模型,通过让似然性极大化估计模型参数的一种方法

    后验分布往往是基于先验分布和极大似然估计计算出来的。

  6. 先验、似然、后验的区分总结:

    1)先验——根据若干年的统计(经验)或者气候(常识),某地方下雨的概率;

    2)似然——下雨(果)的时候有乌云(因/证据/观察的数据)的概率,即已经有了果,对证据发生的可能性描述;

    3)后验——根据天上有乌云(原因或者证据/观察数据),下雨(结果)的概率;

    后验 \~ 先验*似然 : 存在下雨的可能(先验),下雨之前会有乌云(似然)\~ 通过现在有乌云推断下雨概率(后验);

    或者:

    设定背景:酒至半酣,忽阴云漠漠,骤雨将至。

    情景一:“天不会下雨的,历史上这里下雨的概率是20%”----先验概率“但阴云漠漠时,下雨的概率是80%”----后验概率

    情景二:“飞飞别急着走啊,历史上酒桌上死人的概率只有5%“----先验概率”可他是曹操啊,梦里都杀人“----后验概率

  7. 最大似然估计(Maximum Likelihood Estimation): 最大似然估计是利用已知的样本的结果,在使用某个模型的基础上,反推有可能导致这样结果的模型参数值。

  8. 贝叶斯公式:

    1. Copy

      在通常情况下,“事件A在事件B发生的条件下的概率”与“事件B在事件A发生的条件下的概率”是不一样的,但两者的关系是确定的,贝叶斯公式研究的就是这种关系。

    2. 公式:

    3. 解释:

      1. P(A|B)为后验概率,即指事件B发生的条件下事件A发生的概率,因为该概率得自于B的取值而称为A的后验概率。
      2. P(A)为先验概率(边缘概率),即A的发生不用考虑B的任何方面的因素。
      3. P(B|A)为条件概率(类条件概率密度),即指在事件A发生的条件下事件B发生的概率,和1一样被称为B的后验概率。 —>称为似然
      4. P(B)为”用于归一化的证据因子(evidence)“可以当成一个已知的量,在贝叶斯分类器种P(B)的值与分类无关。
  9. 正态分布(高斯分布):

    \

  10. 多源正态分布:

    1. 个人理解:将二分类的高斯分布扩展为多个分类的问题。定义详见:https://www.cnblogs.com/bingjianing/p/9117330.html
    2. 包含了标准化、归化等过程。

左图为多源高斯分布示意 右图为多远高斯分布的归化过程#

(以上为先导概率论知识)

贝叶斯分类器

  1. 贝叶斯决策论:

    1. 前提:所有相关概率已知
    2. 关注点:误判损失
  2. 期望损失(风险): 在N种可能的标记种,λij是指将Cj误分为Ci时所产生的损失。基于后验概率:P(ci|x)得到误分为Ci时所产生的期望损失,这个损失也叫做”风险“,当我们制定一个准则h使得对于每一个样本x风险最小时(此时整个样本的总体风险R(h*)( 贝叶斯风险 )也达到最小),称h贝叶斯最优分类器

    期望损失(风险)表达式

    总体风险表达式

    使每个样本的风险最小

  3. 后验概率最大化与风险最小化:对于二分类问题,λ要么等于0要么等于1

    • 此时所以条件风险(该条件下的风险)为

    • 所以当分类错误率达到最小时,需要后验概率P最小,继而使后验概率最大化就是使风险最小化。即:

  4. 由3和贝叶斯公式得到,想获得最小风险需要获得最大的后验概率,想获得最大的后验概率需要获得最大的似然。以此引导出——>最大似然估计。

最大似然估计(Maximum Likelihood Estimation)

  1. 首先,我们的目标是:P(x|c)这一似然概率,根据频率学派的观点:

    参数虽然未知,当存在客观的固定值。

    我们假设似然概率被一个确定的θc控制,你那么我们的目标就是通过训练集来确定θ c的值,从而确定似然概率的值。

  2. 假设Dc表示训练集D上的第c类样本的集合,他们满足条件:样本服从独立分布,则参数θc对于数据集Dc的似然可以表示为:

    形如:P(A|B)=P(AB)/P(B)

    Copy

    两边取对数(对数似然):

    此时,θc最大时的最大似然估计表达式为:

    不足:该方法严重依赖假设:存在客观的固定值。

  3. MLE估计结果的有偏和无偏性:

    1. 对于均值:无偏
    2. 对于反差:有偏,1/n要改为1/(n-1)
  4. 最大似然估计在样本不足的情况下会出现一个问题:假设我抛10次硬币,有7次是正面朝上,那么我的最大似然估计的概率就是0.7,但是根据常识我们的概率应该靠近0.5才对,这里就需要考虑先验概率。——>引出最大后验概率估计。

最大后验概率(Maximum a posteriori estimation)

  1. MAP和MLE的区别:最大似然估计是求参数θ, 使似然函数P(x|θ)最大。最大后验概率估计则是想求θ使P(x|θ)P(θ)最大 。求得的θ不单单让似然函数大,θ自己出现的先验概率也得大。

  2. MAP的基本思想仍然是基于贝叶斯公式本身,MLE的目的是求出最大的似然估计值,而MAP的目的是求出最大的后验概率本身,在MLE的基础上加上了一个先验概率,他的表达式为:

  3. 主要区别在于贝叶斯学派和频率学派的区别。

朴素贝叶斯分类器

  1. 引导:

    1. 如果有d个样本,每个样本有2种状态0或1,维度为k????,那么他们的组合有2^dk-1种,但是当所有条件独立时,他们的结果有(2-1) dk-1种,使得参数大大减少。
    2. 所以,在该条件成立之上的朴素贝叶斯之所以叫做”朴素“是因为他需要满足”所有条件独立“这个条件。
  2. 朴素贝叶斯分类器所依赖的概率模型就是MAP和MLE。

  3. 应用:文本分类/垃圾邮件筛选等。

``` 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 NaiveBayesClassifierOpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to NaiveBayesClassifierOpeningFcn 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 09-May-2013 06:54:52

% Begin initialization code - DO NOT EDIT guiSingleton = 1; guiState = struct('guiName', mfilename, ... 'guiSingleton', guiSingleton, ... 'guiOpeningFcn', @NaiveBayesClassifierOpeningFcn, ... 'guiOutputFcn', @NaiveBayesClassifierOutputFcn, ... 'guiLayoutFcn', [] , ... 'guiCallback', []); if nargin && ischar(varargin{1}) guiState.gui_Callback = str2func(varargin{1}); clc;

% set window potition (get_size_screen/gsl_)
gsl_ = get(0,'ScreenSize');

end

if nargout [varargout{1:nargout}] = guimainfcn(guiState, varargin{:}); else guimainfcn(guiState, 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;

% Update handles structure guidata(hObject, handles);

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

% Set the figure icon by matlabfreecode.wordpress.com warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame'); jframe=get(handles.NaiveBayesClassifier,'javaframe'); jIcon=javax.swing.ImageIcon('citrus-icon.png'); jframe.setFigureIcon(jIcon);

% --- 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); GetImageTraining=get(NaiveBayesClassifierProject.ImageTraining,'Userdata');

% determine the training data path pathdatatrain=strrep(cd,... 'MatlabCodeToClassificationCitrus','CitrusImage\Data Training');

% data training of Citrus nipis (jn) lotsofdatatrainjn=7;

% data training of Citrus lemon (jl) lotsofdatatrainjl=3;

% data training of Citrus orange (jm) lotsofdatatrainjm=5;

lotsoffeature=4; lotsofclass=3;

% initialization of matrix dataset dataset=zeros(lotsofdatatrainjn,lotsoffeature);

for i=1:(lotsofdatatrainjn+lotsofdatatrainjl+lotsofdatatrainjm)

if(i<=lots_of_data_train_jn)
    % membaca setiap file citra jeruk nipis
    filename=strcat(path_data_train,'\','CitrusNipis',...
    num2str(i),'.jpg');
    class{i}='Nipis';
elseif(i<=(lots_of_data_train_jn+lots_of_data_train_jl))
    % membaca setiap file citra jeruk lemon
    filename=strcat(path_data_train,'\','CitrusLemon',...
        num2str(i-lots_of_data_train_jn),'.jpg');
    class{i}='Lemon';
else
    % membaca setiap file citra jeruk manis
    filename=strcat(path_data_train,'\','CitrusOrange',...
        num2str(i-(lots_of_data_train_jn+lots_of_data_train_jl)),'.jpg');
    class{i}='Orange';
end

I = imread (filename);

% merisize image size
% I = imresize(I,[256 256]);

if(size(I,3)==4)
    I(:,:,1)=[]; % convert to I = [MxNx3]
end

% count mean Red, Green, Blue
mean_red=mean(mean(I(:,:,1)));
mean_green=mean(mean(I(:,:,2)));
mean_blue=mean(mean(I(:,:,3)));

axes(handles.ImageTraining);
imshow(I);    

set(NaiveBayesClassifierProject.ImageTraining,'Userdata',I);   

SizeImageTraining=size(I);
StringSizeImageTraining=sprintf(strcat(num2str(SizeImageTraining(1)),'x',num2str(SizeImageTraining(2)),'x',num2str(SizeImageTraining(3))));    
StringSizeImageTraining = strrep(StringSizeImageTraining,'x',' x ');

set(handles.SizeImageTraining,'String',StringSizeImageTraining);

% set(handles.SizeImageTraining,'String',StringSizeImageTraining);

set(handles.NameImageTraining,'String',sprintf(strcat('Image Training (Color) ->',num2str(i))));

%% create gray-scale image
I_gray=Function_ColorToGray(I);

axes(handles.ImageGray);
imshow(I_gray);  

%%

%% create binary image

% level=graythresh(I); % Ibiner=im2bw(Igray,level);

I_biner=zeros(size(I_gray,1),size(I_gray,2));
I_biner(find(I_gray<255))=1;

axes(handles.ImageBinary);
imshow(I_biner);  

%% create max filter image from binary image
   %windowing_size must be valued an odd number >=3
   windowing_size=5;
   max_filter_I_biner=Function_MaxFilterBiner_(I_biner,windowing_size); 

   axes(handles.ImageMaxFilter);
   imshow(max_filter_I_biner);


%% count diameter with unit length horizontal each pixel 
   % determine index which contains the value 1
     [idx_,idy_]=find(max_filter_I_biner==1);
     diameter=idy_(numel(idy_))-idy_(1)+1;


%% create boundary line in diameter horizontal

    %numel((XY2Index(1,idy_(1),size(I_gray,1)):XY2Index(size(I_gray,1),idy_(numel(idy_)),size(I_gray,1)))')


    % replace pixel value
    I_red=I(:,:,1);
    I_red(:,idy_(1):(idy_(1)+10))=105;
    I_red(:,(idy_(numel(idy_))-10):idy_(numel(idy_)))=105;
    I(:,:,1)=I_red;

    I_green=I(:,:,2);
    I_green(:,idy_(1):(idy_(1)+10))=75;
    I_green(:,(idy_(numel(idy_))-10):idy_(numel(idy_)))=75;
    I(:,:,2)=I_green;

    I_blue=I(:,:,3);
    I_blue(:,idy_(1):(idy_(1)+10))=245; 
    I_blue(:,(idy_(numel(idy_))-10):idy_(numel(idy_)))=245;
    I(:,:,3)=I_blue;


    axes(handles.ImageTraining);
    imshow(I);

% %% count diameter with unit length vertical each pixel % % determine index which contains the value 1 % [idxv,idyv]=find(maxfilterIbiner==1);
% [value
max,idxvmax]=max(idxv); % [valuemin,idxvmin]=min(idxv);
% diameter
v=valuemax-valuemin+1; %
% %% create boundary line in diameter vertical
%
% % replace pixel value % Ired=I(:,:,1); % Ired(idxv(idxvmin):(idxv(idxvmin)+10),:)=105; % Ired((idxv(idxvmax)-10):idxv(idxvmax),:)=105; % I(:,:,1)=Ired; %
% Igreen=I(:,:,2); % Igreen(idxv(idxvmin):(idxv(idxvmin)+10),:)=75; % Igreen((idxv(idxvmax)-10):idxv(idxvmax),:)=75; % I(:,:,2)=Igreen; %
% Iblue=I(:,:,3); % Iblue(idxv(idxvmin):(idxv(idxvmin)+10),:)=245; % Iblue((idxv(idxvmax)-10):idxv(idxvmax),:)=245; % I(:,:,3)=Iblue;
%
% axes(handles.ImageTraining); % imshow(I);

% collect the feature value
dataset(i,:)=[mean_red mean_green mean_blue diameter];

end

class'; % % datasetclass{1}={mat2cell(dataset) class{1}'} % % datasetclass{1}

dataset;

set(handles.NameImageTraining,'String',sprintf(strcat('Image Training (Color) DONE !')));

merge_data={dataset,class'};

% lots of data multiply with lots of feature datamultiplyfeature=(lotsofdatatrainjn+lotsofdatatrainjl+lotsofdatatrainjm)*lotsoffeature;

% collect data feature R, G, B and Diameter for i=1:datamultiplyfeature datinit{i}=num2str(mergedata{1}(i),'%.3f'); end

% collect data class Citrus : Nipis, Lemon and Orange for j=1:(lotsofdatatrainjn+lotsofdatatrainjl+lotsofdatatrainjm) datinit{datamultiplyfeature+j}=char(mergedata{2}(j)); end

dat=reshape(datinit,[(lotsofdatatrainjn+lotsofdatatrainjl+lotsofdatatrainjm) (lotsof_feature+1)]);

set(NaiveBayesClassifierProject.DataTraining,'Userdata',dat);

%% insert data into dataset t=uitable('Data', dat, 'ColumnName',... {'R (Red)', 'G (Green)', 'B (Blue)', 'D (Diameter)','Class (Citrus)'},... 'Position', [20 20 430 150]);

set(NaiveBayesClassifierProject.dataset_all_feature_class,'Userdata',dataset);

% --- Executes during object creation, after setting all properties. function SizeImageTraining_CreateFcn(hObject, eventdata, handles) % hObject handle to SizeImageTraining (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 SizeImageTesting_CreateFcn(hObject, eventdata, handles) % hObject handle to SizeImageTesting (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 NameImageTraining_CreateFcn(hObject, eventdata, handles) % hObject handle to NameImageTraining (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 of Citrus nipis (jn) lotsofdatatrainjn=7;

% data training of Citrus lemon (jl) lotsofdatatrainjl=3;

% data training of Citrus orange (jm) lotsofdatatrainjm=5;

lotsoffeature=4; lotsofclass=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

%set(NaiveBayesClassifierProject.NaiveBayesClassifier,'CurrentAxes',NaiveBayesClassifierProject.ImageTraining);
%set (imshow(I));

axes(handles.ImageTesting);
imshow(I_testing);

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

set(NaiveBayesClassifierProject.var_mean_red_testing,...
    'String',num2str(mean_red_testing,'%.3f'));

set(NaiveBayesClassifierProject.var_mean_green_testing,...
    'String',num2str(mean_green_testing,'%.3f'));

set(NaiveBayesClassifierProject.var_mean_blue_testing,...
    'String',num2str(mean_blue_testing,'%.3f'));

set(NaiveBayesClassifierProject.ImageTesting,'Userdata',I_testing);   

SizeImageTesting=size(I_testing);
StringSizeImageTesting=sprintf(strcat(num2str(SizeImageTesting(1)),'x',num2str(SizeImageTesting(2)),'x',num2str(SizeImageTesting(3))));    
StringSizeImageTesting = strrep(StringSizeImageTesting,'x',' x ');

set(handles.SizeImageTesting,'String',StringSizeImageTesting);

%% create gray-scale image
I_gray_testing=Function_ColorToGray(I_testing);

axes(handles.ImageGrayTesting);
imshow(I_gray_testing);  

%%

%% create binary image _testing

% level=graythresh(Itesting); % Ibinertesting=im2bw(Igray_testing,level);

I_biner_testing=zeros(size(I_gray_testing,1),size(I_gray_testing,2));
I_biner_testing(find(I_gray_testing<255))=1;

axes(handles.ImageBinaryTesting);
imshow(I_biner_testing);  

%% create max filter image from biner_testing image
   %windowing_size must be valued an odd number >=3
   windowing_size=5;
   max_filter_I_biner_testing=Function_MaxFilterBiner_(I_biner_testing,windowing_size); 

   axes(handles.ImageMaxFilterTesting);
   imshow(max_filter_I_biner_testing);


%% count diameter with unit length each pixel
   % determine index which contains the value 1 (white color)
     [idx_,idy_]=find(max_filter_I_biner_testing==1);
     diameter_testing=idy_(numel(idy_))-idy_(1)+1;

     set(NaiveBayesClassifierProject.var_diameter_testing,...
    'String',num2str(diameter_testing,'%.2f'));

% collect feature value
dataset(1,:)=[mean_red_testing mean_green_testing mean_blue_testing diameter_testing];

if(isempty(strfind(basefilename, 'Lemon'))==0)
    class_testing{1}='Lemon';
elseif(isempty(strfind(basefilename, 'Orange'))==0)
    class_testing{1}='Orange';
elseif(isempty(strfind(basefilename, 'Nipis'))==0)
    class_testing{1}='Nipis'; 
else
    class_testing{1}='UnKnown';
end

class_testing{1}

set(NaiveBayesClassifierProject.var_class_testing,...
    'String',char(class_testing{1}));

% replace pixel value
    I_red=I_testing(:,:,1);
    I_red(:,idy_(1):(idy_(1)+10))=105;
    I_red(:,(idy_(numel(idy_))-10):idy_(numel(idy_)))=105;
    I_testing(:,:,1)=I_red;

    I_green=I_testing(:,:,2);
    I_green(:,idy_(1):(idy_(1)+10))=75;
    I_green(:,(idy_(numel(idy_))-10):idy_(numel(idy_)))=75;
    I_testing(:,:,2)=I_green;

    I_blue=I_testing(:,:,3);
    I_blue(:,idy_(1):(idy_(1)+10))=245; 
    I_blue(:,(idy_(numel(idy_))-10):idy_(numel(idy_)))=245;
    I_testing(:,:,3)=I_blue;


    axes(handles.ImageTesting);
    imshow(I_testing); 


  %% count Probability of Posterior
    %GetDataTraining=get(NaiveBayesClassifierProject.DataTraining,'User
    %data');
    %Getmean_varian=get(NaiveBayesClassifierProject.dataset_all_feature_class,'Userdata');      
    dataset=get(NaiveBayesClassifierProject.dataset_all_feature_class,'Userdata');      

    Xrgbd=[mean_red_testing;mean_green_testing;mean_blue_testing;...
        diameter_testing];

% % normalization dataset
% dataset % Xrgbd=Xrgbd' % datasetXrgbd=[dataset;Xrgbd]; % datasetXrgbdnorm=datasetXrgbd./(padarray((sum(datasetXrgbd.*datasetXrgbd).^0.5),[(size(datasetXrgbd,1)-1) 0],'replicate','post')) %
% % replace dataset and Xrgbd with normalization % dataset = dataset
Xrgbdnorm(1:(size(datasetXrgbdnorm,1)-1),:) % Xrgbd = datasetXrgbdnorm(size(datasetXrgbd_norm,1),:)

%% count & save result of mean and varian from every feature & class
        % Initialization
        Getmean_varian=zeros(2*lots_of_class,lots_of_feature);

        for i=1:lots_of_feature
            % set feature 1 for R, 2 for G, 3 for B, 4 for D
            feature_rgbd=dataset(:,i);

            % count mean_class_citrus_nipis(jn),_lemon(jl),_orange(jm)
            mean_feature_rgbd_jn=mean(feature_rgbd(1:lots_of_data_train_jn));
            mean_feature_rgbd_jl=mean(feature_rgbd(...
                (lots_of_data_train_jn+1):(lots_of_data_train_jn+lots_of_data_train_jl)));
            mean_feature_rgbd_jm=mean(feature_rgbd(...
                (lots_of_data_train_jn+lots_of_data_train_jl+1):...
                (lots_of_data_train_jn+lots_of_data_train_jl+lots_of_data_train_jm)));

            % count varian_class_citrus_nipis(jn),_lemon(jl),_orange(jm
            varian_feature_rgbd_jn=var(feature_rgbd(1:lots_of_data_train_jn));
            varian_feature_rgbd_jl=var(feature_rgbd(...
                (lots_of_data_train_jn+1):(lots_of_data_train_jn+lots_of_data_train_jl)));
            varian_feature_rgbd_jm=var(feature_rgbd(...
                (lots_of_data_train_jn+lots_of_data_train_jl+1):...
                (lots_of_data_train_jn+lots_of_data_train_jl+lots_of_data_train_jm)));

            Getmean_varian(:,i)=[mean_feature_rgbd_jn,mean_feature_rgbd_jl,...
                mean_feature_rgbd_jm,varian_feature_rgbd_jn,varian_feature_rgbd_jl,...
                varian_feature_rgbd_jm];
        end

    %% note of format mean_varian matrix :
       % size : 
         % rows = 2*lots_of_class
         % column = lots_of_feature

    % content mean_varian matrix :
     % -----------------------------------------------------------------------------------
     % |       Red        |     Green         |      Blue         |      Diameter        | 
     % -----------------------------------------------------------------------------------
     % |   mean_jn_red    |   mean_jn_green   |  mean_jn_blue     |   mean_jn_diameter   |
     % |   mean_jl_red    |   mean_jl_green   |  mean_jl_blue     |   mean_jl_diameter   |
     % |   mean_jm_red    |   mean_jm_green   |  mean_jm_blue     |   mean_jm_diameter   |
     % |  varian_jn_red   |  varian_jn_green  |  varian_jn_blue   |  varian_jn_diameter  |
     % |  varian_jl_red   |  varian_jl_green  |  varian_jl_blue   |  varian_jl_diameter  |
     % |  varian_jm_red   |  varian_jm_green  |  varian_jm_blue   |  varian_jm_diameter  |
     % -----------------------------------------------------------------------------------
    %%



    % count Probability of Prior
    P_Prior_jn=lots_of_data_train_jn/(lots_of_data_train_jn+...
    lots_of_data_train_jl+lots_of_data_train_jm);
    P_Prior_jl=lots_of_data_train_jl/(lots_of_data_train_jn+...
        lots_of_data_train_jl+lots_of_data_train_jm);
    P_Prior_jm=lots_of_data_train_jm/(lots_of_data_train_jn+...
        lots_of_data_train_jl+lots_of_data_train_jm);

    % initialization Probability value of Posterior
    P_Posterior_jn=1*P_Prior_jn
    P_Posterior_jl=1*P_Prior_jl
    P_Posterior_jm=1*P_Prior_jm

%% note format Getmeanvarian matrix : % size : % rows = 2*lotsofclass % column = lotsof_feature

% content of Getmeanvarian matrix : % ----------------------------------------------------------------------------------- % | Red | Green | Blue | Diameter | % ----------------------------------------------------------------------------------- % | meanjnred | meanjngreen | meanjnblue | meanjndiameter | % | meanjlred | meanjlgreen | meanjlblue | meanjldiameter | % | meanjmred | meanjmgreen | meanjmblue | meanjmdiameter | % | varianjnred | varianjngreen | varianjnblue | varianjndiameter | % | varianjlred | varianjlgreen | varianjlblue | varianjldiameter | % | varianjmred | varianjmgreen | varianjmblue | varianjm_diameter | % ----------------------------------------------------------------------------------- %%

% count Probability of Likelihood from RBGD feature
    for i=1:lots_of_feature      
        mean_varian_RGBD=Getmean_varian(:,i);
        P_Likelihood_x_RGB_to_jn=...
            (1/sqrt(2*(22/7)*mean_varian_RGBD(4)))...
            *exp(-1*(((Xrgbd(i)-mean_varian_RGBD(1))^2)/(2*mean_varian_RGBD(4))))
        P_Posterior_jn=P_Posterior_jn*P_Likelihood_x_RGB_to_jn

        mean_varian_RGBD(5)
        mean_varian_RGBD(2)
        Xrgbd(i)
        P_Likelihood_x_RGB_to_jl=...
            (1/sqrt(2*(22/7)*mean_varian_RGBD(5)))...
            *exp(-1*(((Xrgbd(i)-mean_varian_RGBD(2))^2)/(2*mean_varian_RGBD(5))))
        P_Posterior_jl=P_Posterior_jl*P_Likelihood_x_RGB_to_jl

        P_Likelihood_x_RGB_to_jm=...
            (1/sqrt(2*(22/7)*mean_varian_RGBD(6)))...
            *exp(-1*(((Xrgbd(i)-mean_varian_RGBD(3))^2)/(2*mean_varian_RGBD(6))))
        P_Posterior_jm=P_Posterior_jm*P_Likelihood_x_RGB_to_jm
    end

    set(NaiveBayesClassifierProject.posterior_class_jn,...
    'String',strcat(num2str(P_Posterior_jn,'%.20f'),{'  ('},num2str(P_Posterior_jn),')'));
    set(NaiveBayesClassifierProject.posterior_class_jl,...
    'String',strcat(num2str(P_Posterior_jl,'%.20f'),{'  ('},num2str(P_Posterior_jl),')'));
    set(NaiveBayesClassifierProject.posterior_class_jm,...
    'String',strcat(num2str(P_Posterior_jm,'%.20f'),{'  ('},num2str(P_Posterior_jm),')'));

    All_P_Posterior=[P_Posterior_jn;P_Posterior_jl;P_Posterior_jm];

    [vmax_Posterior,idxmax_Posterior]=max(All_P_Posterior);

    Decision_Of_Classification='';
    if(idxmax_Posterior==1)
        Decision_Of_Classification='Nipis';
    elseif(idxmax_Posterior==2)
        Decision_Of_Classification='Lemon';
    else
        Decision_Of_Classification='Orange';
    end

    set(NaiveBayesClassifierProject.classification_result,...
    'String',Decision_Of_Classification);

end

function varmeanredtestingCallback(hObject, eventdata, handles) % hObject handle to varmeanred_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 varmeanredtesting as text % str2double(get(hObject,'String')) returns contents of varmeanredtesting as a double NaiveBayesClassifierProject = guidata(gcbo); varmeanredtesting = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.varmeanredtesting = varmeanred_testing;

% --- Executes during object creation, after setting all properties. function varmeanredtestingCreateFcn(hObject, eventdata, handles) % hObject handle to varmeanred_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 varmeangreentestingCallback(hObject, eventdata, handles) % hObject handle to varmeangreen_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 varmeangreentesting as text % str2double(get(hObject,'String')) returns contents of varmeangreentesting as a double NaiveBayesClassifierProject = guidata(gcbo); varmeangreentesting = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.varmeangreentesting = varmeangreen_testing;

% --- Executes during object creation, after setting all properties. function varmeangreentestingCreateFcn(hObject, eventdata, handles) % hObject handle to varmeangreen_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 varmeanbluetestingCallback(hObject, eventdata, handles) % hObject handle to varmeanblue_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 varmeanbluetesting as text % str2double(get(hObject,'String')) returns contents of varmeanbluetesting as a double NaiveBayesClassifierProject = guidata(gcbo); varmeanblurtesting = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.varmeanbluetesting = varmeanblue_testing;

% --- Executes during object creation, after setting all properties. function varmeanbluetestingCreateFcn(hObject, eventdata, handles) % hObject handle to varmeanblue_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 vardiametertestingCallback(hObject, eventdata, handles) % hObject handle to vardiameter_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 vardiametertesting as text % str2double(get(hObject,'String')) returns contents of vardiametertesting as a double NaiveBayesClassifierProject = guidata(gcbo); vardiametertesting = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.vardiametertesting = vardiametertesting;

% --- Executes during object creation, after setting all properties. function vardiametertestingCreateFcn(hObject, eventdata, handles) % hObject handle to vardiameter_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 varclasstestingCallback(hObject, eventdata, handles) % hObject handle to varclass_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 varclasstesting as text % str2double(get(hObject,'String')) returns contents of varclasstesting as a double NaiveBayesClassifierProject = guidata(gcbo); varclasstesting = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.varclasstesting = varclasstesting;

% --- Executes during object creation, after setting all properties. function varclasstestingCreateFcn(hObject, eventdata, handles) % hObject handle to varclass_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 posteriorclassjnCallback(hObject, eventdata, handles) % hObject handle to posteriorclass_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 posteriorclassjn as text % str2double(get(hObject,'String')) returns contents of posteriorclassjn as a double NaiveBayesClassifierProject = guidata(gcbo); varclassjn = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.varclassjn = varclassjn;

% --- Executes during object creation, after setting all properties. function posteriorclassjnCreateFcn(hObject, eventdata, handles) % hObject handle to posteriorclass_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 posteriorclassjlCallback(hObject, eventdata, handles) % hObject handle to posteriorclass_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 posteriorclassjl as text % str2double(get(hObject,'String')) returns contents of posteriorclassjl as a double NaiveBayesClassifierProject = guidata(gcbo); varclassjl = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.varclassjl = varclassjl;

% --- Executes during object creation, after setting all properties. function posteriorclassjlCreateFcn(hObject, eventdata, handles) % hObject handle to posteriorclass_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 posteriorclassjmCallback(hObject, eventdata, handles) % hObject handle to posteriorclass_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 posteriorclassjm as text % str2double(get(hObject,'String')) returns contents of posteriorclassjm as a double NaiveBayesClassifierProject = guidata(gcbo); varclassjm = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.varclassjm = varclassjm;

% --- Executes during object creation, after setting all properties. function posteriorclassjmCreateFcn(hObject, eventdata, handles) % hObject handle to posteriorclass_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 meanclassjnCallback(hObject, eventdata, handles) % hObject handle to txtmean_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 txtmeanvar as text % str2double(get(hObject,'String')) returns contents of txtmeanvar as a double NaiveBayesClassifierProject = guidata(gcbo); meanclassjn = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.meanclassjn = meanclassjn;

% --- Executes during object creation, after setting all properties. function meanclassjnCreateFcn(hObject, eventdata, handles) % hObject handle to txtmean_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 varianclassjnCallback(hObject, eventdata, handles) % hObject handle to varianclass_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 varianclassjn as text % str2double(get(hObject,'String')) returns contents of varianclassjn as a double NaiveBayesClassifierProject = guidata(gcbo); varianclassjn = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.varianclassjn = varianclassjn;

% --- Executes during object creation, after setting all properties. function varianclassjnCreateFcn(hObject, eventdata, handles) % hObject handle to varianclass_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 meanclassjlCallback(hObject, eventdata, handles) % hObject handle to meanclass_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 meanclassjl as text % str2double(get(hObject,'String')) returns contents of meanclassjl as a double NaiveBayesClassifierProject = guidata(gcbo); meanclassjl = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.meanclassjl = meanclassjl;

% --- Executes during object creation, after setting all properties. function meanclassjlCreateFcn(hObject, eventdata, handles) % hObject handle to meanclass_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 varianclassjlCallback(hObject, eventdata, handles) % hObject handle to varianclass_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 varianclassjl as text % str2double(get(hObject,'String')) returns contents of varianclassjl as a double NaiveBayesClassifierProject = guidata(gcbo); varianclassjl = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.varianclassjl = varianclassjl;

% --- Executes during object creation, after setting all properties. function varianclassjlCreateFcn(hObject, eventdata, handles) % hObject handle to varianclass_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 meanclassjmCallback(hObject, eventdata, handles) % hObject handle to meanclass_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 meanclassjm as text % str2double(get(hObject,'String')) returns contents of meanclassjm as a double NaiveBayesClassifierProject = guidata(gcbo); meanclassjm = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.meanclassjm = meanclassjm;

% --- Executes during object creation, after setting all properties. function meanclassjmCreateFcn(hObject, eventdata, handles) % hObject handle to meanclass_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 varianclassjmCallback(hObject, eventdata, handles) % hObject handle to varianclass_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 varianclassjm as text % str2double(get(hObject,'String')) returns contents of varianclassjm as a double NaiveBayesClassifierProject = guidata(gcbo); varianclassjm = str2double(get(hObject, 'String')); NaiveBayesClassifierProject.varianclassjm = varianclassjm;

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

% --- Executes during object creation, after setting all properties. function classificationresultCreateFcn(hObject, eventdata, handles) % hObject handle to classification_result (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 ImageTraining_CreateFcn(hObject, eventdata, handles) % hObject handle to ImageTraining (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate ImageTraining

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

% Hint: place code in OpeningFcn to populate ImageTraining

% --- Executes during object creation, after setting all properties. function SizeImageTraining_CreateFcn(hObject, eventdata, handles) % hObject handle to SizeImageTraining (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 NameImageTraining_CreateFcn(hObject, eventdata, handles) % hObject handle to NameImageTraining (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

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

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

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

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

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

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法 神经网络预测 雷达通信  无线传感器 电力系统

信号处理 图像处理 路径规划 元胞自动机 无人机 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Matlab科研辅导帮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值