|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
" ]% i D8 e- f8 K" v" l8 }! G+ _
一、简介
* {; @: ~7 I0 C' J. m* e* s高速公路路面病害养护和管理的重要部分就是路面裂缝的检测。近年来,路面裂缝自动检测技术已得到了广泛应用,而由于路面裂缝图像的复杂性,检测算法直接影响着检测结果的精确度。因此,本文将重点放在路面裂缝病害的检测上,为了提高检测的精度,分别从裂缝图像的去噪、图像的增强、图像的分割以及检测后路面裂缝图像的特征提取方面进行深入研究。 在路面裂缝图像中,由于裂缝信息与背景对比度偏低,难以将裂缝直接检测到。对于图像的预处理,首先对图像进行灰度校正,再对校正之后的图像滤波,本文提出了一种改进的中值滤波方法,对图像进行去噪,之后用基于模糊理论的图像增强原理对图像做进一步增强,有效提高了路面裂缝图像的对比度。 针对路面裂缝图像分割,本文分别用了阈值分割和基于形态学多尺度的思想,对于形状规则的裂缝采用的是阈值分割,对于裂缝形状不规则的图像,本文设计了一种多结构元素的抗噪型边缘检测算子,且依据不同形状的结构元素对裂缝边缘填充的几率不同,确定了自适应权重,使得算子检测到了各种类型的裂缝边缘,有效地提高了检测的精度。 对于经过分割后的路面裂缝图像中存在噪声和裂缝断裂的问题,本文对于断裂较窄的图像用形态学中的闭运算和开运算去处理,对于断裂较宽的图像,提出了一种基于生长的断裂裂缝块的连接方法。提高了连接的效率和准确率,使整个检测结果清晰完整。最终,从识别结果图中提取裂缝信息。根据得到的识别结果图,设定一系列判定条件,提取出裂缝的连通域,对裂缝的类型进行判断,最后计算出网状裂缝的面积及线性裂缝的长宽信息。
8 U/ h+ m( B0 \* ]6 D6 K) j0 _: a" R3 }
二、源代码
0 U0 U3 ~- O/ }function varargout = Gui_Main(varargin)
, E( F$ R, N9 Y# i$ l% GUI_MAIN M-file for Gui_Main.fig' n6 d3 |' K) q6 |9 J) T
% GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing
& _2 s7 k* i( G7 a5 B+ Y! I8 B% singleton*.
: u! Y! L* C1 z% a%
# H# {* g# M% C" t! ]- k& M% i& M& Z% H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to v) N7 ]& j( K
% the existing singleton*.
# a- n$ e; j2 R" c% U; Z%2 n9 R) V3 E- C3 B3 l9 S
% GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
' ?$ x! M3 s6 m. u. W% function named CALLBACK in GUI_MAIN.M with the given input arguments.0 i/ N) f) I$ l( G" @7 G
%! b2 {* g& A0 ]1 j8 O
% GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the8 N0 [7 [# i# T: K' a$ w/ k
% existing singleton*. Starting from the left, property value pairs are
% M8 f1 Q9 v9 e" S% applied to the GUI before Gui_Main_OpeningFcn gets called. An6 L7 Q% a! j* L& i, T+ d+ e" v; [
% unrecognized property name or invalid value makes property application& u" f# |! [- f2 B4 v
% stop. All inputs are passed to Gui_Main_OpeningFcn via varargin., D. z/ Y! v5 n* L
%
, z8 J& t3 P1 M, m7 E( O% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
, B u7 [8 G( V$ e* ~8 @2 n% instance to run (singleton)".
! X# _5 z/ J/ y2 g" G* W" ?& E%
+ A' Y+ C/ P) Y, }, c# F% See also: GUIDE, GUIDATA, GUIHANDLES
7 K$ {; p: s2 j; ~9 _
& i3 m4 D4 @! K% Edit the above text to modify the response to help Gui_Main4 }1 E" N. ^7 S' b
8 c$ ~6 `9 e9 x: W: H4 l
% Last Modified by GUIDE v2.5 29-Mar-2011 22:28:58
& A6 f% ?( @2 h/ B0 Q2 t/ i; f) z ' Z5 z, Y) Y! u
% Begin initialization code - DO NOT EDIT
) z6 {6 D& K: G! C3 Q' w5 Egui_Singleton = 1;
% A3 l! Y! O: p3 o+ W- {gui_State = struct('gui_Name', mfilename, ...0 _7 Y4 B1 |/ `: ?
'gui_Singleton', gui_Singleton, ...
# p5 B) ~, e# t 'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...
5 g* j' W3 U0 m j+ ` 'gui_OutputFcn', @Gui_Main_OutputFcn, ...
# R7 J6 j6 [! ?) u 'gui_LayoutFcn', [] , ...
0 I8 }& m# c% d) U4 e& B 'gui_Callback', []);4 R& T ^ f! h; Z0 g+ \: y2 o
if nargin && ischar(varargin{1})
" b. m1 ]3 N4 A1 I' x0 b" V: L gui_State.gui_Callback = str2func(varargin{1});
8 P: G! f+ F1 V- wend
+ n8 Z6 }. y( T# q. T
8 } y+ K4 @+ _% Qif nargout; G3 r8 f. t8 p% \: X# t% X% \
[varargout{1:nargout}] = gui_maiNFCn(gui_State, varargin{:});
% e7 X6 i' Q! m0 n1 [& Xelse
- G9 ?0 B9 E* i' t: b. s* R& s gui_mainfcn(gui_State, varargin{:});
- }7 S+ ~ S+ ~% o7 K" Rend- u( K+ q+ O8 q) A1 `4 D x
% End initialization code - DO NOT EDIT8 P* [" A2 [; J5 P3 e6 }
& E* U$ _* n. }1 _9 p
0 _5 T! m" H7 }% ?4 P5 u! H
% --- Executes just before Gui_Main is made visible.
0 X# X8 h4 m, o9 Ufunction Gui_Main_OpeningFcn(hObject, eventdata, handles, varargin)/ R) b b# S: t- H# i( j& [ y
% This function has no output args, see OutputFcn.0 g. ]0 n1 N, I- t3 G3 j1 Y
% hObject handle to figure6 L& i0 Y; g- s" J% J4 s- w0 G
% eventdata reserved - to be defined in a future version of MATLAB& x+ s* W4 e' \
% handles structure with handles and user data (see GUIDATA)
( c+ I7 M) r+ p0 W- G% varargin command line arguments to Gui_Main (see VARARGIN)
% y1 [, m0 N8 |/ ]3 ]# o* \3 a 4 }3 R1 _9 a1 a4 T
% Choose default command line output for Gui_Main& Y" y3 ^' Y1 J5 z1 R, K; r
handles.output = hObject;
& z# x( q! e3 I4 j/ z, P, E" [% B0 ^handles.Result = [];0 k+ |) E6 Y# U- `! z
handles.File = [];
+ F- r% A4 R0 \; r. f9 S/ [% Update handles structure
5 m; z9 o5 K/ I' ~# T8 wguidata(hObject, handles);0 n3 h* g8 R3 _( N9 E
clc; warning off all;$ g4 i ^# D, D- ]0 I
InitAxes(handles);" K4 K( t. {* M. d3 S
. _9 O2 @, }" I, m' J7 e! \& e% UIWAIT makes Gui_Main wait for user response (see UIRESUME)
, y- m ~" Y2 t2 ^# O! ~% uiwait(handles.figure1);
! x3 N9 B4 I5 s9 ^ 5 y$ B1 s* i8 w
3 N, P8 X( R8 ?( `9 }( ~, c1 F
% --- Outputs from this function are returned to the command line.
( E# o& l: o M9 v/ K8 bfunction varargout = Gui_Main_OutputFcn(hObject, eventdata, handles)
8 p" u& u/ k0 Z* q! B0 r8 m8 _% varargout cell array for returning output args (see VARARGOUT);8 d* G w% s* L; h% C5 a
% hObject handle to figure
% E3 S# `! u1 Q! o+ _% eventdata reserved - to be defined in a future version of MATLAB
' }4 C% r0 Z3 ?! }% handles structure with handles and user data (see GUIDATA)
7 ]! Z& O0 W. v5 J( L" ]1 g, Y 0 c( ^/ F# Z7 S3 N/ ^ R! m% @$ A# z
% Get default command line output from handles structure
5 t& f z0 ^+ u1 F# ?# y$ R, Bvarargout{1} = handles.output;0 [3 w: o" w0 G* h% S+ J
9 @7 {& W1 \, P2 f0 w( J6 h; X9 r , B& Q7 P4 ]+ \1 K
% --- Executes on button press in pushbuttonOpenFile.0 i# ?% d) |* E J' x2 w, Z$ A" h
function pushbuttonOpenFile_Callback(hObject, eventdata, handles)
. [; [6 d) s" y+ w ^' W% hObject handle to pushbuttonOpenFile (see GCBO)
O8 O* L* T3 v7 a2 c% eventdata reserved - to be defined in a future version of MATLAB+ X2 K( }3 E1 ?% c6 y7 T5 K& A
% handles structure with handles and user data (see GUIDATA)
! U/ G$ s ?8 c; {4 W[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bmp','All Image Files';...- R z. @/ G( w0 _; F
'*.*','All Files' },'载入图像',...
3 z, M* x, y5 `6 z P' e fullfile(pwd, 'images'));9 q6 \, x: y& f& k
if isequal(filename, 0) || isequal(pathname, 0)* j2 m2 A" e; `; l+ s
return;
/ c' u3 B4 n5 s1 vend* M& v% A! ~! K; g, t' P6 l
I = imread(fullfile(pathname, filename));
A9 G; M4 g6 g0 P* ~# j `+ JResult = Process_Main(I);: D- @3 J! m. I
handles.File = fullfile(pathname, filename);' u4 H P: X1 O+ `) y
handles.Result = Result;
& j4 e; h9 u( l* M& o3 @guidata(hObject, handles);3 a. z, F) x' T. R- e4 w
InitAxes(handles)3 e% |# {# r: \4 j( I/ _
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');3 u ~/ O& o& d
! S, Z# ?& G6 [4 u/ V0 \
$ @. O/ C8 \$ ^" X, Q% --- Executes on button press in pushbuttonHisteq.0 q/ b# n$ O0 O( @5 f" |
function pushbuttonHisteq_Callback(hObject, eventdata, handles)! b! p, R# Y/ w
% hObject handle to pushbuttonHisteq (see GCBO)+ w$ B; n0 v0 }, F. J- F) A6 R
% eventdata reserved - to be defined in a future version of MATLAB+ I7 N+ r/ \' C8 G2 B+ @( p) [
% handles structure with handles and user data (see GUIDATA)
( P* x: C: m: ]8 o/ ~if ~isempty(handles.Result)
1 K. M; [+ s% v9 S0 D axes(handles.axes1); imshow(handles.Result.Image); title('原图像');, x o2 B5 c# O& M
axes(handles.axes2); imshow(handles.Result.hist); title('直方图均衡化图像');
0 [1 d2 J- G$ Dend/ _1 E. x0 z9 n! T/ `2 Y, M2 | C2 p2 n
3 q( e" s0 ~8 o1 G& C$ g
0 l0 F6 m* p$ J# w. ^8 f ) R7 k! j6 h' Z$ u, f* E6 x% l
% --- Executes on button press in pushbuttonMedfilt.
6 `% {( o1 W* a; F# o3 \; ifunction pushbuttonMedfilt_Callback(hObject, eventdata, handles)
* t0 l. g' x7 N; {# N) _% hObject handle to pushbuttonMedfilt (see GCBO)# w: Z+ ]! Y8 b9 t. z
% eventdata reserved - to be defined in a future version of MATLAB
' a9 f- k4 s) h9 V: C% handles structure with handles and user data (see GUIDATA)
0 w, q' s4 U& Wif ~isempty(handles.Result)
$ M- i" G6 ?$ U axes(handles.axes1); imshow(handles.Result.Image); title('原图像');$ e: h& W; A/ A) A6 H# n% H/ f" X
axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');
- s3 X: p0 E# I1 D, iend
& X$ r# W; B' Q9 ]# N+ T
' r$ k" N! x- m4 ^
8 P" V/ V4 A) q% B1 H/ e. g3 v% --- Executes on button press in pushbuttonBw.. c. P% _( v8 p
function pushbuttonBw_Callback(hObject, eventdata, handles)
4 r) d6 F! j# B% hObject handle to pushbuttonBw (see GCBO)
2 C$ Q( _8 e* i. _) k* S% eventdata reserved - to be defined in a future version of MATLAB/ U# J8 Y% B, R' e% O5 N; X5 ~
% handles structure with handles and user data (see GUIDATA)" [5 ^( ~1 I0 @4 N# g
if ~isempty(handles.Result)
- N, F0 g) X. ~7 n8 c$ w; _5 V" n axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
1 ^+ o6 z' c' O4 W7 I. U h: v axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');9 ]" a/ X7 l* z# ?/ t/ k
end
- |7 t1 G1 B7 Q8 Z4 u6 _% j
9 s$ m$ b8 l+ ^% --- Executes on button press in pushbuttonEnance.
; U! Z& {! w' T: X1 `function pushbuttonEnance_Callback(hObject, eventdata, handles)
* Z! @5 r0 m# t/ b% hObject handle to pushbuttonEnance (see GCBO)3 l% C$ ?2 b* b* { w% c: |2 E$ c7 r
% eventdata reserved - to be defined in a future version of MATLAB
5 {$ Q, E' L7 v- t5 `8 C% handles structure with handles and user data (see GUIDATA)
% @3 J2 \4 G% m$ S3 S; X. L% nif ~isempty(handles.Result)) z, k& l. e8 l$ |2 A; I4 x
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
- ] S- X5 ?) O" v, p2 y) Y axes(handles.axes2); imshow(handles.Result.Enance); title('增强图像');
8 Q( {/ _0 u8 L% a! M; Z w( j/ Kend& F( Y3 H7 F) k9 f
$ U) _6 O9 y9 ]: o2 Z
% --- Executes on button press in pushbuttonBwfilter.# Q2 A g$ i8 S
function pushbuttonBwfilter_Callback(hObject, eventdata, handles)
+ r, v: \# @# s% hObject handle to pushbuttonBwfilter (see GCBO)
3 B' v8 }& |7 B8 n% eventdata reserved - to be defined in a future version of MATLAB
' t- Z4 Z- E# O* }5 T( u; A% handles structure with handles and user data (see GUIDATA)% A: @2 k3 D( {+ A
if ~isempty(handles.Result)
; r, r* c# I6 d4 |' x axes(handles.axes1); imshow(handles.Result.Image); title('原图像');& N/ ?0 \9 Z G: o% ?2 S/ ?
axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');
! c! Q5 M1 ]- I0 s% L! s& r axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');
+ Z; n |# h8 z9 @' q1 tend
+ r" j1 Q( L* K8 }
* L4 s1 r& ~, F2 f9 e3 d% --- Executes on button press in pushbuttonCrackRec.6 {) @5 H' v+ M5 b# _5 G9 n1 A
function pushbuttonCrackRec_Callback(hObject, eventdata, handles)3 p" u/ ^ b7 U4 X2 P$ D
% hObject handle to pushbuttonCrackRec (see GCBO)
, o; {7 _/ I x! ^% eventdata reserved - to be defined in a future version of MATLAB
# Z, n; D! Y K- m2 @% handles structure with handles and user data (see GUIDATA)
: t6 H, M& y# X6 v! ?if ~isempty(handles.Result)1 O2 a& \' s$ E! M1 @% T8 ?
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
$ v2 u: O# d- H% M3 | axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');
3 W3 g- N2 Z9 D/ ]! O' R5 K- d/ { axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');
* K4 S- H" d. T& K; Q; U# |6 S axes(handles.axes4); imshow(handles.Result.CrackRec); title('裂缝识别');2 ?- A: B& C* m0 `2 Z
end
: y3 @( c9 e _8 m3 M; r 8 G1 i% Z3 D# z2 Q5 j9 _3 p. H6 F
8 M8 w+ w& P9 L! }7 B
% --- Executes on button press in pushbuttonCrackJudge.
9 h3 D8 F: v" Xfunction pushbuttonCrackJudge_Callback(hObject, eventdata, handles)5 x+ @3 Z) H5 ?+ f% R7 I
% hObject handle to pushbuttonCrackJudge (see GCBO)' V5 t" S+ m/ j
% eventdata reserved - to be defined in a future version of MATLAB1 t; F: k6 K {8 ?; T& {" E. n' Y
% handles structure with handles and user data (see GUIDATA)# p9 M* @1 k0 A
if ~isempty(handles.Result)! n% V0 M2 k' N3 C% q
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
7 H( k2 |- ^" _: J) O. n' V* ` axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');
z, q1 F7 o' m/ N- w/ T axes(handles.axes3); imshow(handles.Result.CrackRec); title('裂缝识别');
+ b' p+ Z2 K% a: u' a/ \ axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝判断');
/ T! K. Y8 ?0 q/ |* W( d* N8 M! ?# _end
; f( e d K+ L/ O* ~
' U; g( K" K! K& V$ P6 _% --- Executes on button press in pushbuttonCrackLoc.' D+ S9 [1 \1 ^5 A _& o3 d
function pushbuttonCrackLoc_Callback(hObject, eventdata, handles)% W, W' a8 [: K, d% b1 b5 l
% hObject handle to pushbuttonCrackLoc (see GCBO)
, g! u1 |+ ^$ p5 i+ u* g% eventdata reserved - to be defined in a future version of MATLAB( U6 V% i8 h$ X7 y! a4 P7 g1 _
% handles structure with handles and user data (see GUIDATA)" c, F9 R3 M, a0 l8 I! `
if ~isempty(handles.Result)
/ J1 Y0 M2 u; t k6 G' x v' E axes(handles.axes1); imshow(handles.Result.Image); title('原图像');: f1 l3 s' {- B( c+ J' [
axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');: I9 g5 q" b) H0 h @/ H
axes(handles.axes3); imshow(handles.Result.CrackJudge); title(handles.Result.str);) x" w9 L" J8 W/ p# S/ [; h- f: [
axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝标记图像');- o8 d" D& D/ F1 r" ~
hold on;
* ]) K( f: U9 l rectangle('Position', handles.Result.rect, 'EdgeColor', 'g', 'LineWidth', 2);
; {" o% N5 y, P+ L) [2 {5 D' ?( j hold off;
# F Z w. q& p6 S3 p' vend
6 {+ C" y, X: I1 K* H9 B+ b
* i. K/ c; o0 u3 F# i- f/ H4 W% --- Executes on button press in pushbuttonProject.! b) e! e0 i7 O* J6 L2 r
function pushbuttonProject_Callback(hObject, eventdata, handles)7 H" i- p9 x$ U+ X; i/ {: ?
% hObject handle to pushbuttonProject (see GCBO)( {# }# \# o. K# K
% eventdata reserved - to be defined in a future version of MATLAB5 B3 s0 N% m7 ^
% handles structure with handles and user data (see GUIDATA)
5 Q0 }' p9 s( a; c% C' {if ~isempty(handles.Result)
; Z* ^% f: Z6 f# _+ ~5 _5 Y* O axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
I& G) F* J% A# b' F) ^2 } axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');
- K9 g$ @3 Q3 _* z7 {# \; M/ F axes(handles.axes3); plot(1:size(handles.Result.Image, 1), handles.Result.Projectr);
: _3 u' [: q! c4 {/ [) ? title('行投影');6 k6 l h3 O6 y' j& E( _
axes(handles.axes4); plot(1:size(handles.Result.Image, 2), handles.Result.Projectc);- R- o7 Y3 J5 z# w8 U+ c
title('列投影');
@' I! {" B4 `end6 d5 F2 M7 ?( M% {
+ K7 z' q- s, O3 k% z8 T4 f7 [
/ M9 j! U& t- u, n, q' J3 y% --- Executes on button press in pushbuttonClose.
7 T! I; |4 A' @- K/ t$ gfunction pushbuttonClose_Callback(hObject, eventdata, handles)
) x. }5 [4 [; A* M; [9 g% hObject handle to pushbuttonClose (see GCBO); b2 O+ J3 U6 [
% eventdata reserved - to be defined in a future version of MATLAB4 J- Y% b' u& G( W9 h' p
% handles structure with handles and user data (see GUIDATA)# T/ S, B0 O7 k+ G/ l
choice = questdlg('确定退出?', ...- G7 h! u, K! w
'退出', ...
8 A+ A3 b: s) J) P) C Z '是','否','否');, D) _9 I, Q5 _/ I
switch choice& L" v. p. V! T% j- M# J
case '是'! ~8 j6 M+ a3 Y
close;+ d2 H, |- d, f& m$ D
otherwise
8 k7 X0 S Y) Z* Y: O" j9 V Y return;
0 t5 Y5 e6 B2 _# R% F7 ~end; W) d% `( _4 v6 ?7 {+ A6 U
: j" f5 `4 |/ N+ o, ~7 R * D! n. i$ k, {/ m
7 Z, u4 P: I2 ]- H X, V' a' C9 s% --- Executes on button press in pushbuttonSaveResult.$ U6 \) ^- _' W8 o4 I
function pushbuttonSaveResult_Callback(hObject, eventdata, handles)
+ b7 L+ `3 x$ }4 _) T% hObject handle to pushbuttonSaveResult (see GCBO). D' d3 G Z( y5 X
% eventdata reserved - to be defined in a future version of MATLAB
( M" X/ Z' B! s9 a% handles structure with handles and user data (see GUIDATA)
& F! B7 p3 w2 r! k1 Dtry1 X; {1 J+ H; x* O! P" M* d( N9 D
if ~isempty(handles.File)$ e+ g( q0 }! O" l
raw = [];
" T; a9 o- \$ b' k xlsfile = fullfile(pwd, 'Result/result.xls');9 w8 U7 H7 Q" S- `
if exist(xlsfile, 'file')
1 Y) f% T' w+ _9 g1 p# m& Q [num, txt, raw] = xlsread(xlsfile);
0 Y v% ?7 W" t( Z; {1 U3 ] end
6 X; j2 J4 O) _: `6 _9 S + s/ |( V1 Z: H. U/ f6 T
F = [];
7 m7 e% V# B" ^# ? F{1, 1} = '文件名';
$ w* K$ O5 c& F/ `4 d F{1, 2} = '阈值信息';
0 t& e6 U) g$ f- w' z" t F{1, 3} = '面积信息';: E; T$ m' p @
F{1, 4} = '长度信息';
; Z. Y$ p% T" P$ Y4 s5 o2 d, u( F F{1, 5} = '最大宽度信息';
" j( S0 g0 v. I7 j5 i" T! _ F{1, 6} = '最小宽度信息';
# T, A& ^% n! X9 f( R% u- U F{1, 7} = '形状信息';
6 ~9 @) v: v6 V7 c5 h9 ~
* w; O& d5 h) g F{2, 1} = handles.File;
! H, W) J6 H( F$ Q$ _' {9 _ F{2, 2} = handles.Result.BwTh;5 U. R4 |+ _ F( R
F{2, 3} = handles.Result.BwArea;
! ^) v$ K% s/ E% ?; I F{2, 4} = handles.Result.BwLength;
0 P6 E M, e! {4 g r% n8 r4 y# p2 H F{2, 5} = handles.Result.BwWidthMax; \4 {- @1 ?' _* n( p5 s
F{2, 6} = max(handles.Result.BwWidthMin,0.01);5 j2 T( q' J- p0 A6 o
F{2, 7} = handles.Result.str;$ ]2 ~9 w% Q# j' g
& R/ F9 V! P, [3 F# @4 X
F = [raw; F];
. \% a. Y% l6 O1 | j! J, g xlswrite(xlsfile, F);
6 y# U, p8 _* z0 ?2 E& D) p
2 G8 B Y9 m6 { x msgbox('保存结果成功!', '信息提示框');
4 H: ]; Z) w' Z4 m, x) _ end! e7 J s N: f( x% S0 }
catch
% ] u: u: }3 X1 j5 D msgbox('保存结果失败,请检查程序!', '信息提示框');
+ n2 V8 \$ j& _0 t1 z8 cend% @/ I W+ O w7 b% ?& Z
. ?4 R; B' {% D4 i+ W2 Y
% U7 H5 ^: c. L! b* E( M' }8 i% --- Executes on button press in pushbuttonBridge." Z$ F, @! r' E; V& _/ _. _
function pushbuttonBridge_Callback(hObject, eventdata, handles)
* }2 j( O8 I; }; E, B( c, z% f1 E% hObject handle to pushbuttonBridge (see GCBO)9 f3 g/ G j& {0 [3 h. R: h
% eventdata reserved - to be defined in a future version of MATLAB3 v' u) F" ] p D+ G7 }
% handles structure with handles and user data (see GUIDATA)2 P. J4 g/ z# Y: q0 T# c1 S
if ~isempty(handles.Result)( _$ a) q" }6 g
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');+ \/ a8 u3 \# g Y! h: ^* n
axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');
" E. v# C) @5 f! R. X _ axes(handles.axes3); imshow(handles.Result.CrackJudge); title('裂缝判断');
0 U' i: @, w. B axes(handles.axes4); imshow(handles.Result.CrackBridge); title('裂缝拼接');$ z4 ?2 ~, p5 }0 G# M1 K
end% p# z$ g0 f8 |! Q
' ]. q$ p' x; e( E
$ a1 F* @2 |! R$ C `% --- Executes on button press in pushbuttonSaveImage.
- q2 c- Z( r: T. p& ?function pushbuttonSaveImage_Callback(hObject, eventdata, handles)2 l3 S" n4 d' V3 Z% H8 p; d B
% hObject handle to pushbuttonSaveImage (see GCBO)# m2 m- m% d* ]- M
% eventdata reserved - to be defined in a future version of MATLAB
3 `9 d' C# j/ {/ g& X% handles structure with handles and user data (see GUIDATA)* @' j6 }2 d% d, H& B
[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
+ ?' G4 e1 J4 N( d k '*.*','All Files' },'Save Image',...
1 N9 L+ M1 k- A7 T" M t* w4 b& ] fullfile(pwd, 'Result/result.png'));( h7 ], ` f7 R" h' U6 [( t+ f
if ~isequal(filename, 0)
7 u* m4 Z; ~# R$ j+ \; i imwrite(handles.Result.BwEnd, fullfile(pathname, filename));
6 N. B: m3 J* C, O msgbox('保存图像成功!', '信息提示框');" G( b/ x+ x+ I8 e& y6 `; z' B
end# x3 b" o; Y) l
]0 ^( u, f$ t# _5 U& h
7 ^- R' _- S% g1 D* P/ ~# h% --- Executes on button press in pushbuttonDiplay.
3 w; Z/ J0 i: r6 C+ Qfunction pushbuttonDiplay_Callback(hObject, eventdata, handles)3 L1 t) X: u' C2 c
% hObject handle to pushbuttonDiplay (see GCBO)
9 w7 |/ u, {" H1 Q% eventdata reserved - to be defined in a future version of MATLAB
: Z% \7 d. P# {1 e5 }* m% handles structure with handles and user data (see GUIDATA)
, i- r5 n9 f4 d$ p6 _# Iif ~isempty(handles.File)) o& u- I& A9 m6 \( a
F = [];
, d1 w0 {& Z7 N8 G8 n F{1} = sprintf('文件名:%s', handles.File);
% f* X" U% K' Z0 v+ E' D F{2} = sprintf('阈值信息%.2f', handles.Result.BwTh);9 r% K7 B% S3 {2 ?, X }! F
F{3} = sprintf('面积信息%.2f', handles.Result.BwArea);
7 Z& Y, U$ t4 k: h r) k F{4} = sprintf('长度信息%.2f', handles.Result.BwLength);
8 b$ d; A8 S, l. T: ? F{5} = sprintf('最大宽度信息%.2f', handles.Result.BwWidthMax);
3 z. n, K5 N" C7 E F{6} = sprintf('最小宽度信息%.2f', max(handles.Result.BwWidthMin,0.01));
7 B& F/ \6 T. d3 q F{7} = sprintf('形状信息%s', handles.Result.str);2 T y5 f* m+ w: T
listdlg('PromptString', '参数显示:',...5 ]" S& p1 c/ ?6 ^1 n7 N4 ^, F' q
'Name', '参数信息', ...
' c: u1 R6 o+ [" i$ G 'ListSize', [300, 150], ...( S) o: \5 K0 |) y6 m. L0 o0 k
'SelectionMode','single',...8 I* P, V3 c$ ^# T% K! \
'ListString', F);3 G! O5 ~3 O, B ~2 u- ^
end
! G! ^7 v# G( ]* t* L5 x! j7 `
; s1 \& U7 J( b三、运行结果% R+ E! w# D( w$ e( }
! u' \4 R( v* i/ d1 L( R$ _# n
* r9 U; R/ }) `) b
% a8 N- _5 ^5 W5 L! x' w( x: f( T
. E1 G& S" A0 `. g% `. \ |
|