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

基于matlab GUI路面裂缝识别

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x
; Y5 [( ]2 h  H
一、简介
: G9 h. Y9 }* {5 I/ i9 h高速公路路面病害养护和管理的重要部分就是路面裂缝的检测。近年来,路面裂缝自动检测技术已得到了广泛应用,而由于路面裂缝图像的复杂性,检测算法直接影响着检测结果的精确度。因此,本文将重点放在路面裂缝病害的检测上,为了提高检测的精度,分别从裂缝图像的去噪、图像的增强、图像的分割以及检测后路面裂缝图像的特征提取方面进行深入研究。  在路面裂缝图像中,由于裂缝信息与背景对比度偏低,难以将裂缝直接检测到。对于图像的预处理,首先对图像进行灰度校正,再对校正之后的图像滤波,本文提出了一种改进的中值滤波方法,对图像进行去噪,之后用基于模糊理论的图像增强原理对图像做进一步增强,有效提高了路面裂缝图像的对比度。  针对路面裂缝图像分割,本文分别用了阈值分割和基于形态学多尺度的思想,对于形状规则的裂缝采用的是阈值分割,对于裂缝形状不规则的图像,本文设计了一种多结构元素的抗噪型边缘检测算子,且依据不同形状的结构元素对裂缝边缘填充的几率不同,确定了自适应权重,使得算子检测到了各种类型的裂缝边缘,有效地提高了检测的精度。  对于经过分割后的路面裂缝图像中存在噪声和裂缝断裂的问题,本文对于断裂较窄的图像用形态学中的闭运算和开运算去处理,对于断裂较宽的图像,提出了一种基于生长的断裂裂缝块的连接方法。提高了连接的效率和准确率,使整个检测结果清晰完整。最终,从识别结果图中提取裂缝信息。根据得到的识别结果图,设定一系列判定条件,提取出裂缝的连通域,对裂缝的类型进行判断,最后计算出网状裂缝的面积及线性裂缝的长宽信息。3 T: V) p5 ?# A- d2 V
' ]1 l* v+ P0 H: b; [3 C, K
二、源代码0 Q9 t9 C/ j* C7 x1 H
function varargout = Gui_Main(varargin)
" N* @4 i9 T" p  g/ q% GUI_MAIN M-file for Gui_Main.fig
: p+ R& ^2 m  m6 F%      GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing/ u1 Y8 S. j6 S6 _5 V5 s+ F/ L" P. I
%      singleton*.
! r4 ^# w% ~: X. s9 P' v- H6 u7 I9 q%* Y/ w+ @# ]4 ?4 c) S$ o
%      H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to
9 J  G5 J9 g# H5 x* P1 K6 T$ x' {%      the existing singleton*.
! k% |8 f+ M" @, K! ?, Y%" I  g% [: q+ \2 v
%      GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
. G( G( R' i$ g" y; a6 g$ b%      function named CALLBACK in GUI_MAIN.M with the given input arguments.
# o4 o5 l9 Y# Q' c+ x! |+ U$ S! K%# I, B$ T- E0 y; Y# B8 S
%      GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the
4 L$ `5 i6 g+ H4 _%      existing singleton*.  Starting from the left, property value pairs are
! o  x6 y3 `2 |5 z8 G2 n( t! ]%      applied to the GUI before Gui_Main_OpeningFcn gets called.  An
' t8 P* H, c+ q$ z%      unrecognized property name or invalid value makes property application) ?6 m* b( o' V2 V- h( H9 Y9 P0 g/ y9 o
%      stop.  All inputs are passed to Gui_Main_OpeningFcn via varargin.
2 a" Y/ U6 d  i' {. C%9 o8 |$ z4 q4 T! o
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one% U+ a% C0 v  H) y. {$ r& ?# o! M
%      instance to run (singleton)".$ e& a. P8 f* ?
%; M, _% Q6 O5 G$ R3 N, j
% See also: GUIDE, GUIDATA, GUIHANDLES
5 j, Q& o( p) C$ o
5 z9 w. Y$ n2 W1 H* q7 e% Edit the above text to modify the response to help Gui_Main
4 _# K2 C1 s8 J; S
: ?; e+ H. [; o" J/ f4 I6 E% Last Modified by GUIDE v2.5 29-Mar-2011 22:28:58
% \* V6 d9 M; E% r6 n
3 \; c) w& u: ^7 j& A% Begin initialization code - DO NOT EDIT
; N2 H5 T7 S% tgui_Singleton = 1;
) P' e: ]. W! @& c2 P( q( jgui_State = struct('gui_Name',       mfilename, ...' O( f9 h( h) f6 k/ }
    'gui_Singleton',  gui_Singleton, ...- i4 o: v' q3 u( f
    'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...9 L; m. e8 f; U/ }% l
    'gui_OutputFcn',  @Gui_Main_OutputFcn, ...! t4 H) e2 ?, f- T, E
    'gui_LayoutFcn',  [] , ...
% x4 L4 C, L. c    'gui_Callback',   []);
+ i  q: w. X% t, ]: `# Xif nargin && ischar(varargin{1})5 Y8 F& c2 c; a
    gui_State.gui_Callback = str2func(varargin{1});; N! |2 C% S$ y
end1 t8 ~# S! B( N- X/ `( ?% U6 h

: O1 W) @. B1 h+ nif nargout
) M9 I  o& ^) [1 z. @5 y    [varargout{1:nargout}] = gui_maiNFCn(gui_State, varargin{:});* B7 b) @3 Y  o1 s
else( k( |3 p; s* ?; F+ b
    gui_mainfcn(gui_State, varargin{:});8 ?2 e& V/ j, h: t
end  C5 v% @# t! }6 @
% End initialization code - DO NOT EDIT3 N1 i, C& c5 K% q3 k0 S" J# L3 }

' y7 |3 q2 b1 J0 U- k
' a; a* I5 e* ?1 b* v5 p2 Q* K% --- Executes just before Gui_Main is made visible.
7 Z% `' u/ ?( G4 K; b4 {function Gui_Main_OpeningFcn(hObject, eventdata, handles, varargin)3 c1 Q) j8 q$ j8 W
% This function has no output args, see OutputFcn.
3 m) W2 _- O  b' _% hObject    handle to figure
6 {- ]/ Q  l8 o+ |" }- |) l) k% eventdata  reserved - to be defined in a future version of MATLAB
7 k" L7 Z5 G- A! A3 o: r- n# u: V1 M" X% handles    structure with handles and user data (see GUIDATA)% R! G3 N. t7 `, J+ m) r
% varargin   command line arguments to Gui_Main (see VARARGIN)5 v( _4 a' d4 l% {' T( V/ s, a

) V& [1 x2 E( y; c  J% Choose default command line output for Gui_Main
! Z7 V, i; q; `1 e( W4 F# u) B. Chandles.output = hObject;
" J8 x, _6 ^3 _* o3 v4 R* \handles.Result = [];6 b0 `& S& Z, b  Q# J/ x- Z
handles.File = [];
) P$ Y$ f* x2 B4 N9 T: ~2 ]" H% Update handles structure
' Q- Y- ]% K; Z) g0 \8 `guidata(hObject, handles);
/ Z1 x0 O2 T: H4 P9 y: _clc; warning off all;
$ E$ i, \, u" |5 T, }InitAxes(handles);
0 V, ?$ J2 ?2 M& \( z& z ! O+ m; `# p, S5 C, ~2 v( S- s" Y
% UIWAIT makes Gui_Main wait for user response (see UIRESUME)
3 |& b; x+ X. C6 R+ s: }% uiwait(handles.figure1);
7 i4 ?) @) o1 j' A7 L7 A- g3 O/ \; i
* X0 @9 n$ b2 n. ~0 a- f
% B8 ]1 E, R& x& d6 J/ T8 y  i% --- Outputs from this function are returned to the command line.7 w+ b2 {5 Q  v& e1 ]
function varargout = Gui_Main_OutputFcn(hObject, eventdata, handles)
8 D( Z  a$ H. x% w3 E% varargout  cell array for returning output args (see VARARGOUT);
; p# P: R0 S' G; o0 H+ `  l% hObject    handle to figure: c) E# {6 m" @* K' {2 ]
% eventdata  reserved - to be defined in a future version of MATLAB
* j' [+ b, E/ Y* I2 r  W% handles    structure with handles and user data (see GUIDATA)9 }" v( u: T; e. f8 z( o0 j

- f. q+ Q& V) J2 Q, y% Get default command line output from handles structure! y, K2 @' h( H! K  ?/ w
varargout{1} = handles.output;
* Z$ T. w$ @0 f, H. M2 \' h/ p# d
$ T' G/ @6 _9 ]  ~" w) @$ w8 Z 5 G4 u7 z) e- L1 o8 ^  m8 I5 p* l
% --- Executes on button press in pushbuttonOpenFile.& {) i& |2 I& g: W+ s& S1 e8 B
function pushbuttonOpenFile_Callback(hObject, eventdata, handles)& h+ Y* G$ C% n: E" J5 ~7 z
% hObject    handle to pushbuttonOpenFile (see GCBO)
) i; [5 _/ Y, w7 _3 a. ~. d% eventdata  reserved - to be defined in a future version of MATLAB. g8 ]% a9 H) T
% handles    structure with handles and user data (see GUIDATA)
. q! @& h% G5 Y; n8 U6 Z! L[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bmp','All Image Files';...
$ }% d/ g" }  q; |3 {    '*.*','All Files' },'载入图像',..., S& e  r6 H( o8 ?& c1 F
    fullfile(pwd, 'images'));  C1 J1 {5 K* h! ^! \5 W* q
if isequal(filename, 0) || isequal(pathname, 0)% }0 r+ w9 k  p) i" E! i( V
    return;& ]! S/ {" z# G% c
end
( e) C$ y* d: g( f, KI = imread(fullfile(pathname, filename));4 \5 ?4 l$ e- U( x
Result = Process_Main(I);
* C" E5 i5 F# |& T$ mhandles.File = fullfile(pathname, filename);& \6 I: o9 W/ S
handles.Result = Result;" v/ v5 ]/ `% C$ k  J$ G
guidata(hObject, handles);
2 @- U, d& U8 VInitAxes(handles)
6 o% r. z- _" B( {' P8 Jaxes(handles.axes1); imshow(handles.Result.Image); title('原图像');
) N, _- ^" w9 l# U2 D" u9 {
- t* t, o+ ?, y  i
6 |& b2 a, ]8 P% --- Executes on button press in pushbuttonHisteq.
- _' n$ I5 R8 z* c1 }! Yfunction pushbuttonHisteq_Callback(hObject, eventdata, handles)! ?* I, B$ ?3 Y5 l
% hObject    handle to pushbuttonHisteq (see GCBO)
5 ]" f5 }5 l, w0 ?% o% eventdata  reserved - to be defined in a future version of MATLAB
' `/ a7 @1 `  j5 S) R1 M9 I  N% handles    structure with handles and user data (see GUIDATA)
0 D+ V' n2 d: U3 qif ~isempty(handles.Result)6 t5 G, \/ n1 P  {6 I& O
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');. u9 ]) K% V. a* J; v# r
    axes(handles.axes2); imshow(handles.Result.hist); title('直方图均衡化图像');
7 a+ p% P# I" Oend
" t3 q% C' l* O" M) ?) @# L
5 m6 R& \$ ]: K6 q - N  Z& U) Y/ \  `
  ]# s3 C" z. I& b% N6 {
% --- Executes on button press in pushbuttonMedfilt.$ C/ E( @; W5 i# ~2 O5 ^
function pushbuttonMedfilt_Callback(hObject, eventdata, handles)
9 J( B5 `7 \7 r/ ]% `: T9 x; m- K% hObject    handle to pushbuttonMedfilt (see GCBO)
& N0 |- N, F2 R% eventdata  reserved - to be defined in a future version of MATLAB) }, X9 a3 s- E' Y" f0 d
% handles    structure with handles and user data (see GUIDATA)' o1 |; a& R0 r  ~6 j9 V  ?
if ~isempty(handles.Result)2 W) \  a# k, C% |" U9 A& P
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
0 ]. |$ _" L3 {' }" r. d6 I1 Q    axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');
7 Z: T8 b! n" d5 Q& D+ @- eend7 O7 w! M0 ^! z& O4 l% C' p
/ n4 w; B2 A+ B  j8 i& A
) ]8 o1 s* g; D' Y! @
% --- Executes on button press in pushbuttonBw.
: _; z" |5 B" C$ f# qfunction pushbuttonBw_Callback(hObject, eventdata, handles)
. Q5 t- W. O7 {# Y% hObject    handle to pushbuttonBw (see GCBO)
3 y' S3 b/ a9 K! y* X% eventdata  reserved - to be defined in a future version of MATLAB" P. e0 {8 z, |" R
% handles    structure with handles and user data (see GUIDATA)
( [3 {4 a! o0 j2 U# Vif ~isempty(handles.Result)2 z/ V* _4 }  q! G
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
1 A3 @; l% Q6 C# E2 L4 L2 ]# \  c* b    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');; m7 B1 ?! |: g" C4 o# x4 X
end# Z; o+ M$ ]4 k& F0 g- p, a
/ \8 v3 c% E9 I1 G; B* U
% --- Executes on button press in pushbuttonEnance.: l& v+ X! l+ h  l8 a/ ^* N+ t2 x
function pushbuttonEnance_Callback(hObject, eventdata, handles)
% W+ e8 R" W% E7 N3 [) v' ^2 A: z% hObject    handle to pushbuttonEnance (see GCBO)
8 ]8 _. x# S- c. @% eventdata  reserved - to be defined in a future version of MATLAB
) ]0 [5 X4 `8 I8 L% handles    structure with handles and user data (see GUIDATA)3 l+ s, d5 z7 h. X% z) r+ P
if ~isempty(handles.Result)8 S. w6 a" d* e' d. C
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');6 g0 K5 N/ M& t, c# Z
    axes(handles.axes2); imshow(handles.Result.Enance); title('增强图像');7 \! [7 s- H6 a% r
end
8 D/ X3 C) x, ~. ~' r& Q9 f% Q
4 i1 z9 s, r( _5 C3 R% --- Executes on button press in pushbuttonBwfilter.: e/ f! s' h# E& j
function pushbuttonBwfilter_Callback(hObject, eventdata, handles)
/ |1 s/ Z; b. s5 O% hObject    handle to pushbuttonBwfilter (see GCBO). l4 [& |2 G& i4 R
% eventdata  reserved - to be defined in a future version of MATLAB( c& R2 y6 U( [& _' w6 N( ?, B- |- R
% handles    structure with handles and user data (see GUIDATA)0 r: D/ y2 M- ?* r1 k: m/ `4 D+ d
if ~isempty(handles.Result)
8 s( i# L) Z: H( i; k    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
! h& S8 B, {$ n# p  |5 _( P    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');# j% Z! @* W& J
    axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');
$ e, e8 `3 w8 @) H- [, G: send, Y) J# ?$ e1 I+ m; ]/ e6 N

; `% v  i6 B% m% H( z/ S( r4 e% --- Executes on button press in pushbuttonCrackRec.4 U. D) v4 ^: m3 m6 E; X4 ~- H* n
function pushbuttonCrackRec_Callback(hObject, eventdata, handles)
: Q7 n. D2 N- b2 S, ~% hObject    handle to pushbuttonCrackRec (see GCBO)3 @" V* t6 v! I! T
% eventdata  reserved - to be defined in a future version of MATLAB
5 e/ Y4 L7 {9 W4 X% handles    structure with handles and user data (see GUIDATA): }2 [: Q) O, T
if ~isempty(handles.Result)
; @7 M9 E$ w5 y    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');( h$ o( U& O7 n; H" x
    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');
* D6 J  s8 H: y; Q    axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');
& k0 H( a% T/ ~: W1 t" M3 ^    axes(handles.axes4); imshow(handles.Result.CrackRec); title('裂缝识别');/ C! V* \! K- Q+ {
end; |' H' ?) o" L
0 e3 f5 @% _, m9 D5 b/ h5 d$ [
# ^  u/ R9 y: O3 D
% --- Executes on button press in pushbuttonCrackJudge.& }# p  J5 V2 G8 i# @
function pushbuttonCrackJudge_Callback(hObject, eventdata, handles)& m2 B! Q* c* R, K
% hObject    handle to pushbuttonCrackJudge (see GCBO)
1 C5 ~/ u% `: l3 g- b  s% eventdata  reserved - to be defined in a future version of MATLAB
. P% S4 F: X0 c9 j1 n% handles    structure with handles and user data (see GUIDATA)) M* s4 o$ r& Y
if ~isempty(handles.Result)
  ]3 o: ^1 H# T    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
$ R  M% c5 d6 J& s    axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');+ I; D& Z: j, n8 F1 N3 F
    axes(handles.axes3); imshow(handles.Result.CrackRec); title('裂缝识别');9 X5 n  n, I: p! ^& R
    axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝判断');, E1 a- ^+ s6 V3 ]1 L9 n
end
3 R) e- S& w5 m! |9 Z3 J$ C- O - G3 @/ M$ ]) ]" D
% --- Executes on button press in pushbuttonCrackLoc.
$ e  q+ U% _. r$ w3 D7 D) b, Efunction pushbuttonCrackLoc_Callback(hObject, eventdata, handles)' b  C$ S8 h2 ?
% hObject    handle to pushbuttonCrackLoc (see GCBO)
' H! }; O/ O" ~% eventdata  reserved - to be defined in a future version of MATLAB! y; @. p" r3 F* ~
% handles    structure with handles and user data (see GUIDATA)
, H+ z6 S( N7 X8 cif ~isempty(handles.Result)
9 L/ l4 g6 n4 Y& A0 z) n* i1 u4 }' s3 t    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
+ f9 q# z" {) z' g    axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');7 l9 h. Q# G  W" b( \
    axes(handles.axes3); imshow(handles.Result.CrackJudge); title(handles.Result.str);
