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

基于matlab GUI路面裂缝识别

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x

* a- h  T, I+ _2 Z6 Q! O一、简介7 j3 n) V, F& E8 g- E  H' f
高速公路路面病害养护和管理的重要部分就是路面裂缝的检测。近年来,路面裂缝自动检测技术已得到了广泛应用,而由于路面裂缝图像的复杂性,检测算法直接影响着检测结果的精确度。因此,本文将重点放在路面裂缝病害的检测上,为了提高检测的精度,分别从裂缝图像的去噪、图像的增强、图像的分割以及检测后路面裂缝图像的特征提取方面进行深入研究。  在路面裂缝图像中,由于裂缝信息与背景对比度偏低,难以将裂缝直接检测到。对于图像的预处理,首先对图像进行灰度校正,再对校正之后的图像滤波,本文提出了一种改进的中值滤波方法,对图像进行去噪,之后用基于模糊理论的图像增强原理对图像做进一步增强,有效提高了路面裂缝图像的对比度。  针对路面裂缝图像分割,本文分别用了阈值分割和基于形态学多尺度的思想,对于形状规则的裂缝采用的是阈值分割,对于裂缝形状不规则的图像,本文设计了一种多结构元素的抗噪型边缘检测算子,且依据不同形状的结构元素对裂缝边缘填充的几率不同,确定了自适应权重,使得算子检测到了各种类型的裂缝边缘,有效地提高了检测的精度。  对于经过分割后的路面裂缝图像中存在噪声和裂缝断裂的问题,本文对于断裂较窄的图像用形态学中的闭运算和开运算去处理,对于断裂较宽的图像,提出了一种基于生长的断裂裂缝块的连接方法。提高了连接的效率和准确率,使整个检测结果清晰完整。最终,从识别结果图中提取裂缝信息。根据得到的识别结果图,设定一系列判定条件,提取出裂缝的连通域,对裂缝的类型进行判断,最后计算出网状裂缝的面积及线性裂缝的长宽信息。
6 Y" o% _% p2 v- e( v0 D6 I) c1 W" A0 I/ i
二、源代码% B5 t- y4 Q9 O) w+ R
function varargout = Gui_Main(varargin)
' ~& A* `! c2 c% GUI_MAIN M-file for Gui_Main.fig
- w5 e5 P' a/ Q%      GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing* Z* w! H+ G: t* a
%      singleton*.
0 y- [% ^! R4 Q3 h& u%6 `: x# ^7 `) }7 H9 \
%      H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to2 b+ `1 `0 `) j
%      the existing singleton*.
7 F5 E* V+ e* j. E+ V! C) q- x%
" `1 O, Q, \0 j) F, v1 K%      GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
; H3 j) M; t1 \0 M: U+ l%      function named CALLBACK in GUI_MAIN.M with the given input arguments.
- Y( _- v! a: d8 m) g  G%
. G- n& u' {* J+ `) S# @" h%      GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the
5 U; I4 h, [# a" |  N+ l# M%      existing singleton*.  Starting from the left, property value pairs are7 g3 }/ s/ v+ F: N
%      applied to the GUI before Gui_Main_OpeningFcn gets called.  An, ?6 u' k; d/ Z- o4 z0 t  k
%      unrecognized property name or invalid value makes property application$ e) u; _5 o/ J7 j2 `& r
%      stop.  All inputs are passed to Gui_Main_OpeningFcn via varargin.' s, v, e* L% G& |8 }( M
%
4 D* @3 P) A# Q. y5 M0 R( h# Q  _! ]%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one( m: C: q4 ], e- `* w: x. U
%      instance to run (singleton)".
& O5 Y" ^% ]4 r$ k%
! m5 C0 K+ u7 c5 o' c4 b5 T% See also: GUIDE, GUIDATA, GUIHANDLES& U0 {  d0 {0 b1 w. S1 I1 J

