基于Matlab裂缝识别检测系统

图像的特征是图像处理和特征识别的出发点,决定了处理过程中算法的选取。一般来说,采集系统得到的路面图像中包含三部分:核心部分是待识别的目标裂缝;另一部分是无破损的路面,即背景;最后是噪声,包括油斑阴影等等。噪声是路面图像特征提取的最大障碍,识别算法的目的就是完成对噪音的削弱和去除,以完成更好的提取路面裂缝特征信息的最终目的。在理想情况下,背景像素比裂缝像素更亮一些,特别是裂缝周围的背景,这是大多数路面特征提取研究的基础。但是,受到各种复杂因素的影响,在实际采集的路面图像上会有更多不利情况的出现,诸如以下几种情形:

  • 路面图像呈现中间段明亮而走向两端逐渐变暗的特点。
  • 裂缝作为识别目标,其像素数量仅占整张图像像素总量的很小一部分。
  • 正常路面灰度值的波动范围与裂缝的灰度范围会有重合。
  • 受到光照和天气等因素的影响正常的路面纹理的均匀性。
  • 公路的里程一般很大,采集整条公路的路面图像信息量很大。由于路面图像信息量大,对比度低以及工作环境的复杂性,采集到的路面图像呈现以上几种特征,有些是硬件条件的性质所决定,主要是由如下三个硬件因素的影响,即辅助照明设备的选择以及照明角度的控制,摄像机相对路面的角度和镜头距离公路路面的高度。

 一、路面裂缝检测识别系统设计流程

路面裂缝检测识别系统的主要如下三个功能:

1、把 电子设备采集到的彩色路面裂缝图像进行预处理、路 面裂缝检测识别、保存结果。

2、图像预处理

        图像预处理主要用于消除干扰图像裂缝识别的 噪声信息,起到图像增强对比度的效果,为后来的路 面裂缝识别打下了坚实的基础。预处理通过对图像进 行一系列的数学运算,提取有益于识别裂缝有用特征 信息,提高图像裂缝识别效果。

2.1 直方图均衡化

        在采集路面裂缝图像时,很容易受到当时的天 气、采集技术、设备自身的影响,使得采集到图像不 清晰,出现扭曲、模糊等问题,很容易得到对比度不 清楚的图像。直方图均衡化方法是一种增强图像的方 法,主要用于凸显图像的对比度,该方法是把原始图 像的直方图分布通过某个变换变成均匀分布直方图分 布。假设图像 Image 是一幅灰度图像,图像的灰度用 gray 表示,取值范围为 [0,L-1],则 gray 值取 0 时, 该图像为一幅黑色图像,gray 值取 L-1 时,该图像为 一幅白色图像。

2.2  中值滤波

        在采集裂缝图像时通常会受到设备、天气因素 的干扰而产生噪声, 因此,待处理裂缝图像可能出 现裂缝模糊、裂缝周围带有噪声等问题。经过上述处 理的图像经过中值滤波处理后不仅可以把图像中大 部分噪声消除,还可以很好地保留图像裂缝边缘细 节,同时突出图像的裂缝特征。实现代码:


% --- 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',
    '*.*','All Files' },'载入图像',...
    fullfile(pwd, 'images'));
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('原图像');
    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)
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)
    imwrite(handles.Result.BwEnd, fullfile(pathname, filename));
    msgbox('保存图像成功!', '信息提示框');
end

 

参考文献 

【1】张磊 . 基于图像处理的公路路面裂缝检测技术研究 [J]. 机 械设计与制造工程 ,2017

【2】孙波成.基于数字图像处理的沥青路面裂缝识别技术研 究 [D]. 成都 : 西南交通大学 ,2015.


 详情资料请扣扣:1341703358,后利用 Matlab 设计程序来显示所得到的试验结果。通过实验结果可 以看出,设计的路面裂缝检测识别系统是可以准确有 效地识别路面裂缝。

猜你喜欢

转载自blog.csdn.net/Jiangtagong/article/details/124048920