3 Q5 l" F1 V$ _9 i) m    axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝标记图像');8 G$ m0 @6 |" i$ t0 e0 ~" G
    hold on;. g+ \9 n3 T8 O% o1 c9 h0 @- c  O
    rectangle('Position', handles.Result.rect, 'EdgeColor', 'g', 'LineWidth', 2);0 O; R4 R9 R3 z3 B$ \
    hold off;
1 c$ E+ r5 c' `, p0 m  fend% B4 V- _1 e7 R4 i" R  v% B+ E8 J  d

5 h# V* ~! |: d) k1 Q9 Y% --- Executes on button press in pushbuttonProject.
+ c& K" j! B; Ifunction pushbuttonProject_Callback(hObject, eventdata, handles)
7 k0 o; M' e- q$ S% hObject    handle to pushbuttonProject (see GCBO)
" p0 ]7 j6 w/ G# j% eventdata  reserved - to be defined in a future version of MATLAB. I* Q# i) T' t* l, V, \3 O
% handles    structure with handles and user data (see GUIDATA)
6 @9 `9 q% V! n, I, O3 d  C& qif ~isempty(handles.Result)9 @0 z' K& W+ I
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
! S1 t  ], h; Y    axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');
0 N8 x! e7 h* _& Y: d4 u, i    axes(handles.axes3); plot(1:size(handles.Result.Image, 1), handles.Result.Projectr);
; [' A/ Z/ k2 s5 ^    title('行投影');
- f' q2 l( I, w# [: L8 u    axes(handles.axes4); plot(1:size(handles.Result.Image, 2), handles.Result.Projectc);
- Q" y+ c$ o. y" {1 j/ x: T! _- O    title('列投影');+ z9 M8 H" N2 K; D+ W8 G' e9 A3 W
end
+ p1 D" {/ t* k  C4 s/ ]
) y; x$ u# W6 Y- k
" I3 i' }( i5 ?- \/ H: W$ o  z% --- Executes on button press in pushbuttonClose.
6 V' _$ O, s9 x# W" f! |7 Hfunction pushbuttonClose_Callback(hObject, eventdata, handles); l2 |/ i2 n- M
% hObject    handle to pushbuttonClose (see GCBO)
" b: F8 s7 B1 b# J7 E7 H% eventdata  reserved - to be defined in a future version of MATLAB( I, q- I( t7 z# T8 d- p5 Z
% handles    structure with handles and user data (see GUIDATA)& O& b* n' Y$ e+ Q1 U
choice = questdlg('确定退出?', ...
9 x' j9 x& N* }+ W* f$ c    '退出', ...; a" _4 B9 G$ D5 l& y: k' X, }: E
    '是','否','否');
4 K9 b) z) f0 [% M6 ~switch choice& }7 y2 q  k0 m5 y/ N# S/ U
    case '是'
5 k+ b2 u. V5 Q. M! X# V        close;
+ t0 f& y# s3 p% i" \# T- g; k    otherwise
, ^0 S. h7 Q- @! K- @+ x5 s9 w6 }        return;9 _( G7 y! @5 B' m1 ~0 O2 x0 d
end+ Z% Y* z! m* u7 y
' ]+ T6 q3 Q& u7 L3 s/ T
) o) S9 c5 e9 d# `) k, L3 `

. C- z- k8 L6 Z0 s  r4 V6 }* W0 v% --- Executes on button press in pushbuttonSaveResult.+ K8 a2 k; e7 Y7 P/ i
function pushbuttonSaveResult_Callback(hObject, eventdata, handles)6 v' J6 u7 T7 Y, W; T8 x
% hObject    handle to pushbuttonSaveResult (see GCBO)
7 O1 Y/ I8 M; b; ~% eventdata  reserved - to be defined in a future version of MATLAB
! {# O5 W) r: g: o% handles    structure with handles and user data (see GUIDATA)  G9 E" v8 h8 `1 v
try; A' a% X! ?: P$ X
    if ~isempty(handles.File): \- e. t! L( ]7 D2 s, d+ t
        raw = [];