% ~% D1 a8 ?/ V* Y& O% Edit the above text to modify the response to help Gui_Main- O& n9 s8 M$ m/ R2 R9 ^
% @( z8 S+ X( M+ _$ I: d
% Last Modified by GUIDE v2.5 29-Mar-2011 22:28:58
% h1 e1 |. o+ Y5 [  ]) ]6 N* _
, `1 n! y' J4 `! Z8 D# Y% Begin initialization code - DO NOT EDIT. {% o  t. D  X
gui_Singleton = 1;, H" C0 }# _2 q2 W4 `
gui_State = struct('gui_Name',       mfilename, ...4 L$ Q1 X5 h$ Z
    'gui_Singleton',  gui_Singleton, ...
1 l7 a/ l0 [( y    'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...& g* p4 ~5 I6 B6 u' ~( F9 n; H/ O
    'gui_OutputFcn',  @Gui_Main_OutputFcn, ...
4 I3 A' m& S6 o* ?    'gui_LayoutFcn',  [] , ...
1 J9 F' [6 ?* l# y1 {+ O; i$ ]    'gui_Callback',   []);+ ]1 L& J3 H4 _! v
if nargin && ischar(varargin{1})
+ R1 G% z. _4 l4 o. [& d5 ~    gui_State.gui_Callback = str2func(varargin{1});
6 s. H2 Q+ r3 |! z+ F7 `5 G& g* P+ Dend
4 k9 h! K4 f$ ^# M 9 q  n0 D+ s# P8 o1 m# p
if nargout
8 ^9 k7 j* Y5 K+ F5 J/ m7 I    [varargout{1:nargout}] = gui_maiNFCn(gui_State, varargin{:});2 c+ [7 X) p: u! Y. P! n+ P
else
. p2 w& g. D. B7 O# ?, c9 e    gui_mainfcn(gui_State, varargin{:});# r1 ^. [( X% S) W4 ^% {( a
end% B3 y, F) d$ e# z# l/ M$ B6 v+ I
% End initialization code - DO NOT EDIT
7 c( z, S2 F' ?  Q% `   Y/ h1 i4 z* t6 K

- Y9 r- M$ A! f+ \% --- Executes just before Gui_Main is made visible.
; b$ i4 o, ?8 {( w0 Z2 ]4 S' }; Rfunction Gui_Main_OpeningFcn(hObject, eventdata, handles, varargin)
- Q* E. X3 _4 [6 G; ?/ ^  ]( Z% This function has no output args, see OutputFcn.7 f: ?4 r1 I! m6 j! m
% hObject    handle to figure5 p) X$ V" t: L
% eventdata  reserved - to be defined in a future version of MATLAB" [6 T/ G% D# w$ q+ O
% handles    structure with handles and user data (see GUIDATA)" q, u; G$ ~7 y& x4 e
% varargin   command line arguments to Gui_Main (see VARARGIN)! g/ _: D. Q% z) c% U( B

  `0 [9 D8 T; w3 f7 O$ r" Z- n% Choose default command line output for Gui_Main' E2 {& Y( X! B1 w
handles.output = hObject;
( [: x& C' U9 {+ p* x3 ghandles.Result = [];
2 e4 k' Q+ s- O0 Qhandles.File = [];: Z: g1 U* U" Z8 g' L
% Update handles structure) I, k( u+ L! _, [0 b: \' ?% i
guidata(hObject, handles);: N5 S* x2 ]0 I) i. P0 I: L' i
clc; warning off all;3 B% `1 z3 E8 ~2 L/ f' _' C
InitAxes(handles);9 a9 y6 T7 @2 J3 h. @

! ?5 o, Q! w& u$ i: z% UIWAIT makes Gui_Main wait for user response (see UIRESUME)
& P$ n& q7 t8 ?) Z0 t% uiwait(handles.figure1);
% J3 a7 S! A# z5 h5 \) p ! Y* f. G; d) N2 x2 M( e
: [; d$ u3 \, a4 S- r8 D; X
% --- Outputs from this function are returned to the command line.
/ [- t9 j9 G' V% T& x8 Ufunction varargout = Gui_Main_OutputFcn(hObject, eventdata, handles)8 C% j0 m% P/ S7 _6 q  ]9 _1 T
% varargout  cell array for returning output args (see VARARGOUT);! F3 Y3 ]" W" y5 W0 P0 M
% hObject    handle to figure+ a3 i( y6 V7 L$ W: a' i
% eventdata  reserved - to be defined in a future version of MATLAB/ j( C/ ]# M+ m  r) [/ Q" ~5 g
% handles    structure with handles and user data (see GUIDATA)8 ]  Z4 u4 A$ v$ K3 W- P9 t

+ t2 L7 X6 A2 a3 i% Get default command line output from handles structure0 m$ u: N  u  E) R7 y0 d
varargout{1} = handles.output;
" `% E! N2 m# r& l& p( A: K 0 V& P7 `0 E/ W1 u

, T. B/ c/ Q1 B$ T, X& x0 M3 K/ j% --- Executes on button press in pushbuttonOpenFile.9 l% l$ s" t  Z3 Z+ B% ~/ G: v
function pushbuttonOpenFile_Callback(hObject, eventdata, handles)9 n* ~5 T; m5 V6 d3 y3 ?
% hObject    handle to pushbuttonOpenFile (see GCBO)5 W+ r/ c$ q- Z2 E1 w
% eventdata  reserved - to be defined in a future version of MATLAB+ a. I3 ^$ o7 W9 h8 q1 v6 d; u
% handles    structure with handles and user data (see GUIDATA)8 M5 i% b: I. Y( \8 E; K; X4 [
[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bmp','All Image Files';...
0 i. Z& \1 k# z4 {; }1 y    '*.*','All Files' },'载入图像',...
  W6 x; ]: P2 s) `    fullfile(pwd, 'images'));
- f* i( Q. I; k& V& Nif isequal(filename, 0) || isequal(pathname, 0)& p6 l  q* a) S0 c2 _9 Q9 @
    return;
' u; b9 c! B+ `/ L* t7 tend0 X; Z5 |4 y- E
I = imread(fullfile(pathname, filename));
2 ~, |' L) C5 S& U8 JResult = Process_Main(I);- D* F7 U- O4 _' f
handles.File = fullfile(pathname, filename);& u% x; \5 l! |  h4 b
handles.Result = Result;; F, u' `$ E  A
guidata(hObject, handles);
2 t4 z4 P) e* d: bInitAxes(handles)5 Z! x/ r7 z3 O* U: H
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
, L" l! Z4 y! y1 T4 k & J3 w  t7 s$ ^' u
1 e, V! ?! q2 t6 L+ |: |
% --- Executes on button press in pushbuttonHisteq.
. G. w/ L% V8 E$ [6 V6 O2 V0 S7 Y' \function pushbuttonHisteq_Callback(hObject, eventdata, handles)9 l: A( L7 ^. Q9 m
% hObject    handle to pushbuttonHisteq (see GCBO)" n: w, P2 S- \1 I  j
% eventdata  reserved - to be defined in a future version of MATLAB, j: S8 T1 A5 a/ s. V( o, ^
% handles    structure with handles and user data (see GUIDATA)
- T: r$ Y8 Z( H1 eif ~isempty(handles.Result)
2 S5 b7 t; G$ L  p2 O    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
( _$ v( M" v3 D2 h7 Q% C8 [    axes(handles.axes2); imshow(handles.Result.hist); title('直方图均衡化图像');% s9 \2 ]" p, M0 D; a9 ?( [6 |
end1 F/ o8 M# F' J: s/ h$ R* \

- W# s, x* R" ?* X. w ( E; D4 x* E" i( E% ~

8 ^0 B6 x+ v# Q; ]2 `# \2 A& C% --- Executes on button press in pushbuttonMedfilt.2 c- L) q4 u9 K( ]4 q0 A6 v0 c
function pushbuttonMedfilt_Callback(hObject, eventdata, handles): {% I9 a8 G8 Q6 }
% hObject    handle to pushbuttonMedfilt (see GCBO)# ?2 I3 ?9 \4 A+ @' I& l5 ^1 K
% eventdata  reserved - to be defined in a future version of MATLAB$ v8 v9 N: k* h/ L* A% z
% handles    structure with handles and user data (see GUIDATA)
5 J8 C& I5 V' I( N' iif ~isempty(handles.Result)) \1 _* c, k0 W, s8 d
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
; b$ Q& n3 T; }. `# h2 z    axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');
- L3 C1 K0 N2 S- w- C6 _end. k! I' X! b" O8 b& G, l
# v( `( S8 }$ Z
7 {! P6 |6 H# D. S; L
% --- Executes on button press in pushbuttonBw.
7 f+ g0 L  t( j0 X& N* G  |function pushbuttonBw_Callback(hObject, eventdata, handles)
7 q, @. G- M6 v% hObject    handle to pushbuttonBw (see GCBO)
0 ^9 \' b( F0 [: b; f% eventdata  reserved - to be defined in a future version of MATLAB0 v: v* W1 d! l$ o# I5 r& S
% handles    structure with handles and user data (see GUIDATA)( P3 u+ b5 U7 S! p' _+ i1 L1 I* n
if ~isempty(handles.Result)1 T; r6 u4 b8 w  D; P" B: J
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');; q1 J3 D3 f/ Z
    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');7 ^# A5 s) v6 R9 e8 I
end1 }( Y3 j# U1 \5 u

- O  H  Y4 i$ e& A6 T, d* k  f% --- Executes on button press in pushbuttonEnance.. j4 v# h' f: i+ @
function pushbuttonEnance_Callback(hObject, eventdata, handles)
" c) K: k5 q3 }5 S8 q% hObject    handle to pushbuttonEnance (see GCBO)
. \' ]/ A$ z7 Q! I: W% eventdata  reserved - to be defined in a future version of MATLAB9 l+ o1 N6 m9 d, N- J. E
% handles    structure with handles and user data (see GUIDATA)
, I( C. g% W8 t, _1 iif ~isempty(handles.Result)
7 G" e9 a) [8 A# K' g    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');' v! A( N$ ^) s1 @; W# F
    axes(handles.axes2); imshow(handles.Result.Enance); title('增强图像');
% S( X& m7 B0 T; T7 s0 e; x" ]end& H# _; J1 w$ N- A. s% q* ]1 ], f

6 P7 K" v, ]0 w% --- Executes on button press in pushbuttonBwfilter.* L6 m8 k0 z6 n7 s& A% B* n
function pushbuttonBwfilter_Callback(hObject, eventdata, handles)8 f, q  T8 ?8 P' K" Z  p3 v
% hObject    handle to pushbuttonBwfilter (see GCBO)
* J+ i2 ]( R8 |) e" G0 z& M% eventdata  reserved - to be defined in a future version of MATLAB/ u- R" V8 c- L$ a8 \! K
% handles    structure with handles and user data (see GUIDATA)( e( z' _. i7 N% i) e  V) t
if ~isempty(handles.Result)  q" Q2 a) q/ B( \  ?) [- i2 T
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');6 ~! P: U# e. l% x. ^5 ?$ V2 L
    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');
0 m% r3 k  K$ z1 s; d( Y% h    axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');! W, s9 u& a& ^5 `4 v. J
end
! }( P5 q0 i" x 8 Y, s$ C3 i1 N7 j' H' U
% --- Executes on button press in pushbuttonCrackRec.
% [: W) X2 a; m  K" u- Rfunction pushbuttonCrackRec_Callback(hObject, eventdata, handles)( I: }: X, X$ p7 \
% hObject    handle to pushbuttonCrackRec (see GCBO)/ I# v* L# ]/ l9 B- W
% eventdata  reserved - to be defined in a future version of MATLAB5 ^, N6 O, Q3 R1 l' ^8 t& F
% handles    structure with handles and user data (see GUIDATA)) x. S$ H  u( m# Y7 H5 R( R
if ~isempty(handles.Result)* y& _3 W5 R, N8 y6 e4 A
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');4 `, r# R$ t* i" M) I
    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');% X2 L. n8 `8 v  K6 B# ^: P
    axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');3 w- N6 m; ]% y' \( T# _
    axes(handles.axes4); imshow(handles.Result.CrackRec); title('裂缝识别');7 \4 C1 t% w* H) V- R
end
5 ^3 y! O) C% ?  C4 _0 K ( E# S3 v/ S1 d9 S% l
- s. K. s9 l7 X
% --- Executes on button press in pushbuttonCrackJudge.
& q: ?4 S  U0 G% L* e8 x9 |8 pfunction pushbuttonCrackJudge_Callback(hObject, eventdata, handles)$ W7 p& S$ ^' s! p9 }0 I3 f
% hObject    handle to pushbuttonCrackJudge (see GCBO)
# T* F) J# A( Z4 j6 U3 @% eventdata  reserved - to be defined in a future version of MATLAB
* j' G( d: |8 b+ w* \7 Z% handles    structure with handles and user data (see GUIDATA)! Q0 ]0 }+ \: r( y" _
if ~isempty(handles.Result)( w9 p+ Z) D0 h" A2 ?7 t2 U
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');  q2 |: S  }2 H+ r. E$ W
    axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');
( ?9 R7 [6 M" r+ l    axes(handles.axes3); imshow(handles.Result.CrackRec); title('裂缝识别');9 C) \+ M/ {4 b0 B8 j: v
    axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝判断');. L' B: t! a1 l" r, q
end
4 _1 G0 C% O# c ; m* ]+ a. i% M: @  ^$ }5 g- y1 Z9 j
% --- Executes on button press in pushbuttonCrackLoc.* }  U3 y* O+ w
function pushbuttonCrackLoc_Callback(hObject, eventdata, handles)9 b7 L5 ?; N+ H7 ]5 Y/ \
% hObject    handle to pushbuttonCrackLoc (see GCBO)3 m% B) S0 Y: I9 K% m$ A# q
% eventdata  reserved - to be defined in a future version of MATLAB0 R% A! E. L3 s. |7 M% u. k
% handles    structure with handles and user data (see GUIDATA)( y; C$ E+ K9 ?7 H8 K8 M0 h3 u
if ~isempty(handles.Result)1 O/ j7 C' A2 e( t; l( ]0 N
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
, c7 a5 k/ a. L- W0 N' G    axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');
9 h) Q# m8 [, U) b9 M4 r# z    axes(handles.axes3); imshow(handles.Result.CrackJudge); title(handles.Result.str);
! u- N( Y  ?$ ?' N$ e8 [5 }    axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝标记图像');7 c: I) f  v6 T+ Z1 i3 j. {. F* l
    hold on;
% G# b2 N* J# \$ e. Y; W1 ^    rectangle('Position', handles.Result.rect, 'EdgeColor', 'g', 'LineWidth', 2);
1 ]* I9 g, P# Z4 z+ z4 e# @5 `) ^    hold off;
* {9 M& s" A) Y9 k% n2 L; }/ u5 Qend
, [1 q, D# Y' J3 O; @
( h' j/ v6 {5 z! |! r& O' E% --- Executes on button press in pushbuttonProject.
$ T4 M; M: G1 t) D; ifunction pushbuttonProject_Callback(hObject, eventdata, handles)
; k1 \6 u/ t% j0 u* L5 C* P% hObject    handle to pushbuttonProject (see GCBO)0 E3 v; _2 v2 m
% eventdata  reserved - to be defined in a future version of MATLAB
- P6 k) U& a# B% handles    structure with handles and user data (see GUIDATA)
, q; O- C8 r' v; `. ?6 l* m( Qif ~isempty(handles.Result)- [; A3 R; g* w% l0 K
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');9 _# j1 Y, ?7 n% Z: v! R' ]
    axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');
; D, y2 v0 w/ e" m. a    axes(handles.axes3); plot(1:size(handles.Result.Image, 1), handles.Result.Projectr);
$ f' |6 u( g1 }% m) K    title('行投影');7 W7 u- N1 u, h- P- W+ a
    axes(handles.axes4); plot(1:size(handles.Result.Image, 2), handles.Result.Projectc);
; A" V+ ^8 c' P    title('列投影');
2 W# K8 h" s4 J0 ~9 I6 s2 }  V! Bend
$ ?% Y0 o$ k  g, \/ }% i
/ `1 q) ?2 l/ v
3 C# ?" ~9 U& m0 \9 X6 k% x. y0 {% --- Executes on button press in pushbuttonClose.
/ h& q2 ~+ D: a1 U/ Z) ^function pushbuttonClose_Callback(hObject, eventdata, handles)6 G7 S, ~: m* M4 A  \  D
% hObject    handle to pushbuttonClose (see GCBO)5 x' N& H) F9 ?. U# W$ r) z
% eventdata  reserved - to be defined in a future version of MATLAB
1 f& f) p, ?1 A2 p$ Q- M% handles    structure with handles and user data (see GUIDATA)
4 ?/ b% Q# P$ ~. g1 j, Tchoice = questdlg('确定退出?', ...6 H' i5 Z" u" k  l" Y$ k
    '退出', ...
  f+ q- I5 T. p# E% i) e    '是','否','否');
* ]7 m; y3 Q0 M" {& eswitch choice, C+ Y, l- f9 O0 A4 h
    case '是'9 O7 s. M4 p# b/ u5 m  O
        close;
" @- }5 T% n) B" x4 R. _- ^1 K    otherwise
( l- t! `6 _* n2 \8 X        return;
5 I4 `: O6 M, f* v, `end  N0 }0 y& T$ b2 T2 ^

3 A$ X) r2 }$ t2 d ! f9 I* U# ^  W8 h
4 w6 X0 U+ t% ~, o
% --- Executes on button press in pushbuttonSaveResult.$ U1 t; \* X# m) s
function pushbuttonSaveResult_Callback(hObject, eventdata, handles)- [0 y! _# y/ p4 N, P
% hObject    handle to pushbuttonSaveResult (see GCBO)( l- v. }$ [, M% c$ ^
% eventdata  reserved - to be defined in a future version of MATLAB
6 A0 F4 A! X1 i3 t$ L% handles    structure with handles and user data (see GUIDATA)( Z# r( n0 I8 Y) S5 w
try
6 ?8 u0 x: w. v3 v$ V    if ~isempty(handles.File)
9 U2 @# V! ~3 B# Q- \( C        raw = [];& {' x$ t0 p4 {6 i& O
        xlsfile = fullfile(pwd, 'Result/result.xls');( I) r" `% z! Z) J
        if exist(xlsfile, 'file')0 E! W5 f8 C2 {6 y( h# ^2 j; i0 Z
            [num, txt, raw] = xlsread(xlsfile);0 G7 Y0 N4 k( C6 V  [6 f- p6 L. N
        end
+ M7 _; v& J+ S# Q2 ~  u% N2 q9 \  d        * I) p8 L, x" E* h; D" J! G$ ]
        F = [];# z5 r5 O4 b: w( [2 P$ }
        F{1, 1} = '文件名';
5 U( |- r6 |2 J7 B0 R6 P        F{1, 2} = '阈值信息';# P% ^( C3 Y& }) w- f
        F{1, 3} = '面积信息';" D# w4 s4 Q- W/ B
        F{1, 4} = '长度信息';" b; B( o: _' C/ Q4 ~1 Q) l& E7 h
        F{1, 5} = '最大宽度信息';
5 a" ~9 P+ N) c/ V4 G8 t        F{1, 6} = '最小宽度信息';& E" |2 u( h. y) q7 S5 ]7 y
        F{1, 7} = '形状信息';0 |% w, \* [( S( Q' A4 O
        
) O7 C6 j( d: D0 t. q4 E! c( z/ D- V2 B        F{2, 1} = handles.File;8 t: ?: I: |+ F" N/ N. X  y
        F{2, 2} = handles.Result.BwTh;5 v/ }* f- X) p$ a, W6 e( a! V6 m
        F{2, 3} = handles.Result.BwArea;- D$ Q) Q9 }# t. h
        F{2, 4} = handles.Result.BwLength;  n# a) r/ |4 ?) V; I
        F{2, 5} = handles.Result.BwWidthMax;
6 A- K8 ]8 N  e        F{2, 6} = max(handles.Result.BwWidthMin,0.01);
* g$ |: M; r1 \2 \        F{2, 7} = handles.Result.str;
' f, _1 e( o4 j1 L: Y        
( J+ f8 j# _8 M        F = [raw; F];
8 H8 C, N4 C, P. m6 g        xlswrite(xlsfile, F);
: h: q% B0 K7 R4 r+ d. l" ^        ' f2 O. H/ {9 U* o6 X- E9 o5 l$ _3 ^( Y
        msgbox('保存结果成功!', '信息提示框');1 E5 }! z* G8 `/ @% |5 u
    end
8 O8 O9 u3 H3 [" g  hcatch
" f8 {' a/ l. n    msgbox('保存结果失败,请检查程序!', '信息提示框');$ n3 l6 f6 Q1 b- c
end! R0 G5 d. L( u! I/ A- o. ^/ i

" f# {0 ]  o( i. m8 |* f/ L2 R
% Q# E8 N$ k$ W1 X9 I. l% --- Executes on button press in pushbuttonBridge.. c" [7 C1 I  E' K. O
function pushbuttonBridge_Callback(hObject, eventdata, handles)
. J( a; z; {3 [7 L* I. Q% hObject    handle to pushbuttonBridge (see GCBO): y: [5 @, W' j/ r
% eventdata  reserved - to be defined in a future version of MATLAB- D: i6 u7 F( M1 W; J2 G
% handles    structure with handles and user data (see GUIDATA)
( m8 y9 t9 z( z. qif ~isempty(handles.Result)
2 p" j! S) f3 g  M    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');" G7 ?8 _' h& M  J
    axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');
! ]3 T5 A: d" _9 h! ]/ t8 Z    axes(handles.axes3); imshow(handles.Result.CrackJudge); title('裂缝判断');# r$ [& D! K" L2 ]
    axes(handles.axes4); imshow(handles.Result.CrackBridge); title('裂缝拼接');8 a% h' y; e( t/ Z
end. v  J/ C9 H3 j1 P& i2 _

3 U( J$ F& G; B, B
% `- |( L& }# R, H% c) o% --- Executes on button press in pushbuttonSaveImage.) [+ r) m3 ~4 [6 \# j
function pushbuttonSaveImage_Callback(hObject, eventdata, handles). \& x' V' e7 j
% hObject    handle to pushbuttonSaveImage (see GCBO)
. ~9 f& i+ L3 u% eventdata  reserved - to be defined in a future version of MATLAB+ U# h' D# X: E8 e% G
% handles    structure with handles and user data (see GUIDATA)/ ^* \. d, L" `# ^3 b2 w
[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...( T' g. H$ z4 z0 j. X) S: c
    '*.*','All Files' },'Save Image',...- A# S4 M& z/ O9 l& x: e
    fullfile(pwd, 'Result/result.png'));
/ ?0 a4 X* _% L7 Tif ~isequal(filename, 0). l7 I8 |$ x. y* I, |5 e
    imwrite(handles.Result.BwEnd, fullfile(pathname, filename));
" q& o  j1 c8 r- g5 h    msgbox('保存图像成功!', '信息提示框');
$ N$ E  K9 L: Jend1 V9 S6 }, b# ?; w7 ~
9 K4 r8 S# [$ _" i7 \2 Q( M
  ?/ s, k7 I; g& ~: t/ v. u
% --- Executes on button press in pushbuttonDiplay.
$ |' M4 b- Z) s. A# nfunction pushbuttonDiplay_Callback(hObject, eventdata, handles)! B& P/ C! C3 G1 p
% hObject    handle to pushbuttonDiplay (see GCBO)1 R: c1 L; U0 ?. e' L: `3 d# H0 [
% eventdata  reserved - to be defined in a future version of MATLAB( O$ m' z9 W4 V3 F1 l3 z: `. p
% handles    structure with handles and user data (see GUIDATA)
$ m* x9 V0 ], p- M) w& lif ~isempty(handles.File)7 d2 n( F' f: l
    F = [];8 \/ R( Z9 z8 }% N
    F{1} = sprintf('文件名:%s', handles.File);
8 I8 [, Y6 j5 I& d) @    F{2} = sprintf('阈值信息%.2f', handles.Result.BwTh);. m* Y! z6 H2 A. l# s; U3 p8 h
    F{3} = sprintf('面积信息%.2f', handles.Result.BwArea);
/ Z, @, \: _4 p3 h2 T: J4 w    F{4} = sprintf('长度信息%.2f', handles.Result.BwLength);. O; s& U' n* M: f5 J% Y1 \( z" v
    F{5} = sprintf('最大宽度信息%.2f', handles.Result.BwWidthMax);8 o9 o' |1 }( y
    F{6} = sprintf('最小宽度信息%.2f', max(handles.Result.BwWidthMin,0.01));7 ^! o, `8 b4 o  N
    F{7} = sprintf('形状信息%s', handles.Result.str);/ m# A+ H! J: O% F/ J
    listdlg('PromptString', '参数显示:',...
+ `# y) z. ?& T6 p; J- k        'Name', '参数信息', ...
2 D) _( h) b" X5 a4 z+ T        'ListSize', [300, 150], ...4 L: J- M3 q; ?# d  x2 L! d
        'SelectionMode','single',...
5 x8 u1 p  S( k' L8 n$ j' ?2 N! B        'ListString', F);
1 |6 k9 I3 S4 f/ o$ F$ wend
8 m7 R' q3 I% ^% ^7 t" }/ P; G: n3 J" v
三、运行结果0 j( h# m2 \7 f. w# X

7 l) A( Z9 g! a2 I" p7 }* R% z ! @  a0 a- z# ~; d0 b$ e, w

+ y2 O* m/ I# p3 v2 r
* r8 U. P% s" t% E0 p+ m
- L+ m  {- l) B) _  r/ X

该用户从未签到

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

本版积分规则

关闭

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

EDA365公众号

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

GMT+8, 2025-10-30 13:57 , Processed in 0.156250 second(s), 27 queries , Gzip On.

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

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

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