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 09-May-2013 06:54:52
% 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 window potition (get_size_screen/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;
% 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
path_data_train=strrep(cd,...
'Matlab_Code_To_Classification_Citrus','CitrusImage\Data Training');
% data training of Citrus nipis (jn)
lots_of_data_train_jn=7;
% data training of Citrus lemon (jl)
lots_of_data_train_jl=3;
% data training of Citrus orange (jm)
lots_of_data_train_jm=5;
lots_of_feature=4;
lots_of_class=3;
% initialization of matrix dataset
dataset=zeros(lots_of_data_train_jn,lots_of_feature);
for i=1:(lots_of_data_train_jn+lots_of_data_train_jl+lots_of_data_train_jm)
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);
% I_biner=im2bw(I_gray,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
% [idx_v,idy_v]=find(max_filter_I_biner==1);
% [value_max,idx_v_max]=max(idx_v);
% [value_min,idx_v_min]=mi
没有合适的资源?快使用搜索试试~ 我知道了~
基于MATLAB的柑橘果实分类图像朴素贝叶斯分类器
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共31个文件
jpg:23个
m:5个
fig:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
需积分: 50 31 下载量 187 浏览量
2018-09-08
15:28:50
上传
评论 5
收藏 2.36MB ZIP 举报
温馨提示
基于MATLAB的柑橘果实分类图像朴素贝叶斯分类器 Naive Bayes Classifier To Classification Image Of Citrus Fruits With Matlab Code
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
共 31 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/98df3c99c7054d2fb5237083072529e9_weixin_42825609.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
梅花香——苦寒来
- 粉丝: 1472
- 资源: 13
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)