; G- t. R: `6 p        xlsfile = fullfile(pwd, 'Result/result.xls');6 @( l# O+ N6 A* e. m
        if exist(xlsfile, 'file')/ \& o) Z) z4 j' m) j* Y
            [num, txt, raw] = xlsread(xlsfile);7 b2 B4 F' P; U" J. k- \9 ?  u
        end
0 A4 E* |4 \8 |% T6 }/ f" v2 |        
# p! G1 b- y- M9 M) N5 z8 v7 m& Q        F = [];
. u% F/ W$ j1 _& [" Z        F{1, 1} = '文件名';6 `5 q: x& G: k, P/ [/ _' Z
        F{1, 2} = '阈值信息';; p% u3 U5 W9 k7 q! x
        F{1, 3} = '面积信息';
2 l4 a; ~& }9 {) @8 l6 v0 f        F{1, 4} = '长度信息';
$ n' e% I6 f/ k! T7 G% p7 P        F{1, 5} = '最大宽度信息';
' U- C; X; @1 O% ^: k        F{1, 6} = '最小宽度信息';
' t) N2 t* Z6 X        F{1, 7} = '形状信息';
# d% K! C) X4 H! t* k4 k% k        
7 C8 \3 n# l, ]1 [" C5 S        F{2, 1} = handles.File;
, ~- }, c2 s# J9 o( e        F{2, 2} = handles.Result.BwTh;+ P' z, i' ~1 k$ y( D' ^7 \
        F{2, 3} = handles.Result.BwArea;1 o4 p. L& [" q
        F{2, 4} = handles.Result.BwLength;5 j$ P  E) q3 P
        F{2, 5} = handles.Result.BwWidthMax;
