找回密码
 注册
关于网站域名变更的通知
查看: 711|回复: 1
打印 上一主题 下一主题

基于matlab GUI路面裂缝识别

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2021-4-14 08:49 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x

5 {$ f" u4 T& l- v一、简介
1 W8 S3 I  y! y; @$ o高速公路路面病害养护和管理的重要部分就是路面裂缝的检测。近年来,路面裂缝自动检测技术已得到了广泛应用,而由于路面裂缝图像的复杂性,检测算法直接影响着检测结果的精确度。因此,本文将重点放在路面裂缝病害的检测上,为了提高检测的精度,分别从裂缝图像的去噪、图像的增强、图像的分割以及检测后路面裂缝图像的特征提取方面进行深入研究。  在路面裂缝图像中,由于裂缝信息与背景对比度偏低,难以将裂缝直接检测到。对于图像的预处理,首先对图像进行灰度校正,再对校正之后的图像滤波,本文提出了一种改进的中值滤波方法,对图像进行去噪,之后用基于模糊理论的图像增强原理对图像做进一步增强,有效提高了路面裂缝图像的对比度。  针对路面裂缝图像分割,本文分别用了阈值分割和基于形态学多尺度的思想,对于形状规则的裂缝采用的是阈值分割,对于裂缝形状不规则的图像,本文设计了一种多结构元素的抗噪型边缘检测算子,且依据不同形状的结构元素对裂缝边缘填充的几率不同,确定了自适应权重,使得算子检测到了各种类型的裂缝边缘,有效地提高了检测的精度。  对于经过分割后的路面裂缝图像中存在噪声和裂缝断裂的问题,本文对于断裂较窄的图像用形态学中的闭运算和开运算去处理,对于断裂较宽的图像,提出了一种基于生长的断裂裂缝块的连接方法。提高了连接的效率和准确率,使整个检测结果清晰完整。最终,从识别结果图中提取裂缝信息。根据得到的识别结果图,设定一系列判定条件,提取出裂缝的连通域,对裂缝的类型进行判断,最后计算出网状裂缝的面积及线性裂缝的长宽信息。
$ e( p9 u- E# R
" c: e& J0 i" R  m% X# W6 t二、源代码
* ~6 R# D5 h; I1 i& yfunction varargout = Gui_Main(varargin)
* V- u" y3 Q! C% GUI_MAIN M-file for Gui_Main.fig
3 S' y7 R6 `7 g! W% J4 I- J%      GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing2 y/ H9 H3 d8 `; d
%      singleton*.( p+ W- i# c1 u8 p& J
%& b. K% w) D0 ?0 V% o$ J; T/ C+ \6 S
%      H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to$ h. l) T0 E' t3 N, k+ _
%      the existing singleton*.
# ]/ X# O( i* o$ }  X$ \. Z%5 B0 e0 R5 \, G' J0 n; A
%      GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local& E! h8 {2 d% z6 u: `8 P8 {
%      function named CALLBACK in GUI_MAIN.M with the given input arguments.
; z( K/ K. O, T& ]5 L/ K5 U# Y%5 S6 D6 Q! j7 z4 n
%      GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the
% X% v  t1 S: c%      existing singleton*.  Starting from the left, property value pairs are
1 P  T4 D9 {4 D& {' Q%      applied to the GUI before Gui_Main_OpeningFcn gets called.  An
6 _: F( P. T: w) @* S* W8 Z%      unrecognized property name or invalid value makes property application
9 F6 X# E2 \# m% M7 z  X; x%      stop.  All inputs are passed to Gui_Main_OpeningFcn via varargin./ s; }  A+ J8 o/ W6 \: M  `
%/ L8 T9 I- c9 ]# ?/ z1 B' Y
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
- S8 _# q! \9 s%      instance to run (singleton)".) p1 R5 T6 u3 U2 D; S; y: r$ C
%- C  ]$ L: w: M2 v
% See also: GUIDE, GUIDATA, GUIHANDLES( c) {! C' C- b0 G9 @/ J9 r( t* ?
% k7 b  q* L+ O; m
% Edit the above text to modify the response to help Gui_Main. Q$ c4 y- x7 ]) \+ S
1 R1 G7 [! Q- m: R9 v
% Last Modified by GUIDE v2.5 29-Mar-2011 22:28:581 Z1 C+ v( O( c/ }% B

' B, [5 u" ^' n1 V  R: q% Begin initialization code - DO NOT EDIT
7 H+ a7 ^/ I7 Z1 i& fgui_Singleton = 1;" _" ?5 ]( ~4 J+ Q! B' B
gui_State = struct('gui_Name',       mfilename, ...% m6 A* d# \5 Q" r2 }/ r: ?
    'gui_Singleton',  gui_Singleton, ...
& Y+ @0 C- h$ @8 U8 {+ ~2 m, y9 Z    'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...
% }; j' v% o) U, b$ z( Q# P: Z, J    'gui_OutputFcn',  @Gui_Main_OutputFcn, ...
  o# s! R! ^3 {8 p( {# S: y/ `    'gui_LayoutFcn',  [] , ...
) D! l& C- g$ S9 Z; F& U9 i    'gui_Callback',   []);. S" p. \- U) `" ^) S) n
if nargin && ischar(varargin{1})9 `" D1 h5 u& `, @
    gui_State.gui_Callback = str2func(varargin{1});
