function varargout = shuyeshibie(varargin)
% SHUYESHIBIE MATLAB code for shuyeshibie.fig
% SHUYESHIBIE, by itself, creates a new SHUYESHIBIE or raises the existing
% singleton*.
%
% H = SHUYESHIBIE returns the handle to a new SHUYESHIBIE or the handle to
% the existing singleton*.
%
% SHUYESHIBIE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SHUYESHIBIE.M with the given input arguments.
%
% SHUYESHIBIE('Property','Value',...) creates a new SHUYESHIBIE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before shuyeshibie_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to shuyeshibie_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 shuyeshibie
% Last Modified by GUIDE v2.5 15-Feb-2019 11:13:36
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @shuyeshibie_OpeningFcn, ...
'gui_OutputFcn', @shuyeshibie_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 shuyeshibie is made visible.
function shuyeshibie_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 shuyeshibie (see VARARGIN)
% Choose default command line output for shuyeshibie
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes shuyeshibie wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = shuyeshibie_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)
clc;
ax1=(handles.axes1);cla(ax1,'reset')
ax2=(handles.axes2);cla(ax2,'reset')
ax3=(handles.axes3);cla(ax3,'reset')
ax4=(handles.axes4);cla(ax4,'reset')
ax5=(handles.axes5);cla(ax5,'reset')
ax6=(handles.edit1);cla(ax6,'reset')
[name,path]=uigetfile({'*.png';'*.bmp';'tif'},'载入图像');
x=imread([path,name]); %获取位置
axes(handles.axes1);%axes表示获取位置,这里选取的位置为axes1;
imshow(x); %显示图像
title('测试原图')
f=x;
save('f'); %保存变量
guidata(hObject,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)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
load('f')
%f=imread('3.png');%读入测试图
%f=rgb2gray(f);
A=double(f);%把灰度值转化为双精度
g=mat2gray(A);%灰度值归一化0到1之间
k=im2bw(g,0.4);%二值化,阈值0.4
axes(handles.axes2)
imshow(k)
title('二值化图')
k=1-k;%反转
se=strel('disk',6);
fc=imclose(k,se);%闭运算
fc=imfill(fc,'hole');%填洞
axes(handles.axes3),imshow(fc);
title('填洞')
se=strel('disk',8);
fco=imopen(fc,se);%开运算
axes(handles.axes4),imshow(fco);
title('开运算');
BW=fco;
trainset=train(); %%%%请联系QQ609553134
msgbox('待完善,Q609553134')
trainset2=train2();%训练样本
axes(handles.axes5)
imshow(f,[]);
title('结果图')
[L,num] = bwlabel(BW); %标记
for t=1:num
[r c]=find(L==t);
r1=min(r);
c1=min(c);
r2=max(r);
c2=max(c);
IM{t}=BW(r1:r2,c1:c2);
% figure;imshow(BW(r1:r2,c1:c2))
phi=invmoments(IM{t}); %提取不变矩特征
Pset{t}=phi;
d(t)=norm(abs(log(Pset{t}(1:7)))-abs(log(trainset(1:7)))); %与训练样本进行匹配
d2(t)=norm(abs(log(Pset{t}(1:7)))-abs(log(trainset2(1:7))));
% [M N]=min(d);
% result{t}=b(N); %保存结果
if d(t)<10
text((c2+c1)/2,(r2+r1)/2,'枫叶','BackgroundColor','red'); %显示结果
set(handles.edit1,'string','枫叶');
msgbox(strcat('检测结果为:','枫叶!'), '对话框标题');
[s,fs]=wavread('fengye.wav')
wavplay(s,8000)
end
if d2(t)<10
text((c2+c1)/2,(r2+r1)/2,'灵叶','BackgroundColor','green'); %显示结果
set(handles.edit1,'string','灵叶');
msgbox(strcat('检测结果为:','灵叶!'), '对话框标题');
[s,fs]=wavread('lingye.wav')
wavplay(s,8000)
end
if Pset{t}(3:7)<0.00001
text((c2+c1)/2,(r2+r1)/2,'百合叶','BackgroundColor','yellow'); %显示结果
set(handles.edit1,'string','百合叶');
msgbox(strcat('检测结果为:','百合叶!'), '对话框标题');
[s,fs]=wavread('baiheye.wav')
wavplay(s,8000)
end
end
% 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)
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
msgbox(strcat('本设计为基于几何不变矩的树叶识别系统'), '说明');
% 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)
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
clc;
close all;
% 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)
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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
该资源是一个基于MATLAB开发的树叶识别系统,集成了图形用户界面(GUI)和语音播报功能。它利用Hu不变矩算法进行图像特征提取,实现对不同种类树叶的自动识别。该系统不仅提供了丰富的图像处理与模式识别技术应用实例,还通过友好的GUI界面和语音反馈,极大地提升了用户体验。项目源码经过充分测试,确保稳定运行,适合作为学习MATLAB编程、图像处理及GUI设计的优质资源。
资源推荐
资源详情
资源评论
收起资源包目录
基于MATLAB的不变矩树叶识别系统[GUI界面,语音播报]项目源码+树叶样本.zip (17个子文件)
code1128
f.mat 77KB
train_1.tif 446KB
shuyeshibie.m 7KB
3.png 11KB
train_2.tif 96KB
train_3.tif 1.1MB
lingye.wav 78KB
fengye.wav 78KB
1.png 20KB
6.png 43KB
shuyeshibie.fig 13KB
baiheye.wav 78KB
5.png 61KB
4.png 26KB
invmoments.m 3KB
2.png 11KB
¿
¿j¿l¿l¿`¿n¿T¿a.png 130KB
共 17 条
- 1
资源评论
葡萄籽儿
- 粉丝: 720
- 资源: 2493
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 【保密协议】-03-员工保密协议【适合高层管理者】.docx
- 【保密协议】-14-员工保密与竞业禁止协议【含承诺书】.docx
- 【保密协议】-17-保密协议【适合合作机构之间】.docx
- 【保密协议】-16-软件开发保密协议.docx
- 【保密协议】-15-项目保密协议.docx
- 【保密协议】-10-公司技术保密协议【适用于技术岗位】.doc
- 【保密协议】-18-技术及业务合作保密协议.docx
- 【保密协议】-11-员工保密协议【适合研发、设计或技术人员】.docx
- 1_码同学软件测试面试宝典-高级.pdf
- 01-员工保密协议.doc
- 02-员工保密协议.docx
- 03-员工保密协议.docx
- 12 -员工商业保密协议.docx
- 10 -外派员工保密协议范本.doc.docx
- 04-员工保密协议.doc
- 05-员工保密协议.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功