% u! T/ y) F4 F- s& A- o        F{2, 6} = max(handles.Result.BwWidthMin,0.01);
) i0 F5 F6 \, X5 A9 p& s        F{2, 7} = handles.Result.str;0 Z* u$ z. T9 e6 Q+ H9 a9 w
        
$ m& Z5 F8 A/ l, W& y4 m8 m        F = [raw; F];4 p; C9 }5 A# ~! ~" n4 ~: e4 T. ~
        xlswrite(xlsfile, F);
5 ^; G; t* m5 D6 j8 Z        
- s  A" {# _; Z* T        msgbox('保存结果成功!', '信息提示框');
/ \! ^: l8 q4 _- p# n% j$ k    end
$ J/ V" ~5 W$ l+ F# u3 j( _3 acatch9 [9 U' Y9 V6 w' n  Z* L
    msgbox('保存结果失败,请检查程序!', '信息提示框');7 D2 g) u' B! q& n( ?
end
# j* C4 q9 y7 T* K# R ; ~6 w3 h- ^1 `) w3 Z) `
/ _$ }* z- D) k
% --- Executes on button press in pushbuttonBridge.
. l* Q4 ]/ x; H  q; Qfunction pushbuttonBridge_Callback(hObject, eventdata, handles)
/ ]$ L1 s9 {5 H6 K: ~+ S% F+ O: _4 u% hObject    handle to pushbuttonBridge (see GCBO)
" u3 @- z2 F7 o  c% eventdata  reserved - to be defined in a future version of MATLAB
. i4 C* W+ K. p4 [$ {% handles    structure with handles and user data (see GUIDATA)2 B* E* y/ ^4 p. _8 ~
if ~isempty(handles.Result)4 N, ~7 r4 j" S3 n
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
& R+ G& d  K1 j5 K3 j  u8 h    axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');
, B( o' J) P/ S( x' `0 ^    axes(handles.axes3); imshow(handles.Result.CrackJudge); title('裂缝判断');/ l& C2 i6 X* i! U% h% S
    axes(handles.axes4); imshow(handles.Result.CrackBridge); title('裂缝拼接');0 i: }* c7 b, Q* x
end2 W& B4 q, g2 {, F/ h$ u# ~

& P% n0 R' W( ~6 a& C" \+ @
2 c( H5 c& D! ~2 V4 C+ ~% --- Executes on button press in pushbuttonSaveImage.
7 J. f1 A. b1 d* e6 V& k  yfunction pushbuttonSaveImage_Callback(hObject, eventdata, handles)) U  z1 U7 x+ y. E- V7 \' q$ y4 Q
% hObject    handle to pushbuttonSaveImage (see GCBO)* \) A# b( ~5 g9 _9 G1 v3 C, Z
% eventdata  reserved - to be defined in a future version of MATLAB8 T7 `. J1 j- g6 y+ O9 \' z+ G
% handles    structure with handles and user data (see GUIDATA)! r& x6 l- W: D2 L- t2 f
[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...8 ~6 v. p: E6 S) g2 `
    '*.*','All Files' },'Save Image',..." I' o1 x/ x- _$ D/ g
    fullfile(pwd, 'Result/result.png'));7 ]" M' U/ }% m+ I
if ~isequal(filename, 0)
" @0 y9 ]. W' w: M    imwrite(handles.Result.BwEnd, fullfile(pathname, filename));3 j& T+ `4 Y* L
    msgbox('保存图像成功!', '信息提示框');
. ^* ?7 P' u5 _  R4 Gend6 O7 I3 O  [6 W8 [
# J. r& g/ [, Y+ M0 R' g) A# S

8 o3 i2 h* V/ o( N4 \( a1 F% --- Executes on button press in pushbuttonDiplay.
6 g. O2 |! P) [. f3 x. `$ sfunction pushbuttonDiplay_Callback(hObject, eventdata, handles); y9 A6 z0 ^+ v3 \% P2 W% ]
% hObject    handle to pushbuttonDiplay (see GCBO)
& n. Z: m- @! p3 Y% eventdata  reserved - to be defined in a future version of MATLAB
3 h7 a% w% p) H6 v6 m$ h4 W% handles    structure with handles and user data (see GUIDATA)! P% Z1 C! h) D$ [+ I7 ^6 v
if ~isempty(handles.File)0 r8 \1 R' o4 _. n) A9 a
    F = [];
" ~$ f6 @; i2 m- X0 w% y( s& B    F{1} = sprintf('文件名:%s', handles.File);
" M2 Q2 u. X, ^    F{2} = sprintf('阈值信息%.2f', handles.Result.BwTh);
( m0 M1 @: X, Q% R+ s    F{3} = sprintf('面积信息%.2f', handles.Result.BwArea);
) }0 n) p6 o& s& j0 \& P* j    F{4} = sprintf('长度信息%.2f', handles.Result.BwLength);* s, H' ~, T. M9 h. D
    F{5} = sprintf('最大宽度信息%.2f', handles.Result.BwWidthMax);
- S4 d  `" w6 c1 `$ L+ s! ~4 ]    F{6} = sprintf('最小宽度信息%.2f', max(handles.Result.BwWidthMin,0.01));
! P, u: |% a. r    F{7} = sprintf('形状信息%s', handles.Result.str);
" _: }0 w( e! z8 t6 z! U; u7 Q    listdlg('PromptString', '参数显示:',...
' ~! @- Z$ N6 Z% G1 V        'Name', '参数信息', ...; f; c  Z/ x/ t$ r$ V  z  x
        'ListSize', [300, 150], ...  F& D- s, A  ^  t8 g  D8 n$ X; a6 Y
        'SelectionMode','single',...  N8 L9 Z9 ?( J7 S' C" j
        'ListString', F);/ [; ^9 c1 j# k7 F2 i4 x
end
, [$ X; S) `9 w5 F: p7 u. y8 N9 b# f) q
三、运行结果
* B% L) G% ]% d7 r' p' Q+ ^: M7 L, W% U* Y) L0 R+ Z& @
5 o+ b9 M5 w0 N; `

( U! \2 M. v( i: C. v$ J  m  |2 V; O2 A- W$ w! m
# O$ W( j+ G9 [: l

该用户从未签到

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

本版积分规则

关闭

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

EDA365公众号

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

GMT+8, 2025-11-24 01:15 , Processed in 0.171875 second(s), 26 queries , Gzip On.

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

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

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