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

基于matlab GUI路面裂缝识别

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x

0 I0 E  a- ^: f! a一、简介
5 w: m5 E3 C: B& w' r高速公路路面病害养护和管理的重要部分就是路面裂缝的检测。近年来,路面裂缝自动检测技术已得到了广泛应用,而由于路面裂缝图像的复杂性,检测算法直接影响着检测结果的精确度。因此,本文将重点放在路面裂缝病害的检测上,为了提高检测的精度,分别从裂缝图像的去噪、图像的增强、图像的分割以及检测后路面裂缝图像的特征提取方面进行深入研究。  在路面裂缝图像中,由于裂缝信息与背景对比度偏低,难以将裂缝直接检测到。对于图像的预处理,首先对图像进行灰度校正,再对校正之后的图像滤波,本文提出了一种改进的中值滤波方法,对图像进行去噪,之后用基于模糊理论的图像增强原理对图像做进一步增强,有效提高了路面裂缝图像的对比度。  针对路面裂缝图像分割,本文分别用了阈值分割和基于形态学多尺度的思想,对于形状规则的裂缝采用的是阈值分割,对于裂缝形状不规则的图像,本文设计了一种多结构元素的抗噪型边缘检测算子,且依据不同形状的结构元素对裂缝边缘填充的几率不同,确定了自适应权重,使得算子检测到了各种类型的裂缝边缘,有效地提高了检测的精度。  对于经过分割后的路面裂缝图像中存在噪声和裂缝断裂的问题,本文对于断裂较窄的图像用形态学中的闭运算和开运算去处理,对于断裂较宽的图像,提出了一种基于生长的断裂裂缝块的连接方法。提高了连接的效率和准确率,使整个检测结果清晰完整。最终,从识别结果图中提取裂缝信息。根据得到的识别结果图,设定一系列判定条件,提取出裂缝的连通域,对裂缝的类型进行判断,最后计算出网状裂缝的面积及线性裂缝的长宽信息。7 ?. E. S! A& A0 z# i" u9 F

7 Q* [2 p% s3 u; I% R8 u二、源代码- T8 z1 a) d! |8 |
function varargout = Gui_Main(varargin)& S3 |; F; t% b0 j3 j4 x+ y# `. b. t
% GUI_MAIN M-file for Gui_Main.fig
, d$ x1 ]" t% b' Q3 O# _%      GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing
( `. m1 B- G2 `, R%      singleton*.
# w4 W! I& u" \( {%% ~0 y( t& G4 B" e" Z4 k
%      H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to) B0 q  f- i! l* S4 u
%      the existing singleton*.
: Y! W1 f# P1 e) Z" i  w2 M%) u( Q2 C5 J$ ^( f" A& a4 s' J* E
%      GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
$ m  A/ v5 `# [/ ~! [# y, q%      function named CALLBACK in GUI_MAIN.M with the given input arguments.( v3 ^6 U7 w8 Z4 \& a
%( w9 y4 o9 D- c* ~. C
%      GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the
2 R+ r3 n$ c8 Q%      existing singleton*.  Starting from the left, property value pairs are
( G* j; z  y; i# i4 o%      applied to the GUI before Gui_Main_OpeningFcn gets called.  An! T% _5 \% |( m# O! G" H5 G+ d
%      unrecognized property name or invalid value makes property application/ \  N* ^3 X' U' l
%      stop.  All inputs are passed to Gui_Main_OpeningFcn via varargin.0 K6 a6 d2 |. ], F/ g, R" q8 E$ l& _
%$ v* c' F- O: _. j/ |; P" g6 g6 e
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
: I% |, p# p; D* a$ P" y! v/ x%      instance to run (singleton)".
6 l6 s" _% Q# L%
* W, i6 z: d4 ]5 i: ^4 i% See also: GUIDE, GUIDATA, GUIHANDLES
3 m# W: z1 _# ^$ u, T0 W. O 6 n  M# p0 |- p
% Edit the above text to modify the response to help Gui_Main
+ a7 n, E% T7 J' U: L
% e# d* s! V5 ]9 f7 d% Last Modified by GUIDE v2.5 29-Mar-2011 22:28:58, Y- Q1 z4 l" w4 x5 L8 O

3 _! {& k1 r4 q+ _% Begin initialization code - DO NOT EDIT
, l3 @& K2 m# @1 g+ Hgui_Singleton = 1;
" u7 ]/ K0 v8 a4 dgui_State = struct('gui_Name',       mfilename, ...
3 q2 {: E& J9 Y2 r' P% h    'gui_Singleton',  gui_Singleton, ...  t4 w/ F0 p/ i$ i
    'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...
4 n3 @& e! L* e8 p! l    'gui_OutputFcn',  @Gui_Main_OutputFcn, ...8 Y4 g/ {6 W, a
    'gui_LayoutFcn',  [] , ...
1 q0 }7 B8 c. P: K8 I. o, D0 Y    'gui_Callback',   []);
% V2 u  W3 H$ k) [! Fif nargin && ischar(varargin{1})
- K- l1 A8 {6 X# ^3 y    gui_State.gui_Callback = str2func(varargin{1});7 P  v  [+ X" G* c  V
end% O" J; o( J  v1 `/ U& J$ D

