1 簡介
公路在使用程序中會受到各種車輛的反復磨損以及各種其他因素影響,最終路面就會出現嚴重影響公路正常運行的破損,現行的主要路面破損檢測方式是人工檢測,這種檢測方式不僅耗費大量的人力物力,而且速度極慢,嚴重影響了道路的檢測維護行程,這些路面破損中主要以裂縫的形式表現,所以開發一套路面裂縫自動檢測影像識別系統具有重要的理論意義和使用價值, 本文在數字影像處理技術的基礎上對路面裂縫影像檢測識別系統進行了研究,主要作業和結論如下: 1.本文首先分析了公路路面裂縫檢測系統的結構、各種模塊的選擇以及作業原理,從硬體到軟體設計了路面裂縫檢測系統,硬體設備主要由檢測裝置平臺、影像采集系統、影像處理系統、供電系統、照明系統組成,軟體部分則是基于Matlab GUI的路面裂縫影像處理系統,并且經過多次實際路面裂縫檢測驗驗,成功的驗證了檢測系統的設計思想和硬體選擇的正確性, 2.依據公路路面裂縫影像資料的特點對裂縫進行了影像的增強平滑處理,然后此基礎之使用6種邊緣檢測算子對路面裂縫特征進行了裂縫提取,進而在此基礎上提出了8方向Sobel檢測算子,并驗證了8方向Sobel檢測演算法在對去除影像噪聲改善路面裂縫影像質量方面有明顯的效果, 3.應用了腐蝕、膨脹、細化等數學形態學處理方法對路面裂縫影像進行了處理,然后利用閾值判別法分辨出了線性裂縫和網狀裂縫,在此基礎上又利用投影法分辨出了橫向裂縫和縱向裂縫,最后根據分類后的情況計算了網狀裂縫的外接面積以及橫向裂縫與縱向裂縫的長度,經驗證對裂縫型別的判斷準確率率可達到80%左右,?
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
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('原影像');
axes(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)
% 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', handles.Result.rect, '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
return;
end
% --- Executes on button press in pushbuttonSaveResult.
function pushbuttonSaveResult_Callback(hObject, eventdata, handles)
% hObject handle to pushbuttonSaveResult (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
try
if ~isempty(handles.File)
raw = [];
xlsfile = fullfile(pwd, 'Result/result.xls');
if exist(xlsfile, 'file')
[num, txt, raw] = xlsread(xlsfile);
end
F = [];
F{1, 1} = '檔案名';
F{1, 2} = '閾值資訊';
F{1, 3} = '面積資訊';
F{1, 4} = '長度資訊';
F{1, 5} = '最大寬度資訊';
F{1, 6} = '最小寬度資訊';
F{1, 7} = '形狀資訊';
F{2, 1} = handles.File;
F{2, 2} = handles.Result.BwTh;
F{2, 3} = handles.Result.BwArea;
F{2, 4} = handles.Result.BwLength;
F{2, 5} = handles.Result.BwWidthMax;
F{2, 6} = max(handles.Result.BwWidthMin,0.01);
F{2, 7} = handles.Result.str;
F = [raw; F];
xlswrite(xlsfile, F);
msgbox('保存結果成功!', '資訊提示框');
end
catch
msgbox('保存結果失敗,請檢查程式!', '資訊提示框');
end
% --- Executes on button press in pushbuttonBridge.
function pushbuttonBridge_Callback(hObject, eventdata, handles)
% hObject handle to pushbuttonBridge (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.CrackJudge); title('裂縫判斷');
axes(handles.axes4); imshow(handles.Result.CrackBridge); title('裂縫拼接');
end
% --- Executes on button press in pushbuttonSaveImage.
function pushbuttonSaveImage_Callback(hObject, eventdata, handles)
% hObject handle to pushbuttonSaveImage (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
'*.*','All Files' },'Save Image',...
fullfile(pwd, 'Result/result.png'));%選擇影像保存路徑
if ~isequal(filename, 0)
imwrite(handles.Result.BwEnd, fullfile(pathname, filename));%寫出影像
msgbox('保存影像成功!', '資訊提示框');%提示框
end
% --- Executes on button press in pushbuttonDiplay.
function pushbuttonDiplay_Callback(hObject, eventdata, handles)
% hObject handle to pushbuttonDiplay (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.File)%影像資訊是否為空
F = [];
F{1} = sprintf('檔案名:%s', handles.File);
F{2} = sprintf('閾值資訊%.2f', handles.Result.BwTh);
F{3} = sprintf('面積資訊%.2f', handles.Result.BwArea);
F{4} = sprintf('長度資訊%.2f', handles.Result.BwLength);
F{5} = sprintf('最大寬度資訊%.2f', handles.Result.BwWidthMax);
F{6} = sprintf('最小寬度資訊%.2f', max(handles.Result.BwWidthMin,0.01));
F{7} = sprintf('形狀資訊%s', handles.Result.str);
listdlg('PromptString', '引數顯示:',...
'Name', '引數資訊', ...
'ListSize', [300, 150], ...
'SelectionMode','single',...
'ListString', F);
end
3 仿真結果

4 參考文獻
[1]董欽. 路面裂縫影像檢測識別系統研究. (Doctoral dissertation, 華東交通大學).

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/352060.html
標籤:其他
