function varargout = the4th(varargin)
%========filename:the4th.m============%
%=========动物图像的模式识别=======%
%==========include files:the4th.m===================%
%========================exam.m===================%
%========================exam1.m==================%
%========================do.m=====================%
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @the4th_OpeningFcn, ...
'gui_OutputFcn', @the4th_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 the4th is made visible.
function the4th_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 the4th (see VARARGIN)
% Choose default command line output for the4th
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes the4th wait for user response (see UIRESUME)
% uiwait(handles.figure1);
clc
clear
% --- Outputs from this function are returned to the command line.
function varargout = the4th_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;
% --------------------------------------------------------------------
function menu_1_Callback(hObject, eventdata, handles)
% hObject handle to menu_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fea testimg mask;
% --------------------------------------------------------------------
function menu_2_Callback(hObject, eventdata, handles)
% hObject handle to menu_2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function menu_3_Callback(hObject, eventdata, handles)
% hObject handle to menu_3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function menu_4_Callback(hObject, eventdata, handles)
% hObject handle to menu_4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function menu_5_Callback(hObject, eventdata, handles)
% hObject handle to menu_5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function menu_6_Callback(hObject, eventdata, handles)
% hObject handle to menu_6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes during object creation, after setting all properties.
% --------------------------------------------------------------------
function menu_61_Callback(hObject, eventdata, handles)
% hObject handle to menu_61 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clear
% 读入样本图像
img1 = imread('大象.jpg');
bwpic = RGB2bw(img1);
samfea(1,:) = get_features(img1, bwpic);
img2 = imread('狗.jpg');
bwpic = RGB2bw(img2);
samfea(2,:) = get_features(img2, bwpic);
img3 = imread('马.jpg');
bwpic = RGB2bw(img3);
samfea(3,:) = get_features(img3, bwpic);
img4 = imread('猫.jpg');
bwpic = RGB2bw(img4);
samfea(4,:) = get_features(img4, bwpic);
%读入测试图像
testimg = imread('test1.jpg');
% 测试图像二值化
bwpic = RGB2bw(testimg);
%figure, imshow(testimg)
% 分离各个目标
L = bwlabel(bwpic,4);
mask = zeros(size(bwpic,1),size(bwpic,2), 4);
for i=1:4
Tmask = zeros(size(bwpic,1),size(bwpic,2));
[r, c] = find(L==i);
for j=1:length(r)
Tmask(r(j), c(j)) = 1;
end
%figure, image(Tmask)
mask(:,:,i) = Tmask;
end
% 特征提取
for i=1:4
testfea(i,:) = get_features(testimg, mask(:,:,i));
end
name = {'大象', '狗', '马', '猫'};
% 识别
index = recognition(testfea, samfea);
% 显示结果
%figure
imshow(testimg)
hold on
for i=1:4
R = regionprops(mask(:,:,i),'boundingbox' );
Rect = R.BoundingBox;
if i==3
text(Rect(1)+Rect(3),Rect(2), name(index(i)-1))
else
text(Rect(1)+Rect(3),Rect(2), name(index(i)))
end
end
% --------------------------------------------------------------------
function menu_62_Callback(hObject, eventdata, handles)
% hObject handle to menu_62 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close
% --------------------------------------------------------------------
function menu_51_Callback(hObject, eventdata, handles)
% hObject handle to menu_51 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global samfea
img1 = imread('大象.jpg');
bwimg = RGB2bw(img1);
samfea(1,:) = get_features(img1, bwimg);
img2 = imread('狗.jpg');
bwimg = RGB2bw(img2);
samfea(2,:) = get_features(img2, bwimg);
img3 = imread('马.jpg');
bwimg = RGB2bw(img3);
samfea(3,:) = get_features(img3, bwimg);
img4 = imread('猫.jpg');
bwimg = RGB2bw(img4);
samfea(4,:) = get_features(img4, bwimg);
samfea
% --------------------------------------------------------------------
function menu_52_Callback(hObject, eventdata, handles)
% hObject handle to menu_52 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global testimg mask testfea
for i=1:4
testfea(i,:) = get_features(testimg, mask(:,:,i));
end
testfea
% --------------------------------------------------------------------
function menu_41_Callback(hObject, eventdata, handles)
% hObject handle to menu_41 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I2
figure
subplot(1,2,1)
imshow(I2)
subplot(1,2,2)
imhist(I2)
% --------------------------------------------------------------------
function menu_42_Callback(hObject, eventdata, handles)
% hObject handle to menu_42 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I2
K=histeq(I2);
figure
subplot(1,2,1)
imshow(K)
subplot(1,2,2)
imhist(K)
% --------------------------------------------------------------------
function menu_31_Callback(hObject, eventdata, handles)
% hObject handle to menu_31 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
bwpic = imread('大象.jpg');
%handles.testimg = testimg;
bwpic = RGB2bw(bwpic);
imshow(bwpic);
% --------------------------------------------------------------------
func
没有合适的资源?快使用搜索试试~ 我知道了~
动物识别基于matlab GUI特征提取动物图像分类识别【含Matlab源码 2540期】.zip
共11个文件
jpg:6个
m:4个
fig:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 2 下载量 17 浏览量
2023-04-25
17:04:20
上传
评论 3
收藏 374KB ZIP 举报
温馨提示
代码下载:完整代码,可直接运行 ;运行版本:2014a或2019b;若运行有问题,可私信博主; 博主优势:精通Matlab各领域,且各项目代码较全,可供指导交流。 座右铭:行百里者,半于九十。 1 第一步:海神之光博主主页https://blog.csdn.net/TIQCmatlab?type=blog 2 第二步:搜索相关内容,回车或者点击;然后就出现您需要的文章: 3 Matlab软件下载 与善其事,必先利其器。学习matlab,必须要先下载好matlab软件。 下载链接:Matlab R2020a版安装下载详细操作步骤【Matlab 140期】 4 Matlab基础教程 我们在学习matlab时,如果前面所学知识有部分遗忘,可以及时翻阅课本加深记忆。因此,虽然现在互联网已经非常的发达,但是有一本纸质版的图书也是非常有必要的。 5 学会使用互联网查找知识 现在的互联网非常强大,只靠一本纸质书籍是远远不够的。我们还要学会在网上找一些matlab相关的基础知识进行学习。 6及时进行练习,以免眼高手低 matlab软件要及时的使用起来。我们在学习基础知识时,肯定会遇到很多的小的例子。即使我们对这些例子都能理解也要多使用matlab软件进行验证,看看我们敲出来代码是否也能正常运行。 7 遇到问题及时向博主求助 作为初学者,遇见不会的问题是非常正常的事情。海神之光擅长领域擅长路径规划、优化求解、神经网络预测、图像处理、语音处理等多种领域Matlab仿真,具体代码仿真 私信博主。
资源推荐
资源详情
资源评论
收起资源包目录
【动物识别】基于matlab GUI特征提取动物图像分类识别【含Matlab源码 2540期】.zip (11个子文件)
【动物识别】基于matlab GUI特征提取动物图像分类识别【含Matlab源码 2540期】
test1.jpg 47KB
马.jpg 43KB
the4th.m 12KB
猫.jpg 6KB
RGB2bw.m 299B
狗.jpg 212KB
the4th.fig 27KB
运行结果.jpg 48KB
recognition.m 413B
大象.jpg 19KB
get_features.m 564B
共 11 条
- 1
资源评论
- 扑扑零六2024-03-23资源值得借鉴的内容很多,那就浅学一下吧,值得下载!
- 2301_763137882024-03-16资源有一定的参考价值,与资源描述一致,很实用,能够借鉴的部分挺多的,值得下载。
海神之光
- 粉丝: 3w+
- 资源: 2091
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功