裂缝识别系统 Matlab GUI设计

发布于:2025-03-18 ⋅ 阅读:(20) ⋅ 点赞:(0)

在这里插入图片描述
在这里插入图片描述

使用说明

裂缝识别系统 Matlab GUI设计 ,运行环境Matlab2023b及以上;

一种基于MATLAB图形用户界面(GUI)的裂缝自动识别系统,该系统利用数字图像处理技术实现裂缝图像的预处理,集成均衡化、噪声滤波、对比增强和形态学操作等算法,系统可高效识别裂缝,为工程结构检测提供便捷工具。

代码获取

  • 私信回复裂缝识别系统 Matlab GUI设计


% --- 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)

% --- 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