: [1 d: ]8 F- B9 _end7 o( s, w$ a, ^1 U0 Y* I7 W

( \1 U5 s7 p9 r& rif nargout5 D  M1 [0 d, m/ w( K
    [varargout{1:nargout}] = gui_maiNFCn(gui_State, varargin{:});
/ X1 X2 W) X# d9 y9 D3 ]: lelse/ d; p8 R5 W$ D8 u
    gui_mainfcn(gui_State, varargin{:});2 D! y* y  x$ h$ T2 `- ^' X6 @
end' H2 `$ g( H  U; [
% End initialization code - DO NOT EDIT
/ n$ p- t/ T1 J0 K( v" |
0 s5 `: S; v) w' _+ o4 | ! N4 v, R4 W* R0 a6 j7 @4 ?( j. x
% --- Executes just before Gui_Main is made visible.
5 i( [' K- w% h, I$ U5 lfunction Gui_Main_OpeningFcn(hObject, eventdata, handles, varargin)" Q$ ]' T$ l. r8 O: F9 K
% This function has no output args, see OutputFcn.
# C! j, ?# N: A6 g& d+ s$ F% hObject    handle to figure
" X& z/ y' p! `3 x( F+ n1 M% eventdata  reserved - to be defined in a future version of MATLAB+ z9 b% k  w' @) M0 V7 M5 {1 B
% handles    structure with handles and user data (see GUIDATA), N0 f& s! M* J
% varargin   command line arguments to Gui_Main (see VARARGIN)
3 r7 {" ]! i) k2 V- \) O# ?
+ |4 s5 E( A  e6 q3 b! U% Choose default command line output for Gui_Main' D5 I7 v; k% i
handles.output = hObject;% y* l# u( a4 K8 \, L
handles.Result = [];! p# Y0 t- {. Y: Y
handles.File = [];
( S+ C3 n# o) [0 b% C! ]% Update handles structure
% y, U" e! k0 O& r; t& E  {guidata(hObject, handles);9 S: y# o/ _. Y; e9 k( c3 ^
clc; warning off all;7 |* n8 a' c; ?) n6 c7 A3 {
InitAxes(handles);
# p" e) g; n* U5 e 4 {* x2 s4 C$ J' d  R  w6 M1 t: [
% UIWAIT makes Gui_Main wait for user response (see UIRESUME)
+ h5 }7 z: R* K4 _8 ]% uiwait(handles.figure1);" U' ]( W. L7 D" |( [" l  ^

, |% m, u$ D& v" B 2 W" F; C" U8 d# M. O
% --- Outputs from this function are returned to the command line.4 e0 t' U# _2 N/ j5 a3 N: z4 N+ p
function varargout = Gui_Main_OutputFcn(hObject, eventdata, handles)
% ?+ n2 X7 G$ \% varargout  cell array for returning output args (see VARARGOUT);
2 q: M0 B0 G, \4 ]% hObject    handle to figure; Z) u4 o8 i* ?' n& q+ U
% eventdata  reserved - to be defined in a future version of MATLAB
6 T9 t# w. h. z' I1 N% handles    structure with handles and user data (see GUIDATA)0 B+ p4 y8 S9 X4 H' F. v% H

+ L+ N  K! M. I: o4 M3 U& [% Get default command line output from handles structure
0 B: C4 I9 z; s! d8 w; R- \$ xvarargout{1} = handles.output;) ]% X9 E. j8 L2 |
) b- q0 {) {  i. v6 I' F

; ]' Z! Y6 d" h- {% --- Executes on button press in pushbuttonOpenFile.
) ~  Y9 `1 S. M8 Ifunction pushbuttonOpenFile_Callback(hObject, eventdata, handles)
6 f$ a8 C. Q- |* Q- K2 u' ?% hObject    handle to pushbuttonOpenFile (see GCBO)
5 r0 r  R) R( [: b* T) F% eventdata  reserved - to be defined in a future version of MATLAB, H, H3 q9 a; J; c1 q, I
% handles    structure with handles and user data (see GUIDATA)
- \5 |, Z* z* R5 ^; [: v/ ?[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bmp','All Image Files';...4 e! t8 c7 J0 z' @1 t
    '*.*','All Files' },'载入图像',...
7 W* @# f4 c" h- x! u    fullfile(pwd, 'images'));2 ~  \2 ~% [, Q4 h
if isequal(filename, 0) || isequal(pathname, 0)0 J4 D" j& [; s8 `
    return;
; @% d8 U. l/ s1 p1 T! i0 hend8 l/ e# }) r$ I! _  [. a+ q
I = imread(fullfile(pathname, filename));
2 v+ p8 _8 v" O. N1 nResult = Process_Main(I);
2 \' |3 _) k. j* j0 s' Fhandles.File = fullfile(pathname, filename);* G3 W) S& X7 T9 j$ a
handles.Result = Result;; [, \. x- i1 e$ ^& T$ H
guidata(hObject, handles);
! }# Z* h# ~& n% U6 y* B( e6 \2 lInitAxes(handles)
- y1 t. v3 q5 P& baxes(handles.axes1); imshow(handles.Result.Image); title('原图像');
  s; S& Y2 c/ d( e5 P
  h* b5 c, S+ x) Z+ D0 L( I3 P+ g
0 U3 W& M  h2 l( U# K( f4 H% --- Executes on button press in pushbuttonHisteq.  a) O" [/ a4 k! `* R: ?, o, h* I
function pushbuttonHisteq_Callback(hObject, eventdata, handles)
; Q) w/ B/ l' e  p% hObject    handle to pushbuttonHisteq (see GCBO). N0 Z3 F; j1 ]4 o- @( L
% eventdata  reserved - to be defined in a future version of MATLAB
4 X2 [0 \. `. M) m8 }; j% handles    structure with handles and user data (see GUIDATA)+ r7 U" \  O$ d+ j4 K
if ~isempty(handles.Result)+ u0 s' ?# Y9 X4 ~7 M4 R( y) }" u
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
9 f  d5 ~9 T* {9 t    axes(handles.axes2); imshow(handles.Result.hist); title('直方图均衡化图像');$ F! n1 P  Q9 @: N# Z: z
end- B- i% Y; k$ W
5 |; r) H' \& F% x  o
, d3 ]1 P" u( j6 e% \" f
: Y, {% S4 X0 u( K' S
% --- Executes on button press in pushbuttonMedfilt.
+ J$ V1 m  l2 v2 P# ~function pushbuttonMedfilt_Callback(hObject, eventdata, handles)
+ p2 E% T7 w$ z; L3 T, H0 J% hObject    handle to pushbuttonMedfilt (see GCBO)
( i* L  |) O& Z1 T  T( m% eventdata  reserved - to be defined in a future version of MATLAB
$ `% ^" ^4 l: ]. `" v% handles    structure with handles and user data (see GUIDATA)5 o3 M+ N  L4 R+ w: \% ?
if ~isempty(handles.Result)3 P, r# n( P% c4 \: G- e/ |
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');# z! m+ d* S9 B% q6 l1 i
    axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');
& X8 X' E, j3 I( i' U9 V7 eend
5 Y2 Q; D$ A' Z" p3 y' J% T
. X! Q3 B' H  T# b ) s$ z$ O8 o- c; M
% --- Executes on button press in pushbuttonBw.! |! [6 n4 M1 q% ]
function pushbuttonBw_Callback(hObject, eventdata, handles)8 i1 _! S3 S% ^4 R- d0 e/ k
% hObject    handle to pushbuttonBw (see GCBO), [8 T' f: c, k) k
% eventdata  reserved - to be defined in a future version of MATLAB, ]9 n5 {( ^% i0 f" X
% handles    structure with handles and user data (see GUIDATA)
4 d- P. {! C  L, d# Iif ~isempty(handles.Result)6 P. f0 d: W- S/ B& O4 x2 N
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');4 {" `( m/ t. I+ t8 x" u, y
    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');5 C+ n/ ^" i4 h7 o  u, H
end% H6 O% f$ n5 t, P, w
0 o) i9 G3 v8 d$ U. @" Z$ M
% --- Executes on button press in pushbuttonEnance.
& |( r6 ^* A5 e( @4 U3 Sfunction pushbuttonEnance_Callback(hObject, eventdata, handles)+ n3 v; ?/ k. f" m& [
% hObject    handle to pushbuttonEnance (see GCBO)" Y7 P. M- v# }
% eventdata  reserved - to be defined in a future version of MATLAB8 A% S& m6 |7 `. N
% handles    structure with handles and user data (see GUIDATA)
8 {9 d' o3 d3 i) r2 Gif ~isempty(handles.Result)/ w' x3 |7 w, J0 R5 Y
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');9 v+ ?& [# U6 W" w
    axes(handles.axes2); imshow(handles.Result.Enance); title('增强图像');
% {1 Y# Z: M7 F( b1 C' V6 ^end- a7 J/ v- a4 u8 X

3 a8 Q6 y  A2 Y, b( e- G  Q4 [+ |% --- Executes on button press in pushbuttonBwfilter.& i8 U  d, z2 L  {3 M
function pushbuttonBwfilter_Callback(hObject, eventdata, handles)
, u1 W2 }* P) x2 d1 o9 _% hObject    handle to pushbuttonBwfilter (see GCBO): }) u4 A0 n8 m  Q% k
% eventdata  reserved - to be defined in a future version of MATLAB: C+ H& c! a+ V4 g- z$ B9 F
% handles    structure with handles and user data (see GUIDATA)
' Q8 E% f5 z+ @+ \% dif ~isempty(handles.Result)2 P1 x7 h, M. z
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');% ]5 d# T( x: x
    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');+ i1 p- k5 O& j' y) n3 @
    axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');2 D. m, Y& Q4 U( ]2 H
end
. O* B* q* m# C
, ~/ Z- H- n9 q3 Z% N% --- Executes on button press in pushbuttonCrackRec.! E+ p& {* _  L1 f! `. ]1 H8 s
function pushbuttonCrackRec_Callback(hObject, eventdata, handles)
* u2 R& m( t+ j" I; I" P$ O8 x% hObject    handle to pushbuttonCrackRec (see GCBO)$ |, f2 J" N) U1 V) {0 x) o* ]2 g
% eventdata  reserved - to be defined in a future version of MATLAB
2 a6 ^3 W3 d$ [2 C" f% handles    structure with handles and user data (see GUIDATA)
, M2 Y1 F1 y6 s3 |7 E! @3 |if ~isempty(handles.Result)$ d) X3 M( y4 F/ |4 ?
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');( h, |9 C% F$ `. b8 n! S1 Z: _$ J
    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');
: u; K/ S8 X& I3 T$ A    axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');: a" A4 {0 g1 g4 u# c4 |
    axes(handles.axes4); imshow(handles.Result.CrackRec); title('裂缝识别');( J9 i/ V: z( F% D) x, e) V* q
end3 Z4 V, r; a( X  n) m% V

0 x8 T9 F5 O4 g3 V4 u) {' H
- X. W' \/ \' F, w& S' L8 n) Z, X8 T% --- Executes on button press in pushbuttonCrackJudge.1 u- V; C9 p6 x, z. I
function pushbuttonCrackJudge_Callback(hObject, eventdata, handles)4 P" v! l+ }4 J! f
% hObject    handle to pushbuttonCrackJudge (see GCBO)) w0 j  g' n' u8 n& m
% eventdata  reserved - to be defined in a future version of MATLAB) F4 J3 q# O. a% h7 c+ T
% handles    structure with handles and user data (see GUIDATA)% G* D/ t+ b  D' k& O. F
if ~isempty(handles.Result)/ }  k3 y! W. f: E# I  l
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');- S. E5 h2 ]$ z
    axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');
6 S; R" @, p$ Z    axes(handles.axes3); imshow(handles.Result.CrackRec); title('裂缝识别');
  V3 L/ L& c: R1 q3 j) s    axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝判断');
1 ]* V, M5 C3 ~end4 Y% Z6 d- Y& R5 g8 C
& s+ y: E6 p; Y, R' z2 f3 s* w
% --- Executes on button press in pushbuttonCrackLoc.
: z8 Q) m& v! j% D5 }, lfunction pushbuttonCrackLoc_Callback(hObject, eventdata, handles)
8 \/ S. l+ s5 r$ `& O% hObject    handle to pushbuttonCrackLoc (see GCBO), D, j8 x2 G' k% u, X( u
% eventdata  reserved - to be defined in a future version of MATLAB
# X% v# i6 z2 h# m7 q% handles    structure with handles and user data (see GUIDATA)
& u; b( K. `. y% hif ~isempty(handles.Result)
0 g+ [( ?9 _0 C& m% v' N1 \' p! J9 W    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
2 p- z1 M0 G8 }9 V* ^8 S    axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');
8 s- U4 N+ Z8 l; Q: \    axes(handles.axes3); imshow(handles.Result.CrackJudge); title(handles.Result.str);" |, k+ ]1 D0 i, `9 \7 h& X9 W
    axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝标记图像');
3 h1 x  v4 @* S$ e  o    hold on;
1 J% e3 ~8 G4 R2 ^. _7 j1 R5 F+ }    rectangle('Position', handles.Result.rect, 'EdgeColor', 'g', 'LineWidth', 2);6 X% k$ T$ n2 Z6 {, O3 u7 \  Y1 {
    hold off;% Y1 X+ E5 x* |3 X8 A  {$ W% W
end
  ^+ B6 X( C) ? $ N) P. G; F" M6 R  i2 n( _( _+ l
% --- Executes on button press in pushbuttonProject.
+ H) d, @, s, I  wfunction pushbuttonProject_Callback(hObject, eventdata, handles)
3 o/ j: Z  J6 ~( y4 u& P% hObject    handle to pushbuttonProject (see GCBO)
  A8 z  y' J% y9 i6 P- _# \% h2 g% eventdata  reserved - to be defined in a future version of MATLAB  c1 S1 W" [* i* C7 y) @# o6 b5 j
% handles    structure with handles and user data (see GUIDATA)
7 Y& ?. s( l8 l" q2 @" }) wif ~isempty(handles.Result)0 K0 n) q+ e. W5 z
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');3 m4 d7 w2 A- l1 b. o1 w
    axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');
$ @5 N; L) Q' Y2 p* R* ^    axes(handles.axes3); plot(1:size(handles.Result.Image, 1), handles.Result.Projectr);
# b  \  F6 f) ~    title('行投影');9 f5 B/ V4 P4 M
    axes(handles.axes4); plot(1:size(handles.Result.Image, 2), handles.Result.Projectc);8 c6 Y1 L* o. m& A  a* x7 p
    title('列投影');
: i. L( T' W- b8 b2 |* qend, M( P) H8 B6 e" r- a/ ^3 r
4 I) g/ ]1 ?  L, t: P* g

' F: t8 K4 n6 d/ F' D% --- Executes on button press in pushbuttonClose.
) w3 x2 }5 }2 N8 s( H7 o. Z7 bfunction pushbuttonClose_Callback(hObject, eventdata, handles)
& B" G. W' ^' E3 f0 {( B) w% hObject    handle to pushbuttonClose (see GCBO)
2 T) w( B0 X& ^/ B+ e0 ~0 k% eventdata  reserved - to be defined in a future version of MATLAB
4 |& @0 n0 ?" U* b4 }% handles    structure with handles and user data (see GUIDATA)
4 W4 U% o3 d7 W& w3 h5 Pchoice = questdlg('确定退出?', ...* e! A" x  ~' `3 H$ W0 B, X
    '退出', ...
# ~0 S0 x: z5 K: l0 N/ N    '是','否','否');
% F+ l( d) x1 mswitch choice$ p" `: ^' ~# Y) j
    case '是'- y! T( B* q  u3 d$ t
        close;
9 v8 ?" S" Z& D5 c; U# J    otherwise. K% I& D/ O. U
        return;
6 j# K) g$ J9 f. `0 U: Pend
0 C0 E) {; x( R , E3 R5 ]& o. H4 G
. @1 h7 z. z* H
0 N9 J; c; A# s; ], I
% --- Executes on button press in pushbuttonSaveResult.
8 z1 G# x2 F* k! K: C/ _function pushbuttonSaveResult_Callback(hObject, eventdata, handles)
$ _& S4 }4 S* I$ T+ X) T; V% hObject    handle to pushbuttonSaveResult (see GCBO)
1 m' p, }1 [% B+ Q, {; ?8 A% eventdata  reserved - to be defined in a future version of MATLAB
; n) [' W/ d1 P* g$ o8 r8 p$ [3 j% handles    structure with handles and user data (see GUIDATA)
, w, ]1 n- \! A5 M$ `+ Gtry
6 Y/ Y# A6 [" P& b8 ^. u% C$ n, b& E    if ~isempty(handles.File)
# ]4 l, Y7 [) i5 j1 ]! k        raw = [];. P  D$ m% D# x" `2 D: f$ v
        xlsfile = fullfile(pwd, 'Result/result.xls');
