【图像识别】基于 BP神经网络路面裂缝识别系统Matlab代码

205 阅读5分钟

1 简介

随着我国经济建设的快速发展,道路交通在国民经济建设中扮演的角色越来越重要。随之而来的道路路面的养护和管理问题愈发凸显,其中道路路面的破损检测就成为相关道路养护部门的工作重点之一。另外,随着我国一批早期建设的高等级公路进入中修或大修期,为了提高道路的使用寿命,获取路面破损的数据就成为路面养护管理部门的重要课题。目前,我国的道路路面病害检测方式仍以人工检测为主,但是人工检测的方法存在检测效率低,影响正常通行以及工作强度大、耗时、不安全等问题。因此,对路面破损检测系统的研究具有一定的现实意义。本文重点阐述了基于BP神经网络实现路面裂缝检测技术的研究工作。

img

img

2 部分代码

function varargout = repair_m(varargin)
% REPAIR_M MATLAB code for repair_m.fig
%     REPAIR_M, by itself, creates a new REPAIR_M or raises the existing
%     singleton*.
%
%     H = REPAIR_M returns the handle to a new REPAIR_M or the handle to
%     the existing singleton*.
%
%     REPAIR_M('CALLBACK',hObject,eventData,handles,...) calls the local
%     function named CALLBACK in REPAIR_M.M with the given input arguments.
%
%     REPAIR_M('Property','Value',...) creates a new REPAIR_M or raises the
%     existing singleton*. Starting from the left, property value pairs are
%     applied to the GUI before repair_m_OpeningFcn gets called. An
%     unrecognized property name or invalid value makes property application
%     stop. All inputs are passed to repair_m_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 repair_m

% Last Modified by GUIDE v2.5 02-Apr-2017 19:22:32

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                  'gui_Singleton',  gui_Singleton, ...
                  'gui_OpeningFcn', @repair_m_OpeningFcn, ...
                  'gui_OutputFcn',  @repair_m_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 repair_m is made visible.
function repair_m_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 repair_m (see VARARGIN)

% Choose default command line output for repair_m
handles.output = hObject;

% Update handles structure

guidata(hObject, handles);
flag=getappdata(0,'repair_flag');

if flag==1%纵向裂缝
   set(handles.uipanel1,'Title','纵向裂缝修补建议');
   a=(textread('repair\1-6.txt','%s'));
   set(handles.show,'String',a);
   
elseif flag==2%横向裂缝
   set(handles.uipanel1,'Title','横向裂缝修补建议');
   a=(textread('repair\2-3.txt','%s'));
   set(handles.show,'String',a);
   set(handles.first,'String','骑缝法');set(handles.second,'String','灌缝法');
   set(handles.third,'Visible','off'); set(handles.fourth,'Visible','off');
   set(handles.fifth,'Visible','off');
   
elseif flag==3%不规则裂缝
   set(handles.uipanel1,'Title','不规则裂缝修补建议');
   set(handles.first,'String','一般施工步骤');set(handles.second,'Visible','off');
   set(handles.third,'Visible','off'); set(handles.fourth,'Visible','off');
   set(handles.fifth,'Visible','off');
   a=(textread('repair\3-2.txt','%s'));
   set(handles.show,'String',a);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I=getappdata(0,'I');
imshow(I);



% --- Outputs from this function are returned to the command line.
function varargout = repair_m_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 show_Callback(hObject, eventdata, handles)
% hObject   handle to show (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 show as text
%       str2double(get(hObject,'String')) returns contents of show as a double


% --- Executes during object creation, after setting all properties.
function show_CreateFcn(hObject, eventdata, handles)
% hObject   handle to show (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


% --- Executes on button press in first.
function first_Callback(hObject, eventdata, handles)
% hObject   handle to first (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of first


% --- Executes on button press in second.
function second_Callback(hObject, eventdata, handles)
% hObject   handle to second (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of second


% --- Executes on button press in third.
function third_Callback(hObject, eventdata, handles)
% hObject   handle to third (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of third


% --- Executes on button press in fourth.
function fourth_Callback(hObject, eventdata, handles)
% hObject   handle to fourth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of fourth


% --- Executes on button press in fifth.
function fifth_Callback(hObject, eventdata, handles)
% hObject   handle to fifth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of fifth


% --- Executes on button press in OK.
function OK_Callback(hObject, eventdata, handles)
% hObject   handle to OK (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
repair_flag=getappdata(0,'repair_flag');

a=get(handles.first,'Value');b=get(handles.second,'Value');
c=get(handles.third,'Value');d=get(handles.fourth,'Value');
e=get(handles.fifth,'Value');
a1=[];b1=[];c1=[];d1=[];e1=[];
if a==1
   if repair_flag==1
       a1=(textread('repair\1-1.txt','%s'));
   elseif repair_flag==2
       a1=(textread('repair\2-1.txt','%s'));
   elseif repair_flag==3
       a1=(textread('repair\3-1.txt','%s'));
   end
end
if b==1
   if repair_flag==1
       b1=(textread('repair\1-2.txt','%s'));
   elseif repair_flag==2
       b1=(textread('repair\2-2.txt','%s'));
   end
end
if c==1
   if repair_flag==1
       c1=(textread('repair\1-3.txt','%s'));
   elseif repair_flag==2
       c1=(textread('repair\2-3.txt','%s'));
   end
end
if d==1
   d1=(textread('repair\1-4.txt','%s'));
end
if e==1
   e1=(textread('repair\1-5.txt','%s'));
end
result=[a1' b1' c1' d1' e1']';
set(handles.show,'String',result);
if (a==0)&&(b==0)&&(c==0)&&(d==0)&&(e==0)
  if repair_flag==1%纵向裂缝
   a1=(textread('repair\1-6.txt','%s'));
   set(handles.show,'String',a1);
elseif repair_flag==2%横向裂缝
   a1=(textread('repair\2-3.txt','%s'));
   set(handles.show,'String',a1);
elseif repair_flag==3%不规则裂缝   
   a1=(textread('repair\3-2.txt','%s'));
   set(handles.show,'String',a1);
  end
end


% --- Executes on button press in report.
function report_Callback(hObject, eventdata, handles)
% hObject   handle to report (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
I=getframe(gcf);
figure(1),imshow(I.cdata);
imwrite(I.cdata,'result\report.jpg','quality',100);
repair_flag=getappdata(0,'repair_flag');

switch repair_flag
   case 1
copyfile('repair\纵向裂缝维修方法.docx','result\裂缝维修方法.docx');
   case 2
copyfile('repair\横向裂缝维修方法.docx','result\裂缝维修方法.docx');
   case 3
      copyfile('repair\不规则裂缝维修方法.docx','result\裂缝维修方法.docx');
end




function back_Callback(hObject, eventdata, handles)
% hObject   handle to back (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
close(repair_m);
secondPage;

3 仿真结果

4 参考文献

[1]周林. 基于图像处理的路面裂缝检测系统设计与研究. Diss. 太原理工大学.

部分理论引用网络文献,若有侵权联系博主删除。

5 MATLAB代码与数据下载地址

见博客主页