【裂缝识别】基于matlab GUI BP神经网络路面裂缝识别系统【含Matlab源码 1063期】
一、简介
高速公路路面病害养护和管理的重要部分就是路面裂缝的检测。近年来,路面裂缝自动检测技术已得到了广泛应用,而由于路面裂缝图像的复杂性,检测算法直接影响着检测结果的精确度。因此,本文将重点放在路面裂缝病害的检测上,为了提高检测的精度,分别从裂缝图像的去噪、图像的增强、图像的分割以及检测后路面裂缝图像的特征提取方面进行深入研究。 在路面裂缝图像中,由于裂缝信息与背景对比度偏低,难以将裂缝直接检测到。对于图像的预处理,首先对图像进行灰度校正,再对校正之后的图像滤波,本文提出了一种改进的中值滤波方法,对图像进行去噪,之后用基于模糊理论的图像增强原理对图像做进一步增强,有效提高了路面裂缝图像的对比度。 针对路面裂缝图像分割,本文分别用了阈值分割和基于形态学多尺度的思想,对于形状规则的裂缝采用的是阈值分割,对于裂缝形状不规则的图像,本文设计了一种多结构元素的抗噪型边缘检测算子,且依据不同形状的结构元素对裂缝边缘填充的几率不同,确定了自适应权重,使得算子检测到了各种类型的裂缝边缘,有效地提高了检测的精度。 对于经过分割后的路面裂缝图像中存在噪声和裂缝断裂的问题,本文对于断裂较窄的图像用形态学中的闭运算和开运算去处理,对于断裂较宽的图像,提出了一种基于生长的断裂裂缝块的连接方法。提高了连接的效率和准确率,使整个检测结果清晰完整。最终,从识别结果图中提取裂缝信息。根据得到的识别结果图,设定一系列判定条件,提取出裂缝的连通域,对裂缝的类型进行判断,最后计算出网状裂缝的面积及线性裂缝的长宽信息。
二、源代码
function varargout = firstPage(varargin)
% FIRSTPAGE MATLAB code for firstPage.fig
% FIRSTPAGE, by itself, creates a new FIRSTPAGE or raises the existing
% singleton*.
%
% H = FIRSTPAGE returns the handle to a new FIRSTPAGE or the handle to
% the existing singleton*.
%
% FIRSTPAGE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in FIRSTPAGE.M with the given input arguments.
%
% FIRSTPAGE('Property','Value',...) creates a new FIRSTPAGE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before firstPage_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to firstPage_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 firstPage
% Last Modified by GUIDE v2.5 12-Apr-2021 10:23:22
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @firstPage_OpeningFcn, ...
'gui_OutputFcn', @firstPage_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 firstPage is made visible.
function firstPage_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 firstPage (see VARARGIN)
% Choose default command line output for firstPage
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% set(gcf,'menu','figure');
set(gcf,'numbertitle','off','name','基于BP神经网络的路面裂缝检测与处理建议软件');
% UIWAIT makes firstPage wait for user response (see UIRESUME)
% uiwait(handles.figure1);
bg_P=axes('units','normalized','position',[0 0 1 1]);
uistack(bg_P,'bottom');
II=imread('background\8.jpg');
image(II);
hold on
% w=text(177,68,'基于BP网络的路面裂缝处理系统','fontsize',25,'color',[1.0 1.0 1.0]);
w=text(65,98,'基于BP神经网络的路面裂缝检测与处理建议软件','fontsize',25,'color',[0.0 0.0 0.0]);
w1=text(52,150,'Pavement Crack Detection And Processing Suggest Software ','fontsize',20,'color',[0.0 0.0 0.0]);
w2=text(250,200,'Based On BP Neural Network ','fontsize',20,'color',[0.0 0.0 0.0]);
w3=text(385,400,'大学','fontsize',15,'color',[0.0 0.0 0.0]);
w4=text(340,420,'** University ','fontsize',13,'color',[0.0 0.0 0.0]);
w5=text(380,470,'1st,April,2021','fontsize',11,'color',[0.0 0.0 0.0]);
colormap gray;
set(bg_P,'handlevisibility','off','visible','off');
% set(handles.pushbutton1,'visible','off');
% --- Outputs from this function are returned to the command line.
function varargout = firstPage_OutputFcn(~, 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 model_Callback(hObject, eventdata, handles)
% hObject handle to model (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Help_Callback(hObject, eventdata, handles)
% hObject handle to Help (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Exit_Callback(hObject, eventdata, handles)
% hObject handle to Exit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close gcf;
% --------------------------------------------------------------------
function fast_Callback(hObject, eventdata, handles) %%%%%%%%%%%%%%%%%%%%%%%%%%%模式选择---》快速模式
% --------------------------------------------------------------------
function Retrain_Callback(hObject, eventdata, handles) %%%%%%%%%%%%%%%%%%%%%模式选择---》重新训练
ANNcheck;
load data\acy_check;
load data\acy_reg;
t=['准确率为' acy_check];
q=questdlg(t,'是否重新训练','是','否','否');
if q=='是'
Retrain_Callback();
else
setappdata(0,'acy_check',acy_check);
setappdata(0,'acy_reg',acy_reg);
close(gcf);
secondPage;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%作为《重新训练or快速模式》标志
Hit=0;
setappdata(0,'Hit',Hit); %%%%%%%重新训练模式,则 Hit=0
% --------------------------------------------------------------------
function ask_help_Callback(hObject, eventdata, handles)
% hObject handle to ask_help (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open ('Help.docx');
% --------------------------------------------------------------------
function Wenjian_Callback(hObject, eventdata, handles)
% hObject handle to Wenjian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function file_in_Callback(hObject, eventdata, handles)
% hObject handle to file_in (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open txt\程序文件介绍.txt
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Exit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function DingYi_Callback(hObject, eventdata, handles)
% hObject handle to DingYi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open txt\裂缝方向定义.txt
% --------------------------------------------------------------------
function Net_Callback(hObject, eventdata, handles)
% hObject handle to Net (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function CheckNet_Callback(hObject, eventdata, handles) %%%%%%%%%%%%%%%%%关于网路-》检测网络
% hObject handle to CheckNet (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open txt\检测网络.txt;
% --------------------------------------------------------------------
function RecNet_Callback(hObject, eventdata, handles) %%%%%%%%%%%%%%%%%关于网路-》识别网络
% hObject handle to RecNet (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open txt\识别网络.txt;
% --------------------------------------------------------------------
function retrain_c_Callback(hObject, eventdata, handles)
% hObject handle to retrain_c (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function retrain_r_Callback(hObject, eventdata, handles)
% hObject handle to retrain_r (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Reset_Callback(hObject, eventdata, handles) %%%%%%%%%%%%%%参数重置
% hObject handle to Reset (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
tex=['默认参数是经过多次试验得到的最优组合,您真的需要重新设置吗?'];
q=questdlg(tex,'温馨提示','是','否','否');
if q=='是'
t{1}='最大迭代次数';t{2}='第一隐层隐元数目';t{3}='第二隐层隐元数目';
t{4}='第一隐层激活函数';t{5}='第二隐层激活函数';t{6}='训练函数';
title='设置';
default_t={'5000','432','54','tansig','purelin','trainscg'};
param=inputdlg(t,title,1,default_t,'on');
num1=str2num(param{1});num2=str2num(param{2});num3=str2num(param{3});
str1=(param{4});str2=(param{5});str3=(param{6});
save data\param num1 num2 num3 str1 str2 str3;
key_reset=1;
save data\key_reset key_reset;
else
key_reset=0;
save data\key_reset key_reset;
end
% --------------------------------------------------------------------
function f_open_Callback(hObject, eventdata, handles)
% hObject handle to f_open (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';'*.png';'*.gif'},'选择背景');
% --------------------------------------------------------------------
function f_new_Callback(hObject, eventdata, handles)
% hObject handle to f_new (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
- 233
- 234
- 235
- 236
- 237
- 238
- 239
- 240
- 241
- 242
- 243
- 244
- 245
- 246
- 247
- 248
- 249
- 250
- 251
- 252
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/118278136
- 点赞
- 收藏
- 关注作者
评论(0)