1 l3 O/ t6 Y* {5 }1 O) C- q# y        if exist(xlsfile, 'file')
8 }) o, z+ \# A) a8 ]$ w9 C" e( p# [            [num, txt, raw] = xlsread(xlsfile);
3 v( G0 z* d" W) [: {        end
% Z: o+ @! e- a) ^( x, P" g        # C& ~  s  u7 z7 I% `
        F = [];2 r) |: g. ^( v) q6 m1 K
        F{1, 1} = '文件名';
0 N, I0 ?) Z' A2 a4 a        F{1, 2} = '阈值信息';% o( N4 \$ n6 k
        F{1, 3} = '面积信息';( A8 M6 X  Y0 z! |3 P
        F{1, 4} = '长度信息';; H8 g  |1 o' D8 _! M
        F{1, 5} = '最大宽度信息';
( A1 A. f# Y5 f) F7 p7 t        F{1, 6} = '最小宽度信息';
6 O& n9 u1 w- k6 |" d: R3 E) r        F{1, 7} = '形状信息';
$ n5 j3 }  ]% J5 b# M1 g  x  I        , W. h% I; A) G" \7 _( O4 |# T
        F{2, 1} = handles.File;
. @: \- h) x. v        F{2, 2} = handles.Result.BwTh;- s" _, X! W  J: H; _# K
        F{2, 3} = handles.Result.BwArea;