9 t( a7 Z  m- R5 @$ zif nargout5 E8 D  M( z& i: n; L8 u. Z$ L
    [varargout{1:nargout}] = gui_maiNFCn(gui_State, varargin{:});
" e6 Z: r2 A2 r6 B! r0 A' kelse
3 J( ?& X& A) y  H' m& p9 q  s    gui_mainfcn(gui_State, varargin{:});  d' c# y7 x. a4 Z
end6 J: K9 `8 [  ]+ {! E. P4 W7 Y
% End initialization code - DO NOT EDIT
# d4 q2 ]& [3 c* g ( ^$ f1 E- j5 E' Z. A" m4 t4 A0 b

! u/ s0 z5 W/ N" [: }4 w6 x, ^8 Y% N% --- Executes just before Gui_Main is made visible.1 S2 i9 V( Z! F! U2 D% Z+ b
function Gui_Main_OpeningFcn(hObject, eventdata, handles, varargin)
' _) b# h) a6 C/ Z4 U" |  K  n% This function has no output args, see OutputFcn.
& O3 _6 C, y" Y% hObject    handle to figure
% [$ v4 E7 R8 p1 s% eventdata  reserved - to be defined in a future version of MATLAB. O( ~0 k- }4 V9 c. O8 {
% handles    structure with handles and user data (see GUIDATA)4 f6 B( S3 [8 O( X/ s
% varargin   command line arguments to Gui_Main (see VARARGIN)
- r" d) V6 Q, A, Q' S! R$ q; i + c, G. ]6 k1 d2 Q
% Choose default command line output for Gui_Main
' x4 i! c, v) a; r& r4 chandles.output = hObject;
3 Q8 C$ e- Z# n! |$ chandles.Result = [];" L/ p0 F& ~( @% m
handles.File = [];4 H1 F4 L! v7 h0 }: L
% Update handles structure% P0 Z0 E9 s. r/ B
guidata(hObject, handles);! O$ G9 A# ?2 W" d" o6 S, W: L9 e
clc; warning off all;6 c- t7 j# ]# [; U! ]) h0 N
InitAxes(handles);' i* o" `1 D- K

; h( x+ M+ d5 Y2 J% UIWAIT makes Gui_Main wait for user response (see UIRESUME)$ r& U9 \* t+ S& d
% uiwait(handles.figure1);
. l$ w6 L' x; f6 d% {/ x2 } ( y; q9 {1 g; ~$ R/ t

% ?/ O* S- x  f) G( l4 ^% --- Outputs from this function are returned to the command line./ C3 r/ o- D, y/ @$ l7 a" r- }
function varargout = Gui_Main_OutputFcn(hObject, eventdata, handles)
7 C6 i; A5 c! u6 [% varargout  cell array for returning output args (see VARARGOUT);
. u1 T+ |1 a" C! G4 c. B% hObject    handle to figure
+ ^# ~7 V3 u& U7 c' |% \; d% eventdata  reserved - to be defined in a future version of MATLAB2 U" j4 ]. _6 h# e& h& o
% handles    structure with handles and user data (see GUIDATA)
3 |  f9 c! {* a
& J6 Q1 u1 K- X% Get default command line output from handles structure
* m7 [* {) x4 c8 ?; k$ avarargout{1} = handles.output;5 d/ o1 T; c, t
: d2 K/ C$ z: _: g

# Z) n2 ]- I$ U* d$ F% --- Executes on button press in pushbuttonOpenFile.
, D" V  e; i4 n4 x7 U* z0 Kfunction pushbuttonOpenFile_Callback(hObject, eventdata, handles); c; ]3 x& p0 u5 n6 B) P
% hObject    handle to pushbuttonOpenFile (see GCBO)
8 P$ r- H& m( l( h7 g& ?% eventdata  reserved - to be defined in a future version of MATLAB3 g4 R- v1 x+ Z3 T+ n9 J
% handles    structure with handles and user data (see GUIDATA)  }( d$ c+ K6 X4 R" v
[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bmp','All Image Files';...3 E0 M2 ]: B. I
    '*.*','All Files' },'载入图像',...
' K; f6 X# y" D' k    fullfile(pwd, 'images'));. D8 b4 b% B2 H5 t
if isequal(filename, 0) || isequal(pathname, 0)
$ e1 w) _9 m+ d3 D7 g7 w+ G0 `    return;* y" `* M' _# n. J
end
8 M1 {- a; e/ E4 q4 ^  ?! ZI = imread(fullfile(pathname, filename));
$ [0 Z6 A! W% C7 Z( R4 p* }Result = Process_Main(I);
: W) Y7 h+ k6 H8 H  nhandles.File = fullfile(pathname, filename);6 L6 s* w6 w. q3 E2 @8 G* H: m$ J
handles.Result = Result;
& m' A, N, X! G) oguidata(hObject, handles);
5 o' H: C: O7 \8 h0 @/ C$ g* QInitAxes(handles)+ G1 p1 o# B$ f2 ]! T( H' s8 [
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');, g+ N& y1 q4 C, A, U  c! s
- q' t: D3 u4 C3 C' [# D

7 |; q" ?+ h2 S) ~) ?$ k* H% --- Executes on button press in pushbuttonHisteq.
6 g' H( x" G; z' W7 q! K) kfunction pushbuttonHisteq_Callback(hObject, eventdata, handles), k5 `. z9 b1 F/ L) Q0 {# r
% hObject    handle to pushbuttonHisteq (see GCBO)
# h" |3 ]4 S) z) U& C/ b, z& Z% eventdata  reserved - to be defined in a future version of MATLAB
1 ^; s) D- ?6 R  R% handles    structure with handles and user data (see GUIDATA)
4 n0 n$ R8 A# i0 ]4 pif ~isempty(handles.Result)
4 d8 x- V: C( i9 ]    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');+ {$ g5 p' g. g  U; K( f
    axes(handles.axes2); imshow(handles.Result.hist); title('直方图均衡化图像');" L- f7 K7 V" V3 T9 R
end
' |) s) ?5 w2 X: D7 ]4 K2 q
% x7 E) ]- L, V' H4 Z1 T7 G
- c# E4 k) y4 m. p3 ^ 7 l/ n% `2 q: y9 m  g
% --- Executes on button press in pushbuttonMedfilt.
! K" o; R" f: t( [, Y: Afunction pushbuttonMedfilt_Callback(hObject, eventdata, handles)0 z. {3 K) A8 q* z6 x) b- d& n
% hObject    handle to pushbuttonMedfilt (see GCBO)
$ U; @$ Z0 m5 z, R6 P! k& Q% eventdata  reserved - to be defined in a future version of MATLAB
/ k5 }% W$ p  z2 J9 L8 B4 L% handles    structure with handles and user data (see GUIDATA)5 a! r1 ]6 e- @
if ~isempty(handles.Result)" J0 w1 ]/ j, ~: r, k6 y) l/ Q
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');+ \, ?" Z8 |7 S5 c. `
    axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');
  X1 D2 `" ]% h' yend: U; B, R/ Q! i: u# b2 I* g0 @: A
: [0 Y1 A7 Q  Z8 M# [) k0 {9 f1 x. v

3 Y* ^% f7 C* B* x# S# s0 l$ q: ]% --- Executes on button press in pushbuttonBw.
' T. R8 w* b# u/ S% Y! Y% sfunction pushbuttonBw_Callback(hObject, eventdata, handles)$ `; q- i+ a# F2 y3 E
% hObject    handle to pushbuttonBw (see GCBO)
: K$ n) M. l  N1 J% eventdata  reserved - to be defined in a future version of MATLAB
# q+ l8 L3 L* L& S/ z! g% handles    structure with handles and user data (see GUIDATA)3 G- {% q& O9 Y1 I' J6 R0 }
if ~isempty(handles.Result)
9 I/ P" d. A0 J, v6 j; Q8 p: b$ r    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');& Z' G8 [# w/ s
    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');# Z6 m$ M3 L7 Y; K3 s  ^0 l! |2 m
end
# J! E- {  m) B
8 j" r# u2 a& K6 G; S% --- Executes on button press in pushbuttonEnance.
9 p, \8 l4 d! O# r7 C# }, xfunction pushbuttonEnance_Callback(hObject, eventdata, handles)) l; g( u4 F/ m$ Z4 M4 C/ u( `
% hObject    handle to pushbuttonEnance (see GCBO)
. l4 ?9 t$ Y( z$ u% s0 Q% eventdata  reserved - to be defined in a future version of MATLAB
1 ~$ @4 }% L5 C9 I5 l; ]1 h% handles    structure with handles and user data (see GUIDATA)" F3 `4 ?# V' R- m6 w8 h
if ~isempty(handles.Result)8 ~7 Z  j1 N  O4 B7 @: N/ s
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');5 o, m& B$ b9 O4 |
    axes(handles.axes2); imshow(handles.Result.Enance); title('增强图像');
5 |- o4 p6 q1 ^& A& _end5 T( f3 C: B- }' ^7 E' O
" n/ x6 ~! \2 y' b5 ?
% --- Executes on button press in pushbuttonBwfilter.8 D  @9 ?8 n  d7 q* ^
function pushbuttonBwfilter_Callback(hObject, eventdata, handles)
: A# P+ R) B1 _4 D; ^% hObject    handle to pushbuttonBwfilter (see GCBO)3 ?  q2 l" t" `4 M
% eventdata  reserved - to be defined in a future version of MATLAB, U5 d+ P, B$ i/ E( q# J5 z9 H
% handles    structure with handles and user data (see GUIDATA)' h& C+ W" C  v' \, x! M2 v) `+ i
if ~isempty(handles.Result)
! s6 B3 h6 j' p" A    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');  e  [+ s- P5 }' E/ N
    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');9 m) h2 h' _7 M* a7 M5 {3 _. |4 r+ ^
    axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');# K# Z5 j, t9 C2 m; }7 r1 p/ v  K% e
end
% E8 `) ^- D  w1 A1 ~6 U: T
+ i! d  N# Q. J% q: u) [6 b% --- Executes on button press in pushbuttonCrackRec.% M) ?1 Z2 e, Q  k
function pushbuttonCrackRec_Callback(hObject, eventdata, handles)
" u; P2 F$ W1 i& o$ w, M# J% hObject    handle to pushbuttonCrackRec (see GCBO). L" L7 a, s) A- W
% eventdata  reserved - to be defined in a future version of MATLAB
$ J) a8 E6 }) W' J, l2 I  w/ Y% b6 f8 p% handles    structure with handles and user data (see GUIDATA)) g, U+ [) }$ }. U$ r4 |3 w
if ~isempty(handles.Result)/ S5 r" t# j3 h# R
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
4 N8 l5 s$ A" _8 F    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');
) b- _" }! }3 x( ~# d! P    axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');
' c; n! s; f+ T& L* x+ `' A* a    axes(handles.axes4); imshow(handles.Result.CrackRec); title('裂缝识别');' p; E  v. I% `- d1 r; S5 w$ j' \
end: N( _2 @- A! D# a# A! A1 d7 h( N9 G, X

0 {, Z# [* N5 t  k) a/ B: l& I
$ [9 N' X2 r& i3 t* O' d* J( K% --- Executes on button press in pushbuttonCrackJudge.3 T: H% F$ ]# S3 e& k
function pushbuttonCrackJudge_Callback(hObject, eventdata, handles)5 t  _, u# d# d7 V* A$ P! [
% hObject    handle to pushbuttonCrackJudge (see GCBO)# j- z2 s- c6 {1 `) Z
% eventdata  reserved - to be defined in a future version of MATLAB
) i9 v' K8 t0 H# J' R  C4 W% handles    structure with handles and user data (see GUIDATA)+ w0 T' n6 p1 _" d* m" F0 C0 h
if ~isempty(handles.Result)
+ o& ?, j8 s- Q  I9 x. d! Y    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
% B. R" ~' b8 J, i, B7 b+ m- Q    axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');
6 M7 y$ f5 R3 c% K1 X3 l5 D* H) @) A1 O    axes(handles.axes3); imshow(handles.Result.CrackRec); title('裂缝识别');0 }# a5 v5 O" [! G
    axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝判断');
