function varargout = carcheck(varargin)
% CARCHECK M-file for carcheck.fig
% CARCHECK, by itself, creates a new CARCHECK or raises the existing
% singleton*.
%
% H = CARCHECK returns the handle to a new CARCHECK or the handle to
% the existing singleton*.
%
% CARCHECK('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CARCHECK.M with the given input arguments.
%
% CARCHECK('Property','Value',...) creates a new CARCHECK or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before carcheck_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to carcheck_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help carcheck
% Last Modified by GUIDE v2.5 31-May-2007 19:22:10
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @carcheck_OpeningFcn, ...
'gui_OutputFcn', @carcheck_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 carcheck is made visible.
function carcheck_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 carcheck (see VARARGIN)
% Choose default command line output for carcheck
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes carcheck wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = carcheck_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)
% 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)
%选择打开指定图像
pnum=get(handles.listbox1,'value');
switch pnum
case 1
streetcar=imread('streetcar1.jpg');
case 2
streetcar=imread('streetcar2.jpg');
case 3
streetcar=imread('streetcar3.jpg');
otherwise
end
axes(handles.axes1);%选择坐标轴1
imshow(streetcar);%显示待识别图像
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% 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)
pnum=get(handles.listbox1,'value');
switch pnum
case 1
streetcar=imread('streetcar1.jpg');
case 2
streetcar=imread('streetcar2.jpg');
case 3
streetcar=imread('streetcar3.jpg');
otherwise
end
%---------streetcar=rgb2gray(streetcar);
c=streetcar;
%imshow(c);
b=imread('street.jpg');
%---------b=rgb2gray(b);
%figure;
%imshow(b);
%c=imsubtract(a,b);
%将待识别图像与背景图像进行比较,识别出车子,并只留下车子
for i=1:600
for j=1:800
if (abs(double(b(i,j,1))-double(streetcar(i,j,1)))>2)
c(i,j,1)=0;
c(i,j,2)=0;
c(i,j,3)=0;
elseif (abs(double(b(i,j,2))-double(streetcar(i,j,2)))>2)
c(i,j,1)=0;
c(i,j,2)=0;
c(i,j,3)=0;
elseif (abs(double(b(i,j,3))-double(streetcar(i,j,3)))>2)
c(i,j,1)=0;
c(i,j,2)=0;
c(i,j,3)=0;
else
c(i,j,1)=255;
c(i,j,2)=255;
c(i,j,3)=255;
end
end
end
%图像处理,包括灰度化,二值化和腐蚀,去除噪声
%c=imcomplement(c)
%c=immultiply(a,c);
c=rgb2gray(c);
leftcar=dither(c);
%figure;
%imshow(leftcar);
leftcar=~leftcar;
%figure;
%imshow(leftcar);
leftcar=bwmorph(leftcar,'erode',1);
leftcar=~leftcar;
%leftcar=bwmorph(leftcar,'erode',5);
leftcar=~leftcar;
vsumleftcar=sum(leftcar,2);
%找到车棚,并得到宽度
for i=1:599
if (vsumleftcar(i)<80) & (vsumleftcar(i+1)>80)
top=i;
break;
end
end
for i=1:599
if (vsumleftcar(600-i)<80) & (vsumleftcar(599-i)>80)
bottom=600-i;
break;
end
end
topvalue=vsumleftcar(bottom-ceil((bottom-top)*4/5));
bottomvalue=vsumleftcar(bottom-ceil((bottom-top)*2/5));
maxvalue=max(vsumleftcar);
percent=topvalue/maxvalue;
axes(handles.axes2);
imshow(~leftcar);
h=findobj(gcf,'Tag','text2');
%根据判断依据确定车型
if (percent>=0.2) & (percent<=0.5)
set(h,'String','小型车');
elseif (percent>0.5) & (percent<=0.8)
set(h,'String','中型车');
elseif percent>0.8
set(h,'String','大型车');
end
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns listbox1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
没有合适的资源?快使用搜索试试~ 我知道了~
基于MATLAB实现的车型识别,基于两幅图像相减进行提取轮廓,然后再通过计算定长和车底的比进行判断车型+使用说明文档.zip
共8个文件
jpg:4个
md:1个
db:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 95 浏览量
2024-05-24
09:21:55
上传
评论
收藏 1.85MB ZIP 举报
温馨提示
CSDN IT狂飙上传的代码均可运行,功能ok的情况下才上传的,直接替换数据即可使用,小白也能轻松上手 【资源说明】 基于MATLAB实现的车型识别,基于两幅图像相减进行提取轮廓,然后再通过计算定长和车底的比进行判断车型+使用说明文档.zip 1、代码压缩包内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2020b;若运行有误,根据提示GPT修改;若不会,私信博主(问题描述要详细); 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可后台私信博主; 4.1 期刊或参考文献复现 4.2 Matlab程序定制 4.3 科研合作 功率谱估计: 故障诊断分析: 雷达通信:雷达LFM、MIMO、成像、定位、干扰、检测、信号分析、脉冲压缩 滤波估计:SOC估计 目标定位:WSN定位、滤波跟踪、目标定位 生物电信号:肌电信号EMG、脑电信号EEG、心电信号ECG 通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 5、欢迎下载,沟通交流,互相学习,共同进步!
资源推荐
资源详情
资源评论
收起资源包目录
基于MATLAB实现的车型识别,基于两幅图像相减进行提取轮廓,然后再通过计算定长和车底的比进行判断车型+使用说明文档.zip (8个子文件)
源程序数据库
streetcar2.jpg 468KB
streetcar1.jpg 495KB
Thumbs.db 18KB
carcheck.m 7KB
carcheck.fig 3KB
street.jpg 490KB
streetcar3.jpg 496KB
说明文档.md 13KB
共 8 条
- 1
资源评论
IT狂飙
- 粉丝: 4825
- 资源: 2654
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功