8 L! R0 F- l6 u& b/ l$ `        F{2, 4} = handles.Result.BwLength;
( J& \( y+ n& |4 n; c# r        F{2, 5} = handles.Result.BwWidthMax;, A0 j8 `, ]4 u: p# i
        F{2, 6} = max(handles.Result.BwWidthMin,0.01);
. D9 |& s) ~1 _# W8 q! L3 Z        F{2, 7} = handles.Result.str;
$ ?- ^7 H  E) E        
4 v7 v4 t1 }( N4 N9 Z: q: _        F = [raw; F];
* u6 ?1 @, }( V/ ]! F        xlswrite(xlsfile, F);
9 q0 C2 B8 E, }9 }* D" |0 t% b        + A. s# r/ t! j/ A
        msgbox('保存结果成功!', '信息提示框');
2 y6 s( }8 m/ C6 ]) _    end
4 O& Q$ ?: u" \; Y7 V, I; u5 jcatch
5 c/ o* g$ {; U9 H8 h    msgbox('保存结果失败,请检查程序!', '信息提示框');
/ s& N7 m4 f+ U) |: Wend
: ~( w8 a2 D9 e/ w& ` 4 ~/ P: O% w% n
6 V% b0 P. G1 C  ]0 f
% --- Executes on button press in pushbuttonBridge.) \- i) i1 Q# h+ c9 G+ v
function pushbuttonBridge_Callback(hObject, eventdata, handles)
8 H. f" X. c' H5 ~1 V9 R% hObject    handle to pushbuttonBridge (see GCBO)2 o; Q% H& o4 a; E& n  p
% eventdata  reserved - to be defined in a future version of MATLAB
! ~5 Z3 U# z1 O/ @: m% handles    structure with handles and user data (see GUIDATA)" K% O  {3 ]/ y7 P9 t/ D8 H3 b8 T8 i
if ~isempty(handles.Result)
3 E( s2 a/ c7 Y' {( w' \    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');2 O$ b6 e5 E0 j5 D( h/ H' C
    axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');: W& T: p0 r( a( R- U) S
    axes(handles.axes3); imshow(handles.Result.CrackJudge); title('裂缝判断');
# N, M3 M/ b* v5 d    axes(handles.axes4); imshow(handles.Result.CrackBridge); title('裂缝拼接');
1 q' \% R1 O5 I# J8 F% c( oend
( l# `' n! V3 j3 G * r, Q2 i9 ^% X* ?2 j% v" T0 W

& N6 e3 M3 z# d% h7 I' O& `$ y6 y% --- Executes on button press in pushbuttonSaveImage.
: Q# \; y: E0 c; L9 Sfunction pushbuttonSaveImage_Callback(hObject, eventdata, handles)* n) G* }- C  a- ~$ F& O! i9 [
% hObject    handle to pushbuttonSaveImage (see GCBO)
3 B$ V3 L3 O8 G% eventdata  reserved - to be defined in a future version of MATLAB/ D) `' E  Y7 a) p  o+ D# g
% handles    structure with handles and user data (see GUIDATA)7 A, w% O" X4 d2 c. t
[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...! m- ^. A1 W$ A
    '*.*','All Files' },'Save Image',...
+ D) e8 S4 v- [) e+ ]2 v    fullfile(pwd, 'Result/result.png'));
1 g7 Q- O1 C4 e# H: aif ~isequal(filename, 0): u. D* M1 }6 |! V" {" E
    imwrite(handles.Result.BwEnd, fullfile(pathname, filename));) {- u' g% [. X0 k& `/ O) R
    msgbox('保存图像成功!', '信息提示框');( @3 D: |- R: ]5 r