5 L- h: m& o* X: v8 ^/ ]end
0 B  a8 `! n7 S9 y
5 V! v, m. n3 Q% --- Executes on button press in pushbuttonCrackLoc.
7 m+ ^0 U( a9 y; d2 p2 g4 S8 Q6 @, yfunction pushbuttonCrackLoc_Callback(hObject, eventdata, handles)& D; x" J$ ?9 `% {9 E5 D
% hObject    handle to pushbuttonCrackLoc (see GCBO)& N) A. O( t6 }- ?0 ?# R
% eventdata  reserved - to be defined in a future version of MATLAB8 z* Y/ |) H4 v. d- {- \- @* D7 [
% handles    structure with handles and user data (see GUIDATA)
3 l. m. F5 N, `8 Cif ~isempty(handles.Result)
  V; d( y1 y9 i6 M, Q4 l# S1 C- |    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');+ c& l0 z1 c8 m% L) H
    axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');- }; f5 `; C4 j
    axes(handles.axes3); imshow(handles.Result.CrackJudge); title(handles.Result.str);
' I; z+ ~% {+ A  U& i2 a    axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝标记图像');
3 x" U; Z; o& P7 J9 O! C$ r    hold on;/ L1 Z" I- p! ?7 ?% ?3 E! O
    rectangle('Position', handles.Result.rect, 'EdgeColor', 'g', 'LineWidth', 2);' v1 Y" ?3 f: g: `7 E
    hold off;
4 {. H! z, r% n* I$ Zend
' L% `# X' A: O* S/ t5 R
" E' ^; j  p/ o5 X6 w4 D% --- Executes on button press in pushbuttonProject.
! b  R6 i6 Z; J) e( sfunction pushbuttonProject_Callback(hObject, eventdata, handles)
, q) ]* b/ O( f6 x% hObject    handle to pushbuttonProject (see GCBO)
5 x6 T  O8 a# r% eventdata  reserved - to be defined in a future version of MATLAB- l+ S' i- }% i0 Q7 E, T2 g0 D) b
% handles    structure with handles and user data (see GUIDATA): j) i3 ?+ t+ N' ?6 `: D
if ~isempty(handles.Result)
& D4 B3 i8 J& U" [- B    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');/ m0 T* l+ U5 N6 [9 ^
    axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');, C2 u* R/ d/ g3 y% S
    axes(handles.axes3); plot(1:size(handles.Result.Image, 1), handles.Result.Projectr);4 T, w4 d: G) U* [6 Y
    title('行投影');
# ^  y5 _  ]' B9 o  l4 _: C    axes(handles.axes4); plot(1:size(handles.Result.Image, 2), handles.Result.Projectc);; e1 e' J2 m( C! V. O. {
    title('列投影');3 |/ n: I0 S# ?. x
end
0 Y+ U# n! z% ], e 7 D7 U/ _* w/ ]; }$ R4 S
) b/ U" k( l. C' ~- k" y
% --- Executes on button press in pushbuttonClose.* k$ D* E9 k& ?( p% o/ q
function pushbuttonClose_Callback(hObject, eventdata, handles)
- f* ^. ~3 p% n% hObject    handle to pushbuttonClose (see GCBO)
# s6 s/ N; h' e3 y" j( ^* b) o! L% eventdata  reserved - to be defined in a future version of MATLAB
; t6 K" |) S8 ^+ |% handles    structure with handles and user data (see GUIDATA)( ?! C9 [* c* m8 h) ]$ P0 t3 b* k
choice = questdlg('确定退出?', .../ }4 j2 B- \, @' n
    '退出', ...
& j3 V8 F# q3 O* S    '是','否','否');, ^9 {3 s  c, x* z
switch choice2 J! ~# p) W' a, K+ v  @
    case '是'
3 U. I7 k9 k& f1 W7 s' |% H        close;4 }6 ^9 x+ k/ A7 T9 k) B' b: x
    otherwise
( B0 `( X  ?/ f+ r/ c. f6 j        return;
6 M; c- {( a6 |! E# Xend
8 T" A( P) R# o  ~$ S% L% P( S, O $ x- f( u+ P; D

- r' I( Z$ p; O4 A( L3 d$ M & K3 `2 G+ r5 c. p+ E, W
% --- Executes on button press in pushbuttonSaveResult.8 T! u. s( k3 F& W/ G5 @
function pushbuttonSaveResult_Callback(hObject, eventdata, handles)
. `9 G7 S+ [4 n1 |& [, H& L  m% hObject    handle to pushbuttonSaveResult (see GCBO)
; s  j/ c& v4 g( }5 P* S% eventdata  reserved - to be defined in a future version of MATLAB2 B1 c! E1 |* l: i3 o: F3 C- |2 r" d8 _
% handles    structure with handles and user data (see GUIDATA)& |4 G6 H7 ]% D8 m& R0 l1 t( F
try7 l4 _& {8 R. r
    if ~isempty(handles.File)- O. @. E. v! U& p
        raw = [];8 [( a8 ]+ Q  N" ^, }% {% C
        xlsfile = fullfile(pwd, 'Result/result.xls');9 X+ w7 n3 s' Q. n6 V  e$ x$ j# D$ `/ k
        if exist(xlsfile, 'file')* b: ~9 f8 L; v" C6 ^
            [num, txt, raw] = xlsread(xlsfile);0 W: g$ ]. ]9 V# `- R! w8 ~
        end3 F2 Q& X4 p* a9 v, t; O
        
( p" M: ^6 |' h: Z        F = [];
8 ]8 g$ ]: Z' ]" l, ?0 n( ?        F{1, 1} = '文件名';
1 n8 W3 X$ f* {, r0 n& {6 k) d        F{1, 2} = '阈值信息';* B2 [8 P3 ]/ V: m2 d
        F{1, 3} = '面积信息';
, @1 a0 j0 \" N        F{1, 4} = '长度信息';
8 ]  m4 t0 v0 ?1 _& W+ V7 [        F{1, 5} = '最大宽度信息';
8 B( x" N" N  z6 k) N        F{1, 6} = '最小宽度信息';6 A9 g% q( E1 |  m: Y0 x
        F{1, 7} = '形状信息';) j$ b5 e" I) h2 {, G& u
          X+ f7 R2 E. q# L0 j
        F{2, 1} = handles.File;# I* K3 N) D, m( j/ k6 C& w( n, \
        F{2, 2} = handles.Result.BwTh;
/ R0 r& Y6 r! B! g  I/ e. _        F{2, 3} = handles.Result.BwArea;
1 \, s  h/ W' t- x# b4 ^9 f        F{2, 4} = handles.Result.BwLength;* O1 Q# Q4 }8 m% j8 |
        F{2, 5} = handles.Result.BwWidthMax;8 z6 P4 F0 Q& z; z/ M9 Z
        F{2, 6} = max(handles.Result.BwWidthMin,0.01);* s9 q! |7 k: _, c
        F{2, 7} = handles.Result.str;
6 l" x! V# D; Z: B        ( n1 W' B- X4 D# |( a
        F = [raw; F];
# B6 `8 `4 V  t# i        xlswrite(xlsfile, F);7 u. U4 O9 X% N6 p
        ) H/ t- `2 P2 S
        msgbox('保存结果成功!', '信息提示框');
2 M! \. v8 Y3 f; r4 W- q    end; u3 |2 R5 [8 s3 B( X- z
catch' B% [" I; x! W5 Q
    msgbox('保存结果失败,请检查程序!', '信息提示框');, l4 @# D" A% Y; I) K
end
1 O& u; O0 D# i% l  b# T $ {! \" l$ `' _* {! p- m

