【图像识别】基于计算机视觉实现路面裂缝检测识别系统matlab代码

图像识别】基于计算机视觉实现路⾯裂缝检测识别系统
matlab代码
1 简介
随着公路与铁路事业的飞速发展,各类车辆和⾥程的增加,铁路的⼀次次提速,都对路⾯产⽣了巨⼤的压⼒。不论是公路路⾯还是铁路路⾯,路⾯裂纹都能随处可见,由路⾯裂纹造成的交通事故时有发⽣。研究路⾯裂纹检测⽅法对于路⾯维护、交通安全具有极其重⼤意义。近年来,路⾯裂纹检测⼤多采⽤基于图像特性的⽅法和基于机器学习的⽅法。基于图像特性的⽅法包括边缘检测,直⽅图分析和形态学⽅法等,这类⽅法虽可以达到快速检测,但需⼿⼯设置较多阈值,对不同数据集甚⾄同⼀数据集的不同图像需要设置不同阈值,严重依赖于阈值的选取。⽽最近⼏年,⼤量学者采⽤基于有监督学习⽅式进⾏裂纹检测,如⽀持向量机、神经⽹络、结构化随机森林等,这种⽅法⼀般需要先对特征进⾏标记,然后再通过模型进⾏训练,可以⼤⼤提⾼裂纹检测的准确率,但缺点是检测效果依赖于数据集的选取,学习速度慢,因此算法难以被推⼴。实际上,裂纹检测需要同时兼顾性能和效率,为此,本⽂主要针对⽆监督的路⾯裂纹检测⽅法进⾏研究,在保证性能的前提下,提⾼裂纹检测的效率。本⽂的主要⼯作有:(1)提出了⾃适应的⽆监督裂纹检测⽅法。为了克服有监督学习适应性和推⼴能⼒差的问题,研究了基于块的⽆监督裂纹检测⽅法,具有速度快,⾃适应性好,易于推⼴到不同类型的线路等优点。但是也存在着误检和漏
检等问题。为此,针对漏检裂纹,提出了基于上下⽂信息的⾃适应块裂纹检测⽅法;针对误检裂纹,提出了基于连通区域的裂纹⼏何特性分析⽅法。同时扩充数据集,不仅将算法应⽤于公路路⾯,还在铁路路⾯数据集上进⼀步验证了算法的有效性;(2)实现了路⾯裂纹特征表⽰算法,给出了路⾯裂纹类型划分和严重程度判定依据,并在公路和铁路测试集中进⾏了验证;(3)设计和实现了路⾯裂纹检测系统,将优化后的裂纹检测算法以及裂纹类型与严重程度划分算法应⽤于该系统中,并在不同数据集上进⾏了测试。
2 部分代码
function varargout = Gui_Main(varargin)
% GUI_MAIN M-file for Gui_Main.fig
%    GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing
%    singleton*.
%
%    H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to
%    the existing singleton*.
%
%    GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
%    function named CALLBACK in GUI_MAIN.M with the given input arguments. %通脉汤
%    GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the
%    existing singleton*. Starting from the left, property value pairs are
%    applied to the GUI before Gui_Main_OpeningFcn gets called. An
%    unrecognized property name or invalid value makes property application
%    stop. All inputs are passed to Gui_Main_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 Gui_Main
% Last Modified by GUIDE v2.5 29-Mar-2011 22:28:58
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',      mfilename, ...
'gui_Singleton', gui_Singleton, ...
抽滤装置'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...
'gui_OutputFcn', @Gui_Main_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 Gui_Main is made visible.
function Gui_Main_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 Gui_Main (see VARARGIN)
% Choose default command line output for Gui_Main
handles.output = hObject;
handles.Result = [];%定义结果变量
handles.File = [];%定义⽂件路径变量
% Update handles structure
guidata(hObject, handles);%传递参数
clc; warning off all;%清除命令⾏,警告
InitAxes(handles);%初始化坐标轴
% UIWAIT makes Gui_Main wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Gui_Main_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 pushbuttonOpenFile.
function pushbuttonOpenFile_Callback(hObject, eventdata, handles)
% hObject  handle to pushbuttonOpenFile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles  structure with handles and user data (see GUIDATA) [filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bmp','All Image Files';...  '*.*','All Files' },'载⼊图像',...
fullfile(pwd, 'images'));%选择打开⽂件
if isequal(filename, 0) || isequal(pathname, 0)
return;%如果⽂件没选中,重新选择
end
end
汽油机助力自行车I = imread(fullfile(pathname, filename));%读取图像
Result = Process_Main(I);%进⾏图像处理
handles.File = fullfile(pathname, filename);%保存路径
handles.Result = Result;%保存结果
guidata(hObject, handles);%传递数据
InitAxes(handles)%初始化坐标轴
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');%图像显⽰
% --- Executes on button press in pushbuttonHisteq.
function pushbuttonHisteq_Callback(hObject, eventdata, handles)
% hObject  handle to pushbuttonHisteq (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles  structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
70secaxes(handles.axes2); imshow(handles.Result.hist); title('直⽅图均衡化图像');%图像显⽰end
% --- Executes on button press in pushbuttonMedfilt.
function pushbuttonMedfilt_Callback(hObject, eventdata, handles)
% hObject  handle to pushbuttonMedfilt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles  structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');%图像显⽰end
% --- Executes on button press in pushbuttonBw.
function pushbuttonBw_Callback(hObject, eventdata, handles)
% hObject  handle to pushbuttonBw (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles  structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');%图像显⽰
axes(handles.axes2); imshow(handles.Result.Bw); title('⼆值图像');%图像显⽰
end
% --- Executes on button press in pushbuttonEnance.
function pushbuttonEnance_Callback(hObject, eventdata, handles)
% hObject  handle to pushbuttonEnance (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles  structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');%图像显⽰
axes(handles.axes2); imshow(handles.Result.Enance); title('增强图像');%图像显⽰end
% --- Executes on button press in pushbuttonBwfilter.
function pushbuttonBwfilter_Callback(hObject, eventdata, handles)
% hObject  handle to pushbuttonBwfilter (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles  structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');%图像显⽰
axes(handles.axes2); imshow(handles.Result.Bw); title('⼆值图像');%图像显⽰
axes(handles.axes3); imshow(handles.Result.BwFilter); title('⼆值图像滤波');%图像显⽰end
% --- Executes on button press in pushbuttonCrackRec.
function pushbuttonCrackRec_Callback(hObject, eventdata, handles)
function pushbuttonCrackRec_Callback(hObject, eventdata, handles)
% hObject  handle to pushbuttonCrackRec (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles  structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');%图像显⽰
axes(handles.axes2); imshow(handles.Result.Bw); title('⼆值图像');%图像显⽰
axes(handles.axes3); imshow(handles.Result.BwFilter); title('⼆值图像滤波');%图像显⽰
axes(handles.axes4); imshow(handles.Result.CrackRec); title('裂缝识别');%图像显⽰
end
% --- Executes on button press in pushbuttonCrackJudge.
function pushbuttonCrackJudge_Callback(hObject, eventdata, handles)
% hObject  handle to pushbuttonCrackJudge (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles  structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');%图像显⽰
axes(handles.axes2); imshow(handles.Result.BwFilter); title('⼆值图像滤波');%图像显⽰
axes(handles.axes3); imshow(handles.Result.CrackRec); title('裂缝识别');%图像显⽰
断纸机axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝判断');%图像显⽰
end
% --- Executes on button press in pushbuttonCrackLoc.
function pushbuttonCrackLoc_Callback(hObject, eventdata, handles)
% hObject  handle to pushbuttonCrackLoc (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles  structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');%图像显⽰
axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');%图像显⽰
axes(handles.axes3); imshow(handles.Result.CrackJudge); title(handles.Result.str);%图像显⽰  axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝标记图像');%图像显⽰
hold on;
rectangle('Position', , 'EdgeColor', 'g', 'LineWidth', 2);%标记矩形框
hold off;
end服务器部署
% --- Executes on button press in pushbuttonProject.
function pushbuttonProject_Callback(hObject, eventdata, handles)
% hObject  handle to pushbuttonProject (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles  structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');%图像显⽰
axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');%图像显⽰
axes(handles.axes3); plot(1:size(handles.Result.Image, 1), handles.Result.Projectr);%画出⾏投影  title('⾏投影');
axes(handles.axes4); plot(1:size(handles.Result.Image, 2), handles.Result.Projectc);%画出列投影  title('列投影');
end
% --- Executes on button press in pushbuttonClose.
function pushbuttonClose_Callback(hObject, eventdata, handles)
% hObject  handle to pushbuttonClose (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles  structure with handles and user data (see GUIDATA)
choice = questdlg('确定退出?', ...
'退出', ...
'是','否','否');
switch choice
case '是'
close;
otherwise

本文发布于:2024-09-23 08:21:13,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/4/275520.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:裂纹   检测   图像
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议