end! h8 m' Y8 b8 u* ~0 h: f

# X% P/ @( a( f( J2 j' W
) T1 I9 j2 q) p( ~" C! T2 V1 w% --- Executes on button press in pushbuttonDiplay.1 k8 g- ?/ \$ @1 Z
function pushbuttonDiplay_Callback(hObject, eventdata, handles)
0 A& A# }4 `8 x3 [- t! {4 e/ M, t% hObject    handle to pushbuttonDiplay (see GCBO)
. ]# @' t, h: f3 P% eventdata  reserved - to be defined in a future version of MATLAB5 r  }: t8 u) O- w, n
% handles    structure with handles and user data (see GUIDATA)$ r& q) j+ g5 c( b
if ~isempty(handles.File)& F' {- \  }8 k/ ]+ w  F" i1 X
    F = [];
5 |1 ^% q' S: \9 Z: R) z! _! K    F{1} = sprintf('文件名:%s', handles.File);
7 [  F: y8 A) T6 z( k7 o+ h' B    F{2} = sprintf('阈值信息%.2f', handles.Result.BwTh);; q7 R0 q& {* Z8 `3 _) i" ~
    F{3} = sprintf('面积信息%.2f', handles.Result.BwArea);
- m1 b: {$ o! U- b; @6 k    F{4} = sprintf('长度信息%.2f', handles.Result.BwLength);$ |! \5 V/ l3 H9 y
    F{5} = sprintf('最大宽度信息%.2f', handles.Result.BwWidthMax);
! e! K3 C7 v/ _8 w) G    F{6} = sprintf('最小宽度信息%.2f', max(handles.Result.BwWidthMin,0.01));3 T. h5 d( T0 C6 v
    F{7} = sprintf('形状信息%s', handles.Result.str);
: S% G1 w- L6 Y% M$ P    listdlg('PromptString', '参数显示:',...
; x7 ~, C* b' U6 V6 F6 o( D        'Name', '参数信息', ...
3 G( R/ z) I- r6 u        'ListSize', [300, 150], ...
9 A' E( K/ N/ S% {        'SelectionMode','single',...  D8 _$ [7 t' D$ H
        'ListString', F);8 f7 @: l* o: n: |
end
3 Q2 G2 T5 h* z  U* D# a
: Y! Q3 L. q5 ?) C$ D9 c1 R- R三、运行结果
1 }4 }& ^% Q2 s# {0 \8 G0 m$ u0 X1 K% E

. o2 a+ y8 ~# @0 v
0 ~' i8 ^/ m: _" G% J+ `* z8 }6 t4 T0 \
0 {5 S" U+ k) C- R$ }/ k# G

该用户从未签到

2#
发表于 2021-4-14 10:51 | 只看该作者
基于matlab GUI路面裂缝识别
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

EDA365公众号

关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

GMT+8, 2025-6-18 11:48 , Processed in 0.109375 second(s), 26 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表