% G: G1 y( y8 Y. g: i' ~% --- Executes on button press in pushbuttonBridge.
( j, j$ \( B" r" O0 |: @function pushbuttonBridge_Callback(hObject, eventdata, handles)) }% K9 k' a' r' l  Z4 N0 y$ m! A( C
% hObject    handle to pushbuttonBridge (see GCBO)- A/ m% j( |: S, z8 O# f2 s, s
% eventdata  reserved - to be defined in a future version of MATLAB
' O4 h$ D5 l2 y2 _9 m$ a% U# e7 n% handles    structure with handles and user data (see GUIDATA)' l6 h* U9 `  y) k0 j2 M' R
if ~isempty(handles.Result)5 O* A5 C1 P/ Q9 P
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');5 x7 j! \  u5 }  ~5 x
    axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');
+ T& W. I; ~; q0 |% e/ f# _    axes(handles.axes3); imshow(handles.Result.CrackJudge); title('裂缝判断');
/ X5 Z9 a( a# J6 `    axes(handles.axes4); imshow(handles.Result.CrackBridge); title('裂缝拼接');
+ P4 ?9 B0 J: L( zend3 N- M7 ~; m/ Q
; i: L5 t8 R, p$ ?% n9 b2 s

! t4 t5 u2 w: t3 `" t6 t* x- ]7 N( y% --- Executes on button press in pushbuttonSaveImage.
8 Z8 x4 U; d, w7 ]2 Y8 h- ^function pushbuttonSaveImage_Callback(hObject, eventdata, handles)0 K) @1 r6 W1 ~. M3 }: j( i1 ]0 ~/ X
% hObject    handle to pushbuttonSaveImage (see GCBO)/ N* w( F( j3 B! J- l4 {2 X! t
% eventdata  reserved - to be defined in a future version of MATLAB
+ Z8 v9 Q8 j3 L1 W5 }. @% handles    structure with handles and user data (see GUIDATA)/ W# U$ t! I+ Z7 ?
[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
0 J  t/ @3 P9 s& J& S    '*.*','All Files' },'Save Image',...
8 {1 U/ G! O- N9 n    fullfile(pwd, 'Result/result.png'));
* `* j% F# f  t  |+ Mif ~isequal(filename, 0)5 u1 u$ Z. `, B& c1 b( U/ b8 L
    imwrite(handles.Result.BwEnd, fullfile(pathname, filename));
& s: M7 N# s7 V! d" K$ U: g; w% A    msgbox('保存图像成功!', '信息提示框');5 w4 B# @# T! @" G' _& }9 g* L
end
8 Y. E) X/ u+ z5 q$ l* `; B
) b" k* ~9 Q& m8 j9 h6 d : V( E  m' a4 G$ ^3 H' K
% --- Executes on button press in pushbuttonDiplay.
1 F! h2 l& s0 b- r- O0 Xfunction pushbuttonDiplay_Callback(hObject, eventdata, handles)( [3 ~4 a% r7 H% s; ]! g- d& y
% hObject    handle to pushbuttonDiplay (see GCBO)
$ ~7 @) ^# X  S! e7 F9 x$ A; c% eventdata  reserved - to be defined in a future version of MATLAB
1 S; Q1 ~9 M7 {$ ?2 n- J9 g% handles    structure with handles and user data (see GUIDATA)
' d5 B& u2 O' b& Rif ~isempty(handles.File)
) ]. J3 F# v, \2 Z% i% }" A& L    F = [];
0 c* C  n- _5 R( t    F{1} = sprintf('文件名:%s', handles.File);6 Z- o+ F9 p0 O5 R3 U3 H$ z
    F{2} = sprintf('阈值信息%.2f', handles.Result.BwTh);
0 q' m; B7 ~5 n6 N3 D6 O    F{3} = sprintf('面积信息%.2f', handles.Result.BwArea);$ H( k# B; i, H# O9 K/ Y
    F{4} = sprintf('长度信息%.2f', handles.Result.BwLength);
. O( ^0 \7 k' V0 K" U- d+ E) b9 d' E    F{5} = sprintf('最大宽度信息%.2f', handles.Result.BwWidthMax);' z, x' u% _2 R9 [! g7 z  r
    F{6} = sprintf('最小宽度信息%.2f', max(handles.Result.BwWidthMin,0.01));& j1 ?8 u; ?7 t% r1 W& u
    F{7} = sprintf('形状信息%s', handles.Result.str);
7 B; e( q* m8 D! i/ S    listdlg('PromptString', '参数显示:',...
+ \' Q: K# G& X& w        'Name', '参数信息', ...
* C* t9 E$ Z* R* a        'ListSize', [300, 150], ...
. F' I+ J6 T% O# Y; t5 g        'SelectionMode','single',...: J+ U. y, m/ |  [) v: Q- F2 x4 K9 y
        'ListString', F);
1 |. a3 H# n& X; K8 X' }; Mend
0 d, N$ z' o, d6 m$ z: R8 t( G
. f# v4 i$ r( I; ?三、运行结果1 M& H+ ~4 h9 Q
/ \5 i- Y3 S: g
5 q6 `8 E. k5 \, U1 g

7 J* ^$ D! w$ z
; j0 O1 p% e, @4 }1 ~& E! S1 g2 M# s

该用户从未签到

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

本版积分规则

关闭

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

EDA365公众号

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

GMT+8, 2025-6-20 00:49 , Processed in 0.093750 second(s), 26 queries , Gzip On.

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

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

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