|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
; X* m1 B/ f# b( L/ Z' G一、简介% u5 f; C1 g6 R* J
高速公路路面病害养护和管理的重要部分就是路面裂缝的检测。近年来,路面裂缝自动检测技术已得到了广泛应用,而由于路面裂缝图像的复杂性,检测算法直接影响着检测结果的精确度。因此,本文将重点放在路面裂缝病害的检测上,为了提高检测的精度,分别从裂缝图像的去噪、图像的增强、图像的分割以及检测后路面裂缝图像的特征提取方面进行深入研究。 在路面裂缝图像中,由于裂缝信息与背景对比度偏低,难以将裂缝直接检测到。对于图像的预处理,首先对图像进行灰度校正,再对校正之后的图像滤波,本文提出了一种改进的中值滤波方法,对图像进行去噪,之后用基于模糊理论的图像增强原理对图像做进一步增强,有效提高了路面裂缝图像的对比度。 针对路面裂缝图像分割,本文分别用了阈值分割和基于形态学多尺度的思想,对于形状规则的裂缝采用的是阈值分割,对于裂缝形状不规则的图像,本文设计了一种多结构元素的抗噪型边缘检测算子,且依据不同形状的结构元素对裂缝边缘填充的几率不同,确定了自适应权重,使得算子检测到了各种类型的裂缝边缘,有效地提高了检测的精度。 对于经过分割后的路面裂缝图像中存在噪声和裂缝断裂的问题,本文对于断裂较窄的图像用形态学中的闭运算和开运算去处理,对于断裂较宽的图像,提出了一种基于生长的断裂裂缝块的连接方法。提高了连接的效率和准确率,使整个检测结果清晰完整。最终,从识别结果图中提取裂缝信息。根据得到的识别结果图,设定一系列判定条件,提取出裂缝的连通域,对裂缝的类型进行判断,最后计算出网状裂缝的面积及线性裂缝的长宽信息。* h/ P# z5 A& }) v
" L4 j4 p6 S0 ^7 u2 ^; z* S二、源代码* s: M4 i+ d& f, m; { V( S- {
function varargout = Gui_Main(varargin)- H5 h7 q% c% c" J8 N( i. r5 X
% GUI_MAIN M-file for Gui_Main.fig
) t; t4 w5 s& ^% GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing
5 m7 g$ D+ r, a% singleton*.8 F. G6 U+ J6 ]
%
/ z" @& M( {* }7 O8 V |$ O% H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to
# e8 L2 `7 m% i7 M% the existing singleton*.0 W- a9 h! t" P7 _/ W
%6 I8 v+ H! {9 W! ~ W$ `
% GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local! [; O- b! k% a1 u) ?
% function named CALLBACK in GUI_MAIN.M with the given input arguments.& e4 F0 }( J/ l2 w9 T. `
%1 A5 Y! }% o6 \! V; B" {
% GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the9 ~( r/ M1 e) O; {( H# x) z& ^
% existing singleton*. Starting from the left, property value pairs are$ ~& s: v" x" B
% applied to the GUI before Gui_Main_OpeningFcn gets called. An
. Q* q3 @" W! w+ E9 D5 J# i% Z3 n% unrecognized property name or invalid value makes property application" a. C1 Q7 ]0 S H, n
% stop. All inputs are passed to Gui_Main_OpeningFcn via varargin.$ o& X& }7 w6 F, [$ X
%
9 Q# i5 \ c: y9 v% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
; N, @, e% Q! i+ @0 E5 } l% instance to run (singleton)".
) f* n9 S; G( u9 U%: J Y4 E9 c6 M
% See also: GUIDE, GUIDATA, GUIHANDLES* I: e3 y) ~; F' u- }; u
; ~1 Q/ Y$ D& B: q1 A4 P% A! p% Edit the above text to modify the response to help Gui_Main7 h+ J- Z/ f* C5 w8 i# w$ I
7 Z5 `2 X3 M( J6 U
% Last Modified by GUIDE v2.5 29-Mar-2011 22:28:58# K3 t8 ?& S" P+ ~2 f+ A7 S
* U* }0 e8 B" r' @4 O! f% Begin initialization code - DO NOT EDIT! _5 r" f" j& V( U. A& S
gui_Singleton = 1;
% {1 P6 P" C* C% R; J" N+ sgui_State = struct('gui_Name', mfilename, ...
' ]* e: {5 c- k+ T/ ?' X 'gui_Singleton', gui_Singleton, ...
3 |7 [% ?3 n' G& n- B2 j- v" Y 'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...
/ ~2 i {) w0 q" c8 J 'gui_OutputFcn', @Gui_Main_OutputFcn, ...
, f$ E4 b* z7 d; [8 }* y' v 'gui_LayoutFcn', [] , ...
- d6 e w s$ v- u 'gui_Callback', []);! r. W& e# E0 ~3 M$ G
if nargin && ischar(varargin{1})! {; f0 D' ^. a3 C
gui_State.gui_Callback = str2func(varargin{1});
$ j; o: p: X+ A9 ]; E4 Q* dend1 M) x5 I' H! |+ D- S
6 p+ }( p5 G* ~. [ C! j# w2 kif nargout) J' e3 S2 L0 I6 l% n7 u
[varargout{1:nargout}] = gui_maiNFCn(gui_State, varargin{:});3 `' N, \7 w Y) N, q
else
! A" M1 M: ^- ]: M gui_mainfcn(gui_State, varargin{:});6 g. i. \8 a9 o; B
end
' @, a0 p" r' n% B' S6 V% End initialization code - DO NOT EDIT# z. a4 W0 n! l2 B' Y
" j4 b* `% O: ]: b4 E
2 E9 U3 [0 R. e8 j; @! [& y8 m) t5 Z1 H% --- Executes just before Gui_Main is made visible.
3 [) [9 n* R# f( @function Gui_Main_OpeningFcn(hObject, eventdata, handles, varargin)+ Y: w+ F* A! K6 e% m, l6 m
% This function has no output args, see OutputFcn.
4 L$ t7 b! r7 F( b% hObject handle to figure/ r5 X7 w/ X, R' x2 |/ p! ]; m" k
% eventdata reserved - to be defined in a future version of MATLAB! L9 }) }; |) t; D
% handles structure with handles and user data (see GUIDATA)
8 c* U8 n( f3 `- ^/ c0 W% varargin command line arguments to Gui_Main (see VARARGIN)
& p( J+ T) X! S$ d/ U% U ! s5 t9 S% D$ Q L) k; H
% Choose default command line output for Gui_Main$ @5 Z9 g o z* F0 b$ U
handles.output = hObject;
/ \, l; u9 _: x6 I. ?' mhandles.Result = [];* Y4 `. X6 H8 X9 s1 l3 \* m
handles.File = [];
- S9 O( j/ W% [& W3 Z* |% Update handles structure
4 }' m8 R$ p4 uguidata(hObject, handles);0 U0 S- s" C J, d: J
clc; warning off all;
, h6 H$ g. D% J' @InitAxes(handles);
2 H) [+ f$ V5 M8 f+ u9 a& J E
5 I! ~7 u! _# v- s: p% UIWAIT makes Gui_Main wait for user response (see UIRESUME)
* O% g! H( L3 p' S& \% uiwait(handles.figure1);9 b4 r3 L {0 Y$ ^5 h) q3 ~! e, h" o
; K$ n' o/ t0 o; g; h1 r; B8 X6 w
: E+ F4 \* c$ i1 v$ E0 o& [8 p% --- Outputs from this function are returned to the command line.& S6 \8 e5 f8 h% o& U( w/ a# P. J; _
function varargout = Gui_Main_OutputFcn(hObject, eventdata, handles); d5 Y& X, W I. X# |
% varargout cell array for returning output args (see VARARGOUT);
4 v0 K7 Y4 h" c( z4 V1 d% hObject handle to figure
2 _; Y% W: _* y) X/ L$ I' G- E% eventdata reserved - to be defined in a future version of MATLAB( W }) C! r) ~! `& e
% handles structure with handles and user data (see GUIDATA)8 ^* T9 K, I- K( N5 V/ v5 R5 a
2 d& U8 e; Q% s( Z
% Get default command line output from handles structure
6 u! ]. e* |6 e& {' r# g! Y" D k; Qvarargout{1} = handles.output;0 r& w' Z" n" S- ]. U# S& x
8 l8 d9 c9 A% J& d3 C + f% h" h1 ^% P/ t1 ~& q
% --- Executes on button press in pushbuttonOpenFile.
6 X1 z/ W: `$ E0 f$ sfunction pushbuttonOpenFile_Callback(hObject, eventdata, handles)
$ \2 {, q* H2 M H! V& p% hObject handle to pushbuttonOpenFile (see GCBO)
6 D1 G+ h" k. [' v" G; k0 H% eventdata reserved - to be defined in a future version of MATLAB
- m" B& d7 e3 j) ? B% handles structure with handles and user data (see GUIDATA)
3 }/ Z# P% G0 a, J& v6 f& H[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bmp','All Image Files';...9 A' ~# k$ d. U8 ^: }: q: W% C% l
'*.*','All Files' },'载入图像',...
# K6 m( P. v* l) D: s9 j" k fullfile(pwd, 'images'));# Z9 c- `5 e0 d* r# s: T
if isequal(filename, 0) || isequal(pathname, 0)$ `9 j* ?; k# k# t0 D) n
return;
. y' B% Z6 Z* v3 g* lend
; s1 c" @8 f& G( ZI = imread(fullfile(pathname, filename));
$ Q. w$ o8 N- A. }+ sResult = Process_Main(I);( }& p# ^* e' G4 f6 v
handles.File = fullfile(pathname, filename);
0 M, P' f1 v( X# C: i& L2 rhandles.Result = Result;0 U# {% f9 E7 e* W7 C& [% z
guidata(hObject, handles);
- A$ N# v8 q" [) bInitAxes(handles)9 C0 N) c5 D* L6 B' S# O
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
3 R8 W" M/ I4 V . }. b1 Z3 t" l! J1 |* [
% |0 A8 [* A8 }
% --- Executes on button press in pushbuttonHisteq.4 n, J3 k' c8 N6 X3 a( I
function pushbuttonHisteq_Callback(hObject, eventdata, handles); F% ^$ M8 r0 h; p
% hObject handle to pushbuttonHisteq (see GCBO)
" F! |; S1 L6 A. x# K3 i& P0 L$ B% eventdata reserved - to be defined in a future version of MATLAB U& x+ Y9 L! k' [
% handles structure with handles and user data (see GUIDATA)* [0 D9 P5 R; k" P5 k9 m" V' j
if ~isempty(handles.Result)
9 o o |$ q* ]. ~) f: O4 T" | axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
' e' R( j8 t& y% Q8 J r) @ axes(handles.axes2); imshow(handles.Result.hist); title('直方图均衡化图像');3 U. s2 C4 e4 M
end
2 Y. j1 c* v5 U9 D2 [
* L( _2 r. o; b" \" k
+ m o8 G. j7 P$ Y8 R# {9 G
! x; i, y; v8 b: {% --- Executes on button press in pushbuttonMedfilt.
/ {# E* f$ w9 X: Efunction pushbuttonMedfilt_Callback(hObject, eventdata, handles)
) l+ @% C( ?' N: v# D( ]% hObject handle to pushbuttonMedfilt (see GCBO)( J! K5 Q0 p$ ]% q% V1 X
% eventdata reserved - to be defined in a future version of MATLAB
/ |5 s$ P2 N2 J6 P" [% handles structure with handles and user data (see GUIDATA) z w& Z! H4 X
if ~isempty(handles.Result)
* A$ v3 P" _& P7 l h axes(handles.axes1); imshow(handles.Result.Image); title('原图像');+ {8 R' F9 u, `$ ]7 x! |, O9 r
axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');! X* d- ?3 ~$ e" k( m
end3 M% }. E2 E& {( _( h4 E
* u, h" M" f8 W
) R& [" e+ M1 ^& @" P
% --- Executes on button press in pushbuttonBw.% V( B0 R, ~" W/ _
function pushbuttonBw_Callback(hObject, eventdata, handles)3 ~. U8 X3 N" ]0 `
% hObject handle to pushbuttonBw (see GCBO) E# q3 M4 u% ^1 v, [
% eventdata reserved - to be defined in a future version of MATLAB
2 L6 p0 m$ M4 a5 s& u) T% handles structure with handles and user data (see GUIDATA): [" d+ V! o* {- L$ V1 d+ j+ f' q$ u
if ~isempty(handles.Result)! L( c% P* K5 @5 e6 G( e- D$ z3 q
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
" | D$ L5 X' P axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');5 x$ n- N: ?( c; H
end
; E: U1 R& G# }9 a; T u% t1 V8 }: G, l5 b
% --- Executes on button press in pushbuttonEnance.+ l' d/ _+ b( R. `1 U
function pushbuttonEnance_Callback(hObject, eventdata, handles): z9 V+ C$ C6 P/ ]2 p9 i5 F' u
% hObject handle to pushbuttonEnance (see GCBO)
- e2 ~7 T( z! N& H) v3 y% eventdata reserved - to be defined in a future version of MATLAB
- `7 w0 Y! n% d/ w% r7 h% handles structure with handles and user data (see GUIDATA)
# }! }0 i1 q" b* _4 f# Wif ~isempty(handles.Result)
. {# C1 O( C Y+ H" S5 Q- J axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
8 y8 l% n: G8 r4 h, E$ @7 K axes(handles.axes2); imshow(handles.Result.Enance); title('增强图像');
7 F. }2 r1 G- ~end
4 i" r: w$ s6 H# v: h ! O7 P$ x$ s/ ^* ^* x
% --- Executes on button press in pushbuttonBwfilter.1 W/ A, g I. }
function pushbuttonBwfilter_Callback(hObject, eventdata, handles)& o& g. Z' B- K5 Y4 C9 ~
% hObject handle to pushbuttonBwfilter (see GCBO)( ~0 }6 g% \& l' L) }% i, O- m
% eventdata reserved - to be defined in a future version of MATLAB: s: x9 m( Z/ [2 k; c) J' B
% handles structure with handles and user data (see GUIDATA)* `: b" ^6 c$ z! ~' A; ?6 O
if ~isempty(handles.Result)* i2 r3 R/ I4 v* o) I! H* m
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
# W: W- f# L' b axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');3 v. o. `+ O: o( v4 K3 ~
axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');
% D2 \ c7 C# V8 _9 uend3 u1 ^+ @& I' }- F: b8 U! V
) a% K, ^) A1 h9 v2 x% ^% --- Executes on button press in pushbuttonCrackRec.: y y: k/ S3 t/ ~! M7 v
function pushbuttonCrackRec_Callback(hObject, eventdata, handles)3 o4 Q, o+ Z1 i& n
% hObject handle to pushbuttonCrackRec (see GCBO)! y# d# s; D O0 j
% eventdata reserved - to be defined in a future version of MATLAB
9 l+ r4 p( ~1 ^* N. _, W/ t0 h' l% handles structure with handles and user data (see GUIDATA)
^& b& I5 j9 U# @. V# x6 u7 p( I' Vif ~isempty(handles.Result)
3 V% b' S8 _% u! @' `4 q' k+ P( ] axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
1 Y& L6 [. }% g/ F5 K9 ?; z9 f axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');
; z, a% ], f" d! Y3 g. T axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');
2 E9 ~: ?6 {% Y* E) T axes(handles.axes4); imshow(handles.Result.CrackRec); title('裂缝识别');/ k) K: f1 {8 s& N
end5 e: c- Y) A0 @
, ^6 K/ N* x6 C1 P1 L* M
; o( S! ?# ]9 T& o: l
% --- Executes on button press in pushbuttonCrackJudge.
9 N! i: y$ l! B2 E( afunction pushbuttonCrackJudge_Callback(hObject, eventdata, handles)/ r7 d+ ]7 a: ?9 r
% hObject handle to pushbuttonCrackJudge (see GCBO)2 H9 G9 Y) Z$ A# T
% eventdata reserved - to be defined in a future version of MATLAB' r7 ^; O$ s# y& Y! x* g
% handles structure with handles and user data (see GUIDATA)
3 N# i# w% \) H5 Pif ~isempty(handles.Result)6 _2 n" x, ~! ~, b- ?
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');3 Z% @- R3 ]- P* H0 Q! S4 J
axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');
}- T# _" Y( P! G axes(handles.axes3); imshow(handles.Result.CrackRec); title('裂缝识别');
' j" Z# }( {6 Y3 T9 w* J/ [ axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝判断');
7 s3 Q9 }' O4 g) m5 Hend
" K* {: z0 o) U3 G 1 V* X& ~ P- e" n
% --- Executes on button press in pushbuttonCrackLoc.; w. V" Q6 [: e! G: k- w* R
function pushbuttonCrackLoc_Callback(hObject, eventdata, handles)
2 Y7 d, ?6 a; l% hObject handle to pushbuttonCrackLoc (see GCBO)
u6 G. p7 R# D: u% eventdata reserved - to be defined in a future version of MATLAB
$ I; A7 ]9 B$ r; Y% handles structure with handles and user data (see GUIDATA)" f, z8 h+ n! W) q
if ~isempty(handles.Result): H& _0 l) E1 f% |2 a
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
+ Y4 V! _4 A, \; d axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');
# Y5 U: W( J* s( F1 [0 x# s! A* O8 B axes(handles.axes3); imshow(handles.Result.CrackJudge); title(handles.Result.str);, ]( K3 g4 [2 y+ K ^
axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝标记图像');
" H- w% f1 S0 \+ U* J; ] hold on;* @+ q9 l0 _0 T/ l1 H0 i
rectangle('Position', handles.Result.rect, 'EdgeColor', 'g', 'LineWidth', 2);3 P0 f v- o: f, ]% n5 Z, @9 H
hold off;
* {+ _) v# H( c; S' Hend5 H% f7 o. ]% C" d' I! d
+ k& c/ p) v% C' g
% --- Executes on button press in pushbuttonProject.
_5 Q" I# T& L( Xfunction pushbuttonProject_Callback(hObject, eventdata, handles)0 \% U( H: G& P' i/ {5 Y V
% hObject handle to pushbuttonProject (see GCBO)
7 Z! D) e! ~. ?4 Z) ~3 T, j% eventdata reserved - to be defined in a future version of MATLAB
3 N( C# [" x4 u& o0 U2 F) O- D% handles structure with handles and user data (see GUIDATA)
2 ] _* o) y5 p5 Q# t- p7 bif ~isempty(handles.Result)0 ?, a7 X2 o w+ V$ A
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
; G6 `0 b; }7 B f. b9 r axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');
- a$ v: M* l+ c! S axes(handles.axes3); plot(1:size(handles.Result.Image, 1), handles.Result.Projectr);
% v) U& T5 K: _# Y: c title('行投影');4 X; d: F- i6 Y
axes(handles.axes4); plot(1:size(handles.Result.Image, 2), handles.Result.Projectc); x& o4 O1 L3 ~# Z3 {/ Z8 Q0 E& ]0 @
title('列投影');1 V, o, F" p' g6 A4 f- U3 t0 B) K
end( ~ Q( f, V8 c/ g
3 K6 k' T1 k- r9 d# t k # a2 p% |, o# A. i' |; b
% --- Executes on button press in pushbuttonClose.
" T$ U! u8 _" w1 f" w2 e; Bfunction pushbuttonClose_Callback(hObject, eventdata, handles)
9 u7 }2 W+ [* z% hObject handle to pushbuttonClose (see GCBO)
; d& W$ z) M5 d- j% P4 v( f- a% eventdata reserved - to be defined in a future version of MATLAB
* i6 W. F+ `8 N8 }, v8 w* B% a: I% handles structure with handles and user data (see GUIDATA)
- w) z; b4 U! R. |5 {choice = questdlg('确定退出?', ...( a/ |$ j7 t6 K! i7 S* _
'退出', ...
& E3 W1 l: \ B8 F '是','否','否');
* v, L3 S( {( N1 X! ^switch choice4 V, D- j: o0 ~8 u: L+ `% C
case '是': ^5 A; y+ p$ V3 {8 e: @
close;
- j+ c1 `. v9 k. F7 P otherwise6 I& l3 P' q3 d7 x6 ]
return;7 ^ E! e$ ~0 n" Z R
end2 g5 V5 T( s. H
5 ~5 f& \7 i* Z0 n. J" u
+ T; |. s' V) p 5 {9 M* {+ c. i! R, K; a* f
% --- Executes on button press in pushbuttonSaveResult.
s5 u( Z6 @! L" O; Y2 G3 ]function pushbuttonSaveResult_Callback(hObject, eventdata, handles)
1 y' K( L9 |! f8 j0 e: {7 }% hObject handle to pushbuttonSaveResult (see GCBO)
3 M2 t" d5 y7 X( q9 E2 m. d. z+ X% eventdata reserved - to be defined in a future version of MATLAB7 U. y" L* T1 e i: R
% handles structure with handles and user data (see GUIDATA)/ m4 J7 L' B/ \8 h
try. k# Y- T2 O! b7 h
if ~isempty(handles.File)/ |0 P4 s" B& Q5 B
raw = [];
; s6 B( f5 {/ B! k9 e" [" j xlsfile = fullfile(pwd, 'Result/result.xls');( W" p) q, E7 R; P
if exist(xlsfile, 'file')
, M3 a n2 ^0 c$ |3 t. Q' } [num, txt, raw] = xlsread(xlsfile);
2 K M: M7 o8 O" P6 N5 j end! C. e9 t' m0 O- E
4 L; a, G+ U; M# b( @* @
F = [];8 D5 @1 y" G- |# q2 @
F{1, 1} = '文件名';7 a) _0 r* G7 N+ B, M
F{1, 2} = '阈值信息';* h% f. F+ r, s- S
F{1, 3} = '面积信息';$ R' {9 ^/ K3 W3 G6 s! \
F{1, 4} = '长度信息';) m, b' ^ @& c8 g
F{1, 5} = '最大宽度信息';( Z; |% a+ y2 m# S
F{1, 6} = '最小宽度信息';
. K& y! i+ ?, q# x! }" Z F{1, 7} = '形状信息';. ^8 t! r* s$ z# n* Z- F3 Z- z
- }! l' o) n% ^) u F{2, 1} = handles.File;9 y5 _' g# n7 A$ ^4 G2 s- e+ ]
F{2, 2} = handles.Result.BwTh;) ]$ |7 {" {( g6 L+ \
F{2, 3} = handles.Result.BwArea;7 Z# {: T8 ^1 i5 j
F{2, 4} = handles.Result.BwLength;3 V1 P: G6 |+ o* t7 M" R
F{2, 5} = handles.Result.BwWidthMax;7 T' E3 S1 B" L
F{2, 6} = max(handles.Result.BwWidthMin,0.01);4 z9 @$ F/ ~6 K* l
F{2, 7} = handles.Result.str;
1 t* z2 ?7 T, D" m8 s: ^
, g& B: g, B! C% Y% b F = [raw; F];
- R0 [, ], i& W0 Z xlswrite(xlsfile, F);
, W% _! f4 o& i4 r+ N , \" ]" u; \3 o& M( O* R
msgbox('保存结果成功!', '信息提示框');
% g# Y6 g1 y! y- ^/ J end
$ D$ U7 t# y- a; V- S( V# l4 Ecatch, w4 G( o8 a7 n' v
msgbox('保存结果失败,请检查程序!', '信息提示框');
! z: |/ w' o) Oend
7 Y( ^- L W! I ) f9 a$ x& L6 [ X9 [& c
; y/ z" J, a7 j/ I; o
% --- Executes on button press in pushbuttonBridge. K9 N; ?0 ]5 e: B8 N8 U' \+ O7 F
function pushbuttonBridge_Callback(hObject, eventdata, handles)# C# S6 ?* n4 v6 u: f
% hObject handle to pushbuttonBridge (see GCBO)1 @. D$ o+ ^5 X" C6 Q
% eventdata reserved - to be defined in a future version of MATLAB% Z. ^0 ?0 a% j
% handles structure with handles and user data (see GUIDATA)
: F1 J' a1 P4 [+ fif ~isempty(handles.Result)
+ J: F- M6 m# U+ l- U* ~ axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
- L2 X- s9 N) G- A axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');7 M S) r; `- L, I: X( x# O
axes(handles.axes3); imshow(handles.Result.CrackJudge); title('裂缝判断');% b: ^2 m/ ~; o# s h& D( K
axes(handles.axes4); imshow(handles.Result.CrackBridge); title('裂缝拼接');
6 m9 T* _( v( u- Fend$ g" U( v; C7 m s: L S, N+ p
; [- W. f( `4 q+ a6 I* W' ] $ w/ _! H. _& R, t
% --- Executes on button press in pushbuttonSaveImage.6 g9 U: T: e" N8 ` i$ h
function pushbuttonSaveImage_Callback(hObject, eventdata, handles)9 r1 X+ r3 }, r" X* j# g) e ]% P
% hObject handle to pushbuttonSaveImage (see GCBO)/ [: h$ p+ g0 k; d V+ U
% eventdata reserved - to be defined in a future version of MATLAB# |- r F4 z+ u& `: F7 |# B2 w N
% handles structure with handles and user data (see GUIDATA)
9 E2 l" `$ W* k5 T0 m" Q7 M[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...* `' Z, z( B7 z) c
'*.*','All Files' },'Save Image',...5 y3 X* F7 B7 m# n3 ?' n: \
fullfile(pwd, 'Result/result.png'));) i* ?0 L- @& ]1 ~
if ~isequal(filename, 0)
6 O. C& S3 f9 l imwrite(handles.Result.BwEnd, fullfile(pathname, filename));% u0 ]& ?, Y$ l) G+ V. ^
msgbox('保存图像成功!', '信息提示框');7 L3 T# K3 b* H& Y
end
. H" t8 Y. |0 i! Z) q
t$ O, c& T3 j
2 n# s& e( G# V- K4 [" S! ]% --- Executes on button press in pushbuttonDiplay.. X' `0 m7 m* F) r$ l
function pushbuttonDiplay_Callback(hObject, eventdata, handles)
6 b) D: x% A ^8 Z" ~% hObject handle to pushbuttonDiplay (see GCBO)4 G; g, D" k! b
% eventdata reserved - to be defined in a future version of MATLAB
, {$ o, f# I0 ~5 ]% handles structure with handles and user data (see GUIDATA)
7 i/ }- N4 i) ~1 i2 S7 K/ Nif ~isempty(handles.File)
3 F7 B" {% i4 z: k: V F = [];. |' {+ ~( H, x% o, N7 [
F{1} = sprintf('文件名:%s', handles.File);
9 Z9 j+ J( S2 I8 h9 y5 b! } F{2} = sprintf('阈值信息%.2f', handles.Result.BwTh);7 w, \) U3 f9 E+ ]
F{3} = sprintf('面积信息%.2f', handles.Result.BwArea);
7 S) b$ g) t1 Y" j F{4} = sprintf('长度信息%.2f', handles.Result.BwLength);7 ^- t' ^# ?1 r
F{5} = sprintf('最大宽度信息%.2f', handles.Result.BwWidthMax);5 P7 a5 I' M8 F: E% I6 \
F{6} = sprintf('最小宽度信息%.2f', max(handles.Result.BwWidthMin,0.01));
7 @' \$ X3 ~& E. Y0 M0 b$ M2 j F{7} = sprintf('形状信息%s', handles.Result.str);6 Y# v9 K/ n) S9 O( R! L
listdlg('PromptString', '参数显示:',...3 O/ g A { R% `) B: ~( v
'Name', '参数信息', ...
1 V$ b4 J( x& S! l5 J. G$ Y- g 'ListSize', [300, 150], ...
' U) k! V X: k( `7 p 'SelectionMode','single',...
) Z+ G3 O* |5 f W ^, c9 S6 S/ @ 'ListString', F);0 Q* m# i5 T, y) G8 w$ I
end" |7 @2 ]8 B% ]8 _$ k4 @; \
7 _; Z/ z3 W8 k& ]3 K三、运行结果7 j$ ^* [6 k& _6 L% e
( v# T. l$ a$ a+ r
) E4 M, O- k. T- n* F, ^
6 a, b: W4 J9 ?; e& J+ `3 b9 X' X) ?# S+ C
. g0 {7 `5 E+ }# u& K1 N |
|