1. 程式人生 > 其它 >【裂縫識別】基於matlab GUI BP神經網路路面裂縫識別系統【含Matlab原始碼 1063期】

【裂縫識別】基於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)

三、執行結果


四、備註

版本:2014a
完整程式碼或代寫加1564658423