|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
+ p0 s# D& o1 I2 Z: D( ~5 i
一、简介$ |5 ]% S H6 N; V% G: {, R9 A- [
高速公路路面病害养护和管理的重要部分就是路面裂缝的检测。近年来,路面裂缝自动检测技术已得到了广泛应用,而由于路面裂缝图像的复杂性,检测算法直接影响着检测结果的精确度。因此,本文将重点放在路面裂缝病害的检测上,为了提高检测的精度,分别从裂缝图像的去噪、图像的增强、图像的分割以及检测后路面裂缝图像的特征提取方面进行深入研究。 在路面裂缝图像中,由于裂缝信息与背景对比度偏低,难以将裂缝直接检测到。对于图像的预处理,首先对图像进行灰度校正,再对校正之后的图像滤波,本文提出了一种改进的中值滤波方法,对图像进行去噪,之后用基于模糊理论的图像增强原理对图像做进一步增强,有效提高了路面裂缝图像的对比度。 针对路面裂缝图像分割,本文分别用了阈值分割和基于形态学多尺度的思想,对于形状规则的裂缝采用的是阈值分割,对于裂缝形状不规则的图像,本文设计了一种多结构元素的抗噪型边缘检测算子,且依据不同形状的结构元素对裂缝边缘填充的几率不同,确定了自适应权重,使得算子检测到了各种类型的裂缝边缘,有效地提高了检测的精度。 对于经过分割后的路面裂缝图像中存在噪声和裂缝断裂的问题,本文对于断裂较窄的图像用形态学中的闭运算和开运算去处理,对于断裂较宽的图像,提出了一种基于生长的断裂裂缝块的连接方法。提高了连接的效率和准确率,使整个检测结果清晰完整。最终,从识别结果图中提取裂缝信息。根据得到的识别结果图,设定一系列判定条件,提取出裂缝的连通域,对裂缝的类型进行判断,最后计算出网状裂缝的面积及线性裂缝的长宽信息。$ F; i0 H' F, n8 S" R4 y! U" Z1 P! E
3 r& y% }, x4 { E
二、源代码
# [5 L/ [9 D' O: K t/ Afunction varargout = Gui_Main(varargin)
/ _% j/ } ^0 Z0 ^- S. V% GUI_MAIN M-file for Gui_Main.fig
G9 _; F$ N6 D4 K2 f/ }% GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing
$ a$ l+ V6 D! C+ B7 i% singleton*.+ P+ X! s6 y2 B n
%; g/ U& K: l; E2 ]6 r. k1 e1 W, l* j
% H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to L N! {2 M. e% n( f7 W6 K
% the existing singleton*.4 J' P& c) ^9 N$ n* P. T, U
%1 [! {) P/ i% t7 j/ Y
% GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local7 Y3 V5 [) Q; h& _
% function named CALLBACK in GUI_MAIN.M with the given input arguments.9 Y# i0 Z0 i8 S4 {4 W6 C
%9 P1 R I; i- F
% GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the$ i# |, |0 e. Q
% existing singleton*. Starting from the left, property value pairs are
+ D( L/ ^4 S# g* _7 y% applied to the GUI before Gui_Main_OpeningFcn gets called. An- \) I6 f. K+ f. _. F
% unrecognized property name or invalid value makes property application
/ r! q+ A6 D2 u- ~% stop. All inputs are passed to Gui_Main_OpeningFcn via varargin.
# p: v& o, `* g8 t%# v4 m2 s8 F: }& x
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one( R9 r) R3 Z D! w
% instance to run (singleton)".
7 X Z" y4 ^& y" S5 n%3 j/ B' b6 s1 I* p6 `9 \0 b
% See also: GUIDE, GUIDATA, GUIHANDLES
' T4 w2 E8 F+ l; j! F( P' s1 B8 e
7 }6 g$ M2 t) N) Z8 S) [% Edit the above text to modify the response to help Gui_Main
; C8 N* a; p1 G/ ~
8 p4 j1 O5 m8 ~, {3 _% Last Modified by GUIDE v2.5 29-Mar-2011 22:28:58
( R' h }' O3 K- {* q0 C& [' m
; n- o/ h7 @4 M# f8 O9 W% Begin initialization code - DO NOT EDIT
; t z, ]+ m" P/ z: ?; M: Q$ ~+ Mgui_Singleton = 1;
6 k9 _, T! C1 c/ X0 |% bgui_State = struct('gui_Name', mfilename, ...' g, i3 G. D; x2 H4 ?
'gui_Singleton', gui_Singleton, ...$ O; [! Y6 L: V5 M9 e& ]8 n, e# P
'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...
, p9 j% b, C+ ?5 v# i# r 'gui_OutputFcn', @Gui_Main_OutputFcn, ...' l7 ]( h6 ?! C7 I
'gui_LayoutFcn', [] , ...
6 o: P: D( W9 }* v L$ C1 u$ \+ S 'gui_Callback', []);3 K( k: \- x# P5 X; Q" O
if nargin && ischar(varargin{1})9 t' K) @7 E9 p8 {
gui_State.gui_Callback = str2func(varargin{1}); |# O+ Q" }- P8 _
end
" j0 n a S- T! |
+ _: K8 e& L, k: J7 T5 Zif nargout0 `4 t/ Q ]/ v8 `
[varargout{1:nargout}] = gui_maiNFCn(gui_State, varargin{:});; u: r5 G3 {8 b+ a7 D
else4 M4 I/ r+ E3 R6 R" ]. G* j0 M; Q$ s
gui_mainfcn(gui_State, varargin{:});
5 \" U" E: l3 I8 Z( s" d% S5 dend% O4 ^5 P" p4 f8 f
% End initialization code - DO NOT EDIT
& {; H1 `; t9 v: L* L( b# H 2 e8 z/ Z3 x! y3 B, S
- v* N, y6 C* X" q# C; N/ g% --- Executes just before Gui_Main is made visible.
: Q' F/ S" M' Ofunction Gui_Main_OpeningFcn(hObject, eventdata, handles, varargin)
2 M( d! g2 j& t6 j% j$ }% This function has no output args, see OutputFcn., J) s2 f. j! b
% hObject handle to figure3 t$ u. A" n2 N1 D4 U+ J6 j
% eventdata reserved - to be defined in a future version of MATLAB
6 ?" U- f7 S# {" _3 z' t& t: R2 d% handles structure with handles and user data (see GUIDATA)
6 j& N# T9 }# Q" M3 h- X4 I* I% varargin command line arguments to Gui_Main (see VARARGIN)
. V' u1 P( u3 ]7 C( j0 n$ o
. e# @3 A' }; m: m6 U1 Q# d1 t( L% Choose default command line output for Gui_Main
8 X7 e% m* K( m5 }4 mhandles.output = hObject;% `" G: c0 I- k' c
handles.Result = [];6 r4 {( Y& d3 y+ x& L% Y
handles.File = [];
& a, x8 N1 L* @6 Z% Update handles structure
: b* v6 @- ]$ ]2 {8 pguidata(hObject, handles);
" e* s. Z9 N8 p L0 ^& Qclc; warning off all;3 R. C: L. E! c* ?& O. Y6 j
InitAxes(handles);
. X% v$ Z. y# G# x* `3 b9 N ) \5 R% X8 g! y
% UIWAIT makes Gui_Main wait for user response (see UIRESUME)( `# w! J' o3 T4 M S$ L
% uiwait(handles.figure1);0 t6 G+ f5 F# n+ s0 I
# L$ M& ]! B7 q/ I; g
Z, z0 ]8 t* h7 |& i3 I2 v% --- Outputs from this function are returned to the command line.
5 [/ l$ n2 c2 s- u1 ~9 A) sfunction varargout = Gui_Main_OutputFcn(hObject, eventdata, handles)
4 t6 J7 r; C! O% varargout cell array for returning output args (see VARARGOUT);
/ K7 u" e" k7 S+ m7 ]7 m% hObject handle to figure& p" q- \! n* O0 m
% eventdata reserved - to be defined in a future version of MATLAB" Q! w- F0 X4 y! @ L
% handles structure with handles and user data (see GUIDATA)
% j5 F3 [* g0 |9 i + K2 x, e9 z. Z
% Get default command line output from handles structure/ \5 H* Q6 u1 s K' q
varargout{1} = handles.output;
& A/ X3 w5 _5 o+ Z9 m2 Y / E9 Z8 A& A8 w# k4 L+ k. u
" b0 U( v) u; k7 E! Q% --- Executes on button press in pushbuttonOpenFile.
R( _6 W$ m1 n) ~function pushbuttonOpenFile_Callback(hObject, eventdata, handles)
; `5 l6 @( F! Y) n, N( m- \% hObject handle to pushbuttonOpenFile (see GCBO)
# B1 Y! \2 T( R9 q: \1 u1 f# Q5 E% eventdata reserved - to be defined in a future version of MATLAB
7 j( `& S0 i) h; m) p1 p6 X1 s. P( N% handles structure with handles and user data (see GUIDATA)
: L, u0 b. p3 P' k/ Q) h8 q. F[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bmp','All Image Files';...
1 A5 }, y6 X$ }& D) B '*.*','All Files' },'载入图像',...9 X1 c6 i o- N6 y# g" \5 b. q: k
fullfile(pwd, 'images'));
( K0 b# s( r+ g* G) xif isequal(filename, 0) || isequal(pathname, 0)4 O4 {+ m X2 ?9 ]$ Y
return;
$ K, ]. n+ q% w+ Q0 x vend
6 W: a2 Z0 X. H/ K9 k; O+ fI = imread(fullfile(pathname, filename));: ?, |/ l3 o- Z2 {0 I- h3 C. ^
Result = Process_Main(I);
- I1 T o+ g, Y3 |5 thandles.File = fullfile(pathname, filename);- Z9 N9 [1 W4 E2 S& S+ O. L
handles.Result = Result;
9 M5 R7 o9 H* X3 h) u2 @2 jguidata(hObject, handles);% R, @# z! Q j
InitAxes(handles)
8 U5 {) O8 i0 {# Q; U( d( Oaxes(handles.axes1); imshow(handles.Result.Image); title('原图像');
2 B) V/ u( T6 _; c1 O0 h/ e , s2 q z; D( b
9 C9 B1 c% _8 ^, ]( B+ i$ a% --- Executes on button press in pushbuttonHisteq.' |: h5 l1 w7 t
function pushbuttonHisteq_Callback(hObject, eventdata, handles)9 p- Q3 e0 P8 S
% hObject handle to pushbuttonHisteq (see GCBO)
9 B$ x3 H: Q8 j J1 u% eventdata reserved - to be defined in a future version of MATLAB
# c2 ^% F: {6 L) ]# Q1 w; d$ b% handles structure with handles and user data (see GUIDATA)
; |2 _( [; L7 F3 jif ~isempty(handles.Result)' h) `: J! H$ O7 i; S4 h9 `$ [
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');5 ^, h! N4 a% W9 J2 R$ g* S5 z+ v
axes(handles.axes2); imshow(handles.Result.hist); title('直方图均衡化图像');
# Z' n( n S, xend. w& @0 u' k0 d& W* d6 g1 v
( o% H5 ?5 j* x8 u# l& P
, l4 U0 y) x( E/ t
3 o, O t2 q2 p7 C$ k3 Y0 O% --- Executes on button press in pushbuttonMedfilt.+ w7 A3 I3 Q2 R5 m
function pushbuttonMedfilt_Callback(hObject, eventdata, handles)4 V/ L% F: |( b$ K) E
% hObject handle to pushbuttonMedfilt (see GCBO)5 n" V& n9 R+ V& m7 Y
% eventdata reserved - to be defined in a future version of MATLAB
2 I& W4 s1 U( c% n, e* h% D' |7 C% handles structure with handles and user data (see GUIDATA)
; `' M, B L+ n' j \2 [if ~isempty(handles.Result)8 F& ?% ], @9 d8 c7 I& j
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');/ G- Q- @, i; Z' q) n6 @
axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');
" P w' C, _' T) Q& d6 Kend
2 ?" [, t& b7 g, J {8 X
2 `4 V8 V0 V) W& _; Y! o
' m" t- O( x. @7 ?* L$ n& _7 O' z+ ^% --- Executes on button press in pushbuttonBw.! X5 H% i* l- d/ U: f# K
function pushbuttonBw_Callback(hObject, eventdata, handles)8 I8 L! d* l4 M
% hObject handle to pushbuttonBw (see GCBO)
?! x$ \3 F/ k) f% eventdata reserved - to be defined in a future version of MATLAB
, Y; t3 ]2 C. l% handles structure with handles and user data (see GUIDATA)
$ b6 R$ _! C2 h* C' G: Iif ~isempty(handles.Result)
5 x8 E/ W6 g1 e; [$ k8 n3 _ axes(handles.axes1); imshow(handles.Result.Image); title('原图像');3 N& F3 _! e+ `3 M( K6 @- f) \9 g
axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');
5 g' I5 O8 g+ [) l* c7 v pend
, G4 c4 M6 }8 u" ^! x! x; o; b 5 }9 X/ d l, \9 x" A
% --- Executes on button press in pushbuttonEnance.
* U6 u6 m! A |# N6 x* q- mfunction pushbuttonEnance_Callback(hObject, eventdata, handles)
4 c3 r7 e+ E# B, E' B. h% hObject handle to pushbuttonEnance (see GCBO)& Y& ]9 n4 @) ^, N$ T; Q/ U0 O M
% eventdata reserved - to be defined in a future version of MATLAB* @4 l c; P& N' e, T
% handles structure with handles and user data (see GUIDATA)
6 G" c( R# C9 v t L3 X8 ^- N* k8 Cif ~isempty(handles.Result)
! K* F1 ~) C9 O" s7 ?3 z8 e axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
" M9 p0 m4 {7 z+ C/ |! `8 d axes(handles.axes2); imshow(handles.Result.Enance); title('增强图像');
% R+ K0 O) w, Nend
" h9 O: e2 ~1 C" M 8 F& p! g' i- b: H3 z
% --- Executes on button press in pushbuttonBwfilter.6 l1 @- I a6 Q
function pushbuttonBwfilter_Callback(hObject, eventdata, handles)7 A: w6 _" k) q
% hObject handle to pushbuttonBwfilter (see GCBO)
: i7 S. n7 }8 U& }6 ?/ s% eventdata reserved - to be defined in a future version of MATLAB: c" L+ e) l8 I' C" G. _' s* j4 X2 a
% handles structure with handles and user data (see GUIDATA)
# ]* O1 G9 A9 {/ p9 i' a6 fif ~isempty(handles.Result)6 ] D a+ V" o2 x3 s) r+ Z
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
+ d4 P/ w5 W, n axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');* |; Z% _0 \8 s# Z6 } [
axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');& `/ ~2 W. w& l n; {: O9 {
end. G8 p ~: h% Q) \9 D* ]3 n
! d! w% o0 E8 f7 S0 O
% --- Executes on button press in pushbuttonCrackRec.2 W! i' h8 u4 F. H) y& T
function pushbuttonCrackRec_Callback(hObject, eventdata, handles)/ F! g7 L4 q% x, t7 F
% hObject handle to pushbuttonCrackRec (see GCBO)2 ~. y! J. q/ }4 `# }4 U
% eventdata reserved - to be defined in a future version of MATLAB
: e' X1 f8 v6 Z1 E3 A" Q% handles structure with handles and user data (see GUIDATA)4 b. m) ?1 n# i X9 C
if ~isempty(handles.Result)
, o2 M: }! u2 f6 j6 f axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
: d3 m B+ A* N9 k: ~ axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');* Z. O* w- ^1 v* k9 L: R, K
axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');* W: C0 G8 \) G
axes(handles.axes4); imshow(handles.Result.CrackRec); title('裂缝识别');& K. @" x/ f; d
end
4 |# V3 B5 f* p" w ) A% C! w! E! k6 G9 R
, Z. O- K9 J* T3 T( J, }$ ^
% --- Executes on button press in pushbuttonCrackJudge. U( x a3 |# u a; c* ~
function pushbuttonCrackJudge_Callback(hObject, eventdata, handles)
8 \* ^+ {: k9 v( `% |5 O% hObject handle to pushbuttonCrackJudge (see GCBO)8 J# M* C) u- k3 x
% eventdata reserved - to be defined in a future version of MATLAB1 H( E: X! U& E: j) v$ i6 Z
% handles structure with handles and user data (see GUIDATA). p# N2 q: P y4 ?. u* h
if ~isempty(handles.Result)
# t5 l. `) w, m/ K axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
( j( j* F7 ?- P; g) [) L) d. M; f axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');; G- H+ H6 L: q3 G
axes(handles.axes3); imshow(handles.Result.CrackRec); title('裂缝识别');+ x6 v3 I0 q- @* _0 R9 {
axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝判断');1 G5 J- w8 v5 Y0 D3 y
end+ X( Z2 f. t$ u: k- N+ U: g
. u6 r3 ]. V6 U. @) H% --- Executes on button press in pushbuttonCrackLoc.! w* b* }8 e3 H/ A2 H
function pushbuttonCrackLoc_Callback(hObject, eventdata, handles)5 k& m) _& O6 ]" {3 ~5 r0 R4 }/ O
% hObject handle to pushbuttonCrackLoc (see GCBO)
' |" A* L: p3 F$ l* Q$ t% eventdata reserved - to be defined in a future version of MATLAB1 P' f7 ^% Z& v/ ^5 v
% handles structure with handles and user data (see GUIDATA)
3 l% K4 d1 d0 lif ~isempty(handles.Result)1 ?* }/ @0 E% J v
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
6 b3 Y( a6 B" r7 u* N axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');8 c1 E) ^$ R7 N9 x
axes(handles.axes3); imshow(handles.Result.CrackJudge); title(handles.Result.str);) ~( \; F1 F, V6 G+ v8 L& P
axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝标记图像');
& Y5 v" a& @/ \) I' M hold on;9 i* R0 F \; w
rectangle('Position', handles.Result.rect, 'EdgeColor', 'g', 'LineWidth', 2);
# A, w" V; t+ m" U hold off;5 s! `# G& v% u: o- A
end, R0 [) e+ M# h1 A* I( N
p. H6 I+ K8 x$ a7 r- t% --- Executes on button press in pushbuttonProject.( r |7 U$ t) |
function pushbuttonProject_Callback(hObject, eventdata, handles)7 V- c6 o0 I) ^3 w
% hObject handle to pushbuttonProject (see GCBO)
0 |6 u9 J3 A }/ S% eventdata reserved - to be defined in a future version of MATLAB
' T% Y" Q2 M, `8 {9 L; |: D% handles structure with handles and user data (see GUIDATA)$ j0 h8 N! q2 U6 e8 S0 R
if ~isempty(handles.Result)
/ r: c2 X/ [( y8 m b axes(handles.axes1); imshow(handles.Result.Image); title('原图像');! E1 r5 }. _4 c6 R' T. _: F/ ~& d
axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');
$ Z% W1 R4 Z. ~ axes(handles.axes3); plot(1:size(handles.Result.Image, 1), handles.Result.Projectr);: J$ `/ `# B) E; U0 n: r: X
title('行投影');
; B3 c! A6 F3 S/ S" a/ N axes(handles.axes4); plot(1:size(handles.Result.Image, 2), handles.Result.Projectc);
: R; G8 ]1 b+ {$ y0 Q2 ] title('列投影');0 t8 u$ ]! g$ O z$ a9 Q9 G
end
3 D. w7 w; Z+ W3 y 2 H9 t9 }5 p- `7 R
& {, j& A2 V' @/ @0 w' h% --- Executes on button press in pushbuttonClose.1 h l2 P W# ?3 Y* ? Z8 m
function pushbuttonClose_Callback(hObject, eventdata, handles)
9 b: J' I4 E. R; f! X. [( j/ H! V' y% hObject handle to pushbuttonClose (see GCBO) s4 N) S' I& t; G! N5 i
% eventdata reserved - to be defined in a future version of MATLAB3 `: l# S* R6 [
% handles structure with handles and user data (see GUIDATA)
$ D! k+ g; [# T6 n8 l+ uchoice = questdlg('确定退出?', ...6 q" m8 K. ~1 A3 y0 V1 {, I
'退出', ...4 R/ N2 p- ^: b) \; z! C; c
'是','否','否');
9 k7 [! ~- ~& y! l {switch choice7 {' q; q& o& ~% t
case '是'! G3 Y$ P- ^" e7 |
close;- E2 H1 I7 n, j
otherwise3 u7 o0 o+ c5 ~! s4 t% y4 j( f
return;
' ^: ^3 }; `. x1 ~! x: X1 E, \end
3 t9 ?$ W# D4 V) Y- {) x! w; q
1 I, N% t7 H0 a+ A
# r* [/ B, c* \8 r8 f, G $ j: `* K: D: u
% --- Executes on button press in pushbuttonSaveResult.6 [: b2 y! W: Q2 o/ b. h
function pushbuttonSaveResult_Callback(hObject, eventdata, handles)
" a% Z2 z4 e; e$ w+ j0 X( P7 \% hObject handle to pushbuttonSaveResult (see GCBO)
7 ^. b& B$ f- @# b$ Q% eventdata reserved - to be defined in a future version of MATLAB
7 }4 e) B5 j" T3 }, }& J1 ? z% handles structure with handles and user data (see GUIDATA)& h& o& w/ y( c( N- X7 A, D. z
try% `1 z0 n9 B9 i2 n& v0 c& _( i1 Q. o
if ~isempty(handles.File)
+ S: q% f' ]4 g raw = [];- s& ~% D% H/ P$ Z. I3 }% B, s
xlsfile = fullfile(pwd, 'Result/result.xls');
$ e/ c% z; t- e$ R: u3 I/ i1 ]8 w" z if exist(xlsfile, 'file')
2 s9 B7 n. \4 C/ W [num, txt, raw] = xlsread(xlsfile);
: o) L; H( @, V end: [. T; N8 M) f. d+ o
" p% j7 b8 e( @4 a
F = [];* O9 A8 H9 w& q) w k& [
F{1, 1} = '文件名';
4 B- K/ P1 N" a: n: X: d F{1, 2} = '阈值信息';
' K5 T3 F* n7 |% v2 E- T4 E F{1, 3} = '面积信息';
* u4 @, ~1 y$ ]- a4 u7 X# j# M F{1, 4} = '长度信息';
( Y0 Z9 t) c9 C6 k9 u% o8 Q& R F{1, 5} = '最大宽度信息';
' N6 Z+ Y2 |3 D+ V5 S1 M: |1 R6 C F{1, 6} = '最小宽度信息';
$ B; v8 l, [& b6 O8 f F{1, 7} = '形状信息';
6 Y6 L1 h2 T0 O) z
' g1 {: G1 T6 B! a' t5 \; _8 Q" f F{2, 1} = handles.File;
8 m! `9 [3 M, T5 h: h F{2, 2} = handles.Result.BwTh;
3 b' x6 c7 h- _# ^, F/ b d+ |* u F{2, 3} = handles.Result.BwArea;- _: |0 u) x1 S2 @
F{2, 4} = handles.Result.BwLength;
; U- a$ O8 R* w1 C; t% z F{2, 5} = handles.Result.BwWidthMax;
6 S1 }6 k$ q) r o' R: k7 W" l! T' v F{2, 6} = max(handles.Result.BwWidthMin,0.01);
) r: B* A3 _' s+ X# I; q- Q F{2, 7} = handles.Result.str;9 Y5 n+ K7 G0 P, G0 w$ m
2 o, h- k. `% \, N* V$ P/ g4 X F = [raw; F];; z4 v8 h1 w) C
xlswrite(xlsfile, F);8 P9 M6 y# s; D6 f
# T# T C6 }+ t# ` msgbox('保存结果成功!', '信息提示框');/ _7 O& {1 W; n# V, t* q1 l
end
1 V$ ^/ q9 V, Qcatch9 T: M* ~" m$ f8 P/ C
msgbox('保存结果失败,请检查程序!', '信息提示框');
9 O7 q# o- J# H0 vend
: ?3 V3 H+ o1 {2 h4 {% Q2 E6 p
2 P; f1 u& f, u; K6 v/ z
/ q. Z" D; z) v8 j% S, a% --- Executes on button press in pushbuttonBridge.
2 [' N9 ~! [. Z9 h$ lfunction pushbuttonBridge_Callback(hObject, eventdata, handles)# x# z6 ?% |0 B1 D+ O! X" j
% hObject handle to pushbuttonBridge (see GCBO)
8 s( J9 |, ^8 W6 {+ |9 P* i% eventdata reserved - to be defined in a future version of MATLAB- h* N, @/ U* }2 E
% handles structure with handles and user data (see GUIDATA)
6 J/ m" H7 c8 F. v) l/ hif ~isempty(handles.Result)
1 E2 l# q1 T/ V; l& H1 w8 N axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
) }; H2 ^1 I2 y x7 }; d( D axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');1 Q7 N1 K& { L. f
axes(handles.axes3); imshow(handles.Result.CrackJudge); title('裂缝判断');5 T6 K( z' S' R m* i# x
axes(handles.axes4); imshow(handles.Result.CrackBridge); title('裂缝拼接');
6 D( ` n f0 E' q3 N- C! Rend( K3 G: }7 K1 Q
' k4 M0 [0 H L; F2 W: U
1 s5 G7 v- s: C+ P
% --- Executes on button press in pushbuttonSaveImage.. ?( {. r% T. Q/ D0 S' l( }6 h
function pushbuttonSaveImage_Callback(hObject, eventdata, handles)" E* x7 T; M6 E; c' X8 k
% hObject handle to pushbuttonSaveImage (see GCBO)
& i- u9 f8 ~0 h3 r$ a& w% eventdata reserved - to be defined in a future version of MATLAB
' N" j& J' H2 v8 o% handles structure with handles and user data (see GUIDATA)
3 |" F- |) J) A0 T* Q0 ^% T3 W R$ y" p( M0 T[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
6 E# z! F+ _- ^+ }. I! [5 d! Z. P '*.*','All Files' },'Save Image',...
C& _# k$ o2 B6 L3 x; V( h fullfile(pwd, 'Result/result.png'));
8 b \" l' w, F; d$ q0 |* x0 @* l1 lif ~isequal(filename, 0)
6 y# h \+ X/ ?6 L& Y( M imwrite(handles.Result.BwEnd, fullfile(pathname, filename));
* B0 {3 o! S/ |! |: \. s( H4 t7 X msgbox('保存图像成功!', '信息提示框');+ a/ t0 n \5 D# F; c& Z
end
. Q1 C, [3 O1 X% l" F
0 u' E1 W6 g0 T ~ 8 g$ s, ]7 C4 [2 S8 s/ g
% --- Executes on button press in pushbuttonDiplay.
$ ]5 z* a4 g% U3 X9 afunction pushbuttonDiplay_Callback(hObject, eventdata, handles)0 ?6 } x4 t6 s7 g. ~2 S
% hObject handle to pushbuttonDiplay (see GCBO) v0 `; e0 H( ^" ~
% eventdata reserved - to be defined in a future version of MATLAB+ `# ?) _3 ]* K* i$ Z4 A! c
% handles structure with handles and user data (see GUIDATA)! j6 P4 B D8 f, p
if ~isempty(handles.File)
, Z. j+ V6 k& b' K. R F = [];+ Z1 w* y- T/ M2 E2 r3 u( Q
F{1} = sprintf('文件名:%s', handles.File);
( j2 I2 C3 [, A3 T. I F{2} = sprintf('阈值信息%.2f', handles.Result.BwTh);
N7 F1 q: i% R6 D F{3} = sprintf('面积信息%.2f', handles.Result.BwArea);
" z! [( P2 S3 t F{4} = sprintf('长度信息%.2f', handles.Result.BwLength);3 R* q- y w7 z4 p7 I" ]4 Q( C
F{5} = sprintf('最大宽度信息%.2f', handles.Result.BwWidthMax);; J, }* D# N; i7 M% {+ u( ]
F{6} = sprintf('最小宽度信息%.2f', max(handles.Result.BwWidthMin,0.01));9 r/ ^( h; }3 f. u+ b
F{7} = sprintf('形状信息%s', handles.Result.str);
* Z+ ~7 a7 n4 x3 n- L listdlg('PromptString', '参数显示:',...
) A& W' s ], [4 H T) { 'Name', '参数信息', ...
* L1 Y0 s& r# j" m. l# k 'ListSize', [300, 150], ...) P/ U5 ~: }) ~; j4 q5 r! y/ S) i0 _
'SelectionMode','single',...' L* V e+ w& @0 M1 n& P) x$ n
'ListString', F);
. p; z( t2 H$ T7 g" jend
/ D- W% n/ e: p5 {( z) V: C$ A I& _' q$ u' V1 C6 ~
三、运行结果; G) g% \# ]+ ~7 y# K( s: k& j. Q
) g8 R2 d( F* G8 i
, x8 b& h, {% A. \. {- `
/ H6 I" ^$ B* V g9 c
; f3 g- Q! B9 y/ d- A0 F/ x2 |% H" ^ h' [. n* s
|
|