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

基于matlab GUI路面裂缝识别

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x

) o: k  [- I" \7 J# {" ^9 h一、简介
' t3 Y9 F5 w4 o; U高速公路路面病害养护和管理的重要部分就是路面裂缝的检测。近年来,路面裂缝自动检测技术已得到了广泛应用,而由于路面裂缝图像的复杂性,检测算法直接影响着检测结果的精确度。因此,本文将重点放在路面裂缝病害的检测上,为了提高检测的精度,分别从裂缝图像的去噪、图像的增强、图像的分割以及检测后路面裂缝图像的特征提取方面进行深入研究。  在路面裂缝图像中,由于裂缝信息与背景对比度偏低,难以将裂缝直接检测到。对于图像的预处理,首先对图像进行灰度校正,再对校正之后的图像滤波,本文提出了一种改进的中值滤波方法,对图像进行去噪,之后用基于模糊理论的图像增强原理对图像做进一步增强,有效提高了路面裂缝图像的对比度。  针对路面裂缝图像分割,本文分别用了阈值分割和基于形态学多尺度的思想,对于形状规则的裂缝采用的是阈值分割,对于裂缝形状不规则的图像,本文设计了一种多结构元素的抗噪型边缘检测算子,且依据不同形状的结构元素对裂缝边缘填充的几率不同,确定了自适应权重,使得算子检测到了各种类型的裂缝边缘,有效地提高了检测的精度。  对于经过分割后的路面裂缝图像中存在噪声和裂缝断裂的问题,本文对于断裂较窄的图像用形态学中的闭运算和开运算去处理,对于断裂较宽的图像,提出了一种基于生长的断裂裂缝块的连接方法。提高了连接的效率和准确率,使整个检测结果清晰完整。最终,从识别结果图中提取裂缝信息。根据得到的识别结果图,设定一系列判定条件,提取出裂缝的连通域,对裂缝的类型进行判断,最后计算出网状裂缝的面积及线性裂缝的长宽信息。
0 g) G% J6 D0 ]  y, G# J, `" c. C/ W7 t% [
二、源代码# @; ~* @" K* o1 h
function varargout = Gui_Main(varargin)+ z' X' K% i* S; G6 ]
% GUI_MAIN M-file for Gui_Main.fig
, L4 K1 x+ ^" R9 n%      GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing
+ F$ [+ x3 Y3 l4 }%      singleton*.. t4 w- p  J# Q
%
( p) \" U6 s$ i8 J; C6 q: Z%      H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to
2 Q3 C! v3 s3 v2 T%      the existing singleton*.
+ H# {' O7 @' E! H: `+ j2 R+ s3 S  v%7 f- Q, }5 N# p& d9 Z5 ~( i
%      GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
5 s# l2 }  n) R! E%      function named CALLBACK in GUI_MAIN.M with the given input arguments.
' {: S% K" J5 f%
# z' \0 t5 o6 y1 C6 q%      GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the; O, t. w2 T3 N$ s1 O% u8 R
%      existing singleton*.  Starting from the left, property value pairs are2 B& ~0 f9 i* c  {- [% y1 o4 O
%      applied to the GUI before Gui_Main_OpeningFcn gets called.  An
+ w. _; G& J3 q5 ]- y5 r. y%      unrecognized property name or invalid value makes property application
4 R1 i/ ~; D  B; D/ w%      stop.  All inputs are passed to Gui_Main_OpeningFcn via varargin.
. }' e7 a' L* e! m% H%7 {' _0 r  p, q, n1 L, ?- _
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one" F. o% }4 x2 W
%      instance to run (singleton)".6 W4 r% \8 v6 U& J7 u2 l1 ^
%* i' Y3 w% x) T6 L3 E
% See also: GUIDE, GUIDATA, GUIHANDLES
; F* ]0 `- Q5 C
+ F$ ?& S8 k, ?7 I9 Y% Edit the above text to modify the response to help Gui_Main+ S) g  S: t3 Y2 R6 r# A
5 h( e. G1 V2 M) l0 @4 m
% Last Modified by GUIDE v2.5 29-Mar-2011 22:28:58; O3 b: x( {. ^( x4 _# {

! p' ]; x. b- B& C. O% Begin initialization code - DO NOT EDIT
5 ~& V. O6 r2 z9 [$ @, T4 Ngui_Singleton = 1;% [# L& t# m& z9 e3 b' p
gui_State = struct('gui_Name',       mfilename, ...
. F+ x" [  V' @6 T- ]7 h* w    'gui_Singleton',  gui_Singleton, ...% {) N6 ^0 s  |* e5 F5 W
    'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...! _3 t7 O3 D2 P+ {) i
    'gui_OutputFcn',  @Gui_Main_OutputFcn, ...% A1 P/ [4 n' r" K
    'gui_LayoutFcn',  [] , ...
- F+ ~' w: n' v5 |" O    'gui_Callback',   []);8 D7 O; w) I5 k/ E
if nargin && ischar(varargin{1})
) m) C  `* T! J1 H    gui_State.gui_Callback = str2func(varargin{1});
6 d3 z7 G/ W& r2 j; `) g; Send
( E3 C8 v. j. O( s3 C1 s, [ 8 O9 |8 Y$ i. {" k+ ^5 y
if nargout" B) h  I) U% L8 W8 ?6 L
    [varargout{1:nargout}] = gui_maiNFCn(gui_State, varargin{:});" r7 ^2 b) E! ], L# L% n  ?8 \
else3 P" A$ O5 ^% \/ _3 {- t6 N
    gui_mainfcn(gui_State, varargin{:});
3 ?) V* B5 U0 lend9 U5 M. N) d& M) r/ t' x9 W5 W: C
% End initialization code - DO NOT EDIT" {( A0 C' ~0 a' m/ E
2 `; }  d, u$ O) j; n. Y- u

8 [, o0 P0 g) W4 z) @( A% w% --- Executes just before Gui_Main is made visible.9 z9 ^/ s! C8 r. ?
function Gui_Main_OpeningFcn(hObject, eventdata, handles, varargin)( }( l4 ^; H* w- S* g! C
% This function has no output args, see OutputFcn.
  M" t; V1 ^7 M% hObject    handle to figure
# Q- x  ~8 b/ m# ?+ d. E" r6 [3 e* Q% eventdata  reserved - to be defined in a future version of MATLAB' i. y0 d9 e; ]" U' h
% handles    structure with handles and user data (see GUIDATA)
! w. u9 `# A+ [' [8 X4 V5 N: \) _% varargin   command line arguments to Gui_Main (see VARARGIN)1 y4 a" H1 {! ?
5 F, J% Z" ~( r) B/ G1 B
% Choose default command line output for Gui_Main
' Z: g- W) y: Z7 o5 o) Whandles.output = hObject;$ A. K' H0 c6 G7 w
handles.Result = [];
# M8 v0 u# V" V5 v! U  _2 Lhandles.File = [];7 o9 _2 I$ ^& J" x4 R2 ?
% Update handles structure
7 Y$ m/ O9 i; Uguidata(hObject, handles);
3 D) C. A$ J- \clc; warning off all;
' l8 o! D- j. EInitAxes(handles);0 d' I4 [5 @: H/ L# c1 N
# p  s; Q* f- a7 k) j0 R
% UIWAIT makes Gui_Main wait for user response (see UIRESUME)
" U7 t0 \  y, g' L: w# D+ e% uiwait(handles.figure1);
, L0 u4 o* V" X( H: O1 R ; r. ~8 |' J4 @0 z+ J$ w- f3 j

1 T+ Z, r& C+ c, c9 o! n3 w( l% --- Outputs from this function are returned to the command line.8 S" g( N/ T, q( v: a
function varargout = Gui_Main_OutputFcn(hObject, eventdata, handles)
2 G/ ?8 F9 z/ }+ J+ j% varargout  cell array for returning output args (see VARARGOUT);
: a" m9 R: Y* h; |& P: N% hObject    handle to figure
, @) h8 d  x2 o! u9 T2 H/ }% eventdata  reserved - to be defined in a future version of MATLAB
8 d" T0 B8 ~  c4 U0 Z% handles    structure with handles and user data (see GUIDATA)  D9 ?5 k& D# m' C

2 U+ z, |0 V2 U5 A9 `3 u! @% |% Get default command line output from handles structure
9 [8 n& N! I2 Q  g7 Kvarargout{1} = handles.output;" k" D$ p; w8 c9 I" H

$ s% ]1 V# ^, Q* K3 X
; g) Z5 c8 K$ W3 d; q9 |3 a  D5 f% --- Executes on button press in pushbuttonOpenFile.) N9 H9 E4 K5 d8 }1 c. D/ G7 l
function pushbuttonOpenFile_Callback(hObject, eventdata, handles)
4 a) g2 j7 b. d0 u* o! P# v. Q1 D% hObject    handle to pushbuttonOpenFile (see GCBO)5 e( I; j, G' [' y/ L
% eventdata  reserved - to be defined in a future version of MATLAB& D8 K& F' s' K1 k
% handles    structure with handles and user data (see GUIDATA)" w' F; T# k9 M# X' ^
[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bmp','All Image Files';...
2 L  M9 C, ?6 W, _" C& O    '*.*','All Files' },'载入图像',...
. k9 ?  M; W6 Y! z; z6 n+ O    fullfile(pwd, 'images'));
1 S5 n9 a$ Y, g7 @6 ]$ D# `( t& \if isequal(filename, 0) || isequal(pathname, 0)
* P. i- Q0 g- |) @/ |. k8 d# T# f    return;) S8 F+ f5 H& G5 i# Q1 \/ ?( Z
end0 q( Z9 X; P/ A0 Z# t
I = imread(fullfile(pathname, filename));0 C9 S& J+ ?) i! c; D
Result = Process_Main(I);; H  L6 w/ Q7 k5 Z
handles.File = fullfile(pathname, filename);
9 z. ?5 V: q( l1 \" U9 Phandles.Result = Result;$ x: E2 I' i8 f2 y* Y
guidata(hObject, handles);
" f" I' m+ \0 hInitAxes(handles)
4 V, S( r+ W9 [3 jaxes(handles.axes1); imshow(handles.Result.Image); title('原图像');% p  R! x" _# n

$ A3 M4 K; f7 q
/ ]; w4 M5 J+ n' I7 k+ b- i  W5 W% --- Executes on button press in pushbuttonHisteq.7 _: j% S! l; V* H; i( @
function pushbuttonHisteq_Callback(hObject, eventdata, handles)1 u7 V' u; \, a$ U; |/ x
% hObject    handle to pushbuttonHisteq (see GCBO)2 J' Z+ O8 R. W7 U+ f
% eventdata  reserved - to be defined in a future version of MATLAB: m3 X8 F* n9 l! T0 v& l
% handles    structure with handles and user data (see GUIDATA)3 M3 g: B* y9 P( e/ y
if ~isempty(handles.Result)
& S' {& I" E9 o4 E; Q/ i    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');! }, y$ [" g9 |7 x9 ]' S- L
    axes(handles.axes2); imshow(handles.Result.hist); title('直方图均衡化图像');
  ?6 h% S% m7 u6 w6 ^; U- oend2 F: S6 q$ o" Q3 r) D' L
9 c7 Z! Y& M% n+ J7 z
# m& D" {. d7 }$ K' W6 d
. x3 r* m% k2 t0 ~6 e* ~* p1 \0 n. J
% --- Executes on button press in pushbuttonMedfilt.- K# j% p* ~( a  M: [/ ~5 b3 t! a% F
function pushbuttonMedfilt_Callback(hObject, eventdata, handles)
; f/ j* V$ X4 i. O  D1 m7 I, I% hObject    handle to pushbuttonMedfilt (see GCBO)% i' F! q2 }) r; v& @( i3 u" {
% eventdata  reserved - to be defined in a future version of MATLAB
8 p) L+ Y4 O. L) Z6 y% handles    structure with handles and user data (see GUIDATA)
) s# r% k$ Z+ [4 tif ~isempty(handles.Result)
; ?$ L4 {7 m8 g7 `    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');, k6 r' B% m  {) v$ i8 u
    axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');7 K2 s3 c4 b0 c
end$ ~/ U4 {0 n0 c3 A5 j
# D8 e5 F8 v9 {$ x: O/ K9 p

+ v3 j/ X& ?. S( P% --- Executes on button press in pushbuttonBw.' J) D/ R5 Q/ ]: v
function pushbuttonBw_Callback(hObject, eventdata, handles)$ Q+ _( S) Z- |: Q: E
% hObject    handle to pushbuttonBw (see GCBO)
3 F+ s6 s- ^* @, q7 G% eventdata  reserved - to be defined in a future version of MATLAB, K! D  o- M7 F  m7 O8 C: k
% handles    structure with handles and user data (see GUIDATA)
- Q" }" }7 f3 E2 Z# J. }0 }# gif ~isempty(handles.Result)
. z1 I* A& Z, I+ o" z0 D    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
' V4 \& H. {# H7 q+ J, J+ a0 f    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');
8 q5 M9 U& r8 aend
1 W; R  E$ [+ e' B * e7 D# u" j; I" C8 Y0 d% o
% --- Executes on button press in pushbuttonEnance.
3 q! C( }, k$ @- N/ L4 H+ Q1 I6 {! Bfunction pushbuttonEnance_Callback(hObject, eventdata, handles)) {$ y3 a3 O& H, }( v* c0 ^2 J
% hObject    handle to pushbuttonEnance (see GCBO)
4 ?& n. n$ _+ j4 j) B9 f8 T% eventdata  reserved - to be defined in a future version of MATLAB7 T: V; h+ v( F7 p: q- e4 k
% handles    structure with handles and user data (see GUIDATA)
3 @% B0 ~$ J! [5 qif ~isempty(handles.Result)
+ ?& I- F6 c5 H- `    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');: X6 r& [- e& O1 q5 C2 t
    axes(handles.axes2); imshow(handles.Result.Enance); title('增强图像');0 [' U. w( r! _$ @1 n) ?3 ]
end
& f7 s6 k! c' g. S( [ 2 _& m5 m$ I$ X! j7 r2 B
% --- Executes on button press in pushbuttonBwfilter.0 t% a- C& t; u1 N4 e, k# V. u
function pushbuttonBwfilter_Callback(hObject, eventdata, handles)
3 v. R6 ~- j8 ~4 b, X" s+ i; D% hObject    handle to pushbuttonBwfilter (see GCBO)( k2 L5 L9 X( v" d1 ?! a: a
% eventdata  reserved - to be defined in a future version of MATLAB
7 S6 d3 C) Q1 e5 z" F8 h+ S% handles    structure with handles and user data (see GUIDATA)9 Q& h% ?+ P& _, h: c% p
if ~isempty(handles.Result). e) Y- i. r, m' ~( y
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
$ j2 m1 R; C. }+ m& x) T: a' H3 Z    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');
- L4 u* I' u2 r2 n  f3 }1 I& \4 c    axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');
/ M7 ]6 u4 ?# ^8 S1 l& Xend4 _. F7 Y% m/ W& v% @

3 T/ q; o/ D( y% --- Executes on button press in pushbuttonCrackRec.
! Z2 G% n  M* g' ^* T0 o  G+ ~function pushbuttonCrackRec_Callback(hObject, eventdata, handles), V, U" T% B, Z  ~3 P+ m
% hObject    handle to pushbuttonCrackRec (see GCBO)
- ]0 J# M& l# q( w% eventdata  reserved - to be defined in a future version of MATLAB
: u0 z; C7 c0 Y7 U8 x% handles    structure with handles and user data (see GUIDATA)0 I. K( T4 b" g0 {) H+ {% u
if ~isempty(handles.Result)
- H% h6 Y, W5 Y9 H7 i& X0 W    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
& {. P& T: Z% C, t2 l& R, @) d    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');0 P, z. [/ ?: k; ?/ Q# X2 `
    axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');3 H; _0 i* a: _2 N
    axes(handles.axes4); imshow(handles.Result.CrackRec); title('裂缝识别');) J: c8 W2 P/ ^0 [( T1 A0 ]
end
0 }) C+ Q+ l& V& L# a! b ( r0 ?$ r) M/ l9 ^+ e

# B; y/ O& P; B  \8 g% --- Executes on button press in pushbuttonCrackJudge.
7 n& `1 j- o4 b3 e+ S+ gfunction pushbuttonCrackJudge_Callback(hObject, eventdata, handles)
0 f3 M% m$ j5 H6 @$ P% hObject    handle to pushbuttonCrackJudge (see GCBO)
" a+ g; A/ ?+ T6 E% eventdata  reserved - to be defined in a future version of MATLAB+ D# g& L8 K4 }# y- y6 L
% handles    structure with handles and user data (see GUIDATA): b% h1 m& V( _/ G$ p  \
if ~isempty(handles.Result)6 P( P6 @  B5 E  W) `
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
. w9 S$ [! ^& t    axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');% o( k: ?! y6 X2 b; _- m0 p! M
    axes(handles.axes3); imshow(handles.Result.CrackRec); title('裂缝识别');
& ?/ d& t% t3 m) ~/ U    axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝判断');
. p/ {7 b6 @6 b  o/ }& D0 l; uend
/ `% C4 C- C5 E% z- c5 o) F& R  \ * C8 F' W- I. l' u9 q
% --- Executes on button press in pushbuttonCrackLoc.
5 M* f0 ^$ V' P* ]- Afunction pushbuttonCrackLoc_Callback(hObject, eventdata, handles)
3 v( k% P- Y9 m1 i% hObject    handle to pushbuttonCrackLoc (see GCBO)
# T7 o: ?  t# k% eventdata  reserved - to be defined in a future version of MATLAB
& s2 P- H. s9 ?( v5 R% handles    structure with handles and user data (see GUIDATA)
; Z. b' Q: @" r) }if ~isempty(handles.Result)* u# ^4 z; w6 k1 f) K) y2 R
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
, j- y$ T1 h& {    axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');  h& l/ [/ B6 W. e3 C# u2 }
    axes(handles.axes3); imshow(handles.Result.CrackJudge); title(handles.Result.str);, |1 W' F4 a4 V& y8 Z8 e* [
    axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝标记图像');* t$ g9 q% K2 ^1 Q1 `
    hold on;, t$ z9 F" g. b. V2 x
    rectangle('Position', handles.Result.rect, 'EdgeColor', 'g', 'LineWidth', 2);3 R! m' Z( w0 I" u
    hold off;
$ F# R  ?7 N+ ]; p2 @end7 c( `) o: o1 F8 ~8 m

+ r' b0 r& h+ S: u% --- Executes on button press in pushbuttonProject.
8 [. e. ^; N3 a2 x5 B* zfunction pushbuttonProject_Callback(hObject, eventdata, handles): U7 |; L& p1 S; f0 c$ C
% hObject    handle to pushbuttonProject (see GCBO)
" P- O- n% Z! L0 l% eventdata  reserved - to be defined in a future version of MATLAB& y' H( O% v0 @
% handles    structure with handles and user data (see GUIDATA)
- h. H: Y) L' d! g" |if ~isempty(handles.Result)
/ Q* F& Y; W+ O# f9 y" _    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
; {$ v' I1 e6 ]; ?( P    axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');
7 r2 I5 u& Q9 V3 g& k) V) n    axes(handles.axes3); plot(1:size(handles.Result.Image, 1), handles.Result.Projectr);
$ G1 p7 |  T/ b' B# ?: X    title('行投影');
  P4 U% k/ D. R& C6 J    axes(handles.axes4); plot(1:size(handles.Result.Image, 2), handles.Result.Projectc);
; f. o$ K/ X+ }# T1 B8 {    title('列投影');0 v3 f" X8 D( A$ }: k- f
end8 Y: _' B. M% V; V

9 b( }2 s/ i& C2 C% d0 l1 M, U+ r . C; b+ x4 d% O) x- A
% --- Executes on button press in pushbuttonClose.
0 |" N/ ~' C, Pfunction pushbuttonClose_Callback(hObject, eventdata, handles)
1 `+ K% S; }- X( H& _9 R& S% hObject    handle to pushbuttonClose (see GCBO)
' d+ Z& l: l5 M( d7 T: M: U% eventdata  reserved - to be defined in a future version of MATLAB) m/ ^$ E, k, e8 U9 `$ K, t" l3 O
% handles    structure with handles and user data (see GUIDATA)& G: k6 V' y1 [
choice = questdlg('确定退出?', ...
9 H* O. n# \) \, Q5 z9 t! Q    '退出', ...2 j' U5 N' ^2 @
    '是','否','否');& O. b. V4 Y' x8 Q: {( j
switch choice9 _0 K. L# b. n. V5 B/ E3 M2 {# R$ q
    case '是'
$ I+ z6 r, w) H+ c        close;! ?! w# `+ c0 _* t2 z
    otherwise; A5 g7 k3 D6 O& U
        return;3 `# {3 E# y2 E: J* W* D( z& f
end
; b/ r* U& a0 N3 q
; q+ z* Y* _- o4 w6 i
7 j2 z# `9 B# O- O
6 n! A8 s& h- s7 _% --- Executes on button press in pushbuttonSaveResult.# Q9 J. s; `+ q$ q
function pushbuttonSaveResult_Callback(hObject, eventdata, handles); a; V3 Y" A! |! G
% hObject    handle to pushbuttonSaveResult (see GCBO)
& f  g9 R% @' p7 c- S% eventdata  reserved - to be defined in a future version of MATLAB% U* i5 t5 i- e# h
% handles    structure with handles and user data (see GUIDATA)
  G- p& z  U4 ~/ ?2 \- Atry3 N; u, L2 f- l
    if ~isempty(handles.File)& l3 C! ^( d' |& n! D3 Y, L
        raw = [];
' [& {( t* r* m- h6 p        xlsfile = fullfile(pwd, 'Result/result.xls');% o  w# A; a$ L* V6 R5 _( w
        if exist(xlsfile, 'file')" d9 A# J! z  t% r* T  u- S: s& O
            [num, txt, raw] = xlsread(xlsfile);
! q2 y) x; \7 W7 ?. A7 \0 H: d8 W) s        end
) p, A% S9 w; y) H' L% H6 v* ?; g        : ~7 M: s/ @) X1 h
        F = [];
7 ]" u+ Y- ^3 `6 Q        F{1, 1} = '文件名';
! k) k$ t2 M) J6 C        F{1, 2} = '阈值信息';( F; C( q1 T  G- b- T% {
        F{1, 3} = '面积信息';
% `. {! K) D; c& c        F{1, 4} = '长度信息';
% C9 I% l8 S' B. A6 n' ]3 d) d        F{1, 5} = '最大宽度信息';% ^8 _: f- P8 d* R8 f; @9 c' Y- Z! v
        F{1, 6} = '最小宽度信息';+ V8 \0 c, o$ k8 t* r
        F{1, 7} = '形状信息';
' a: w+ Y( d( u1 n. D. g% h& Z) ]        / a# I: l+ m# X; e- I+ P4 a
        F{2, 1} = handles.File;
* |( G: J. S8 o0 A2 {7 Q* H        F{2, 2} = handles.Result.BwTh;
: d/ _6 @' ^- i1 _# T% b, |3 p  W        F{2, 3} = handles.Result.BwArea;* Z( c9 s2 l* a( L  i0 G
        F{2, 4} = handles.Result.BwLength;' C, e" U& f* v: i
        F{2, 5} = handles.Result.BwWidthMax;
5 g3 M/ J; n1 X1 ]0 h( g3 N        F{2, 6} = max(handles.Result.BwWidthMin,0.01);
& O8 I4 z. Z! U; H. T. L        F{2, 7} = handles.Result.str;4 A4 g9 \0 w- O$ Q
        
6 |/ i% z; f9 s7 p        F = [raw; F];6 w( J, k8 ^" g. V* E# Q& o
        xlswrite(xlsfile, F);, y/ O4 T; T# E
        3 \7 I2 Y0 r  O$ o5 A
        msgbox('保存结果成功!', '信息提示框');
& B( T$ x( d/ h    end
; P2 w: o3 t5 acatch
+ \" J, j- p! H6 \1 u    msgbox('保存结果失败,请检查程序!', '信息提示框');
# u5 P! b* n, Oend
# O- Q+ C0 W& r( j1 L2 G+ @ / I( f" ~3 Z* O" W6 v8 K

- w! v7 Q/ Q2 [: w, x7 L% --- Executes on button press in pushbuttonBridge.. Q7 N( b/ z# r4 D. o* @
function pushbuttonBridge_Callback(hObject, eventdata, handles)1 G( L# D+ P/ ~5 D2 Q% \
% hObject    handle to pushbuttonBridge (see GCBO)/ d* j4 R. s1 X* v
% eventdata  reserved - to be defined in a future version of MATLAB
' a+ H' S1 F1 Q- C6 U& j  t% handles    structure with handles and user data (see GUIDATA): q" X  {6 _  u+ x7 g
if ~isempty(handles.Result)
$ J# `0 y5 ]. a9 o    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');1 V2 Q/ H; V4 t' y' x6 q
    axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');
7 M, p* G/ ~% |6 a    axes(handles.axes3); imshow(handles.Result.CrackJudge); title('裂缝判断');
# v; C( r0 l1 E( m. f4 l    axes(handles.axes4); imshow(handles.Result.CrackBridge); title('裂缝拼接');5 J( _( X( r( v$ L9 ^0 x: j
end: t; s8 Q+ n5 U3 I1 P

& Y1 j4 t& X4 G. ] 6 ~+ k3 v( a% _( B  P
% --- Executes on button press in pushbuttonSaveImage.
, h; a4 H6 d1 ?0 @. [function pushbuttonSaveImage_Callback(hObject, eventdata, handles)$ b7 `8 J) A- r0 \. t1 N7 W
% hObject    handle to pushbuttonSaveImage (see GCBO)+ r* B0 S. x' O* t
% eventdata  reserved - to be defined in a future version of MATLAB
0 C: x5 T; I& a9 ?9 E' I% handles    structure with handles and user data (see GUIDATA)/ ]0 F4 Z& d% T" M& T. R/ k' ]
[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
2 a9 ?9 s2 o, V    '*.*','All Files' },'Save Image',...% a( P9 {2 }, {, p8 ^: m* T/ u
    fullfile(pwd, 'Result/result.png'));
$ P8 J/ d8 e  ~9 fif ~isequal(filename, 0), ]- w& E7 b" m% P
    imwrite(handles.Result.BwEnd, fullfile(pathname, filename));0 J+ O, Z! O+ w  H& P# n1 p
    msgbox('保存图像成功!', '信息提示框');
& g  p4 l; i8 e; Nend
3 l( W7 i& E1 N7 ^: Z/ D " |8 v1 u& h4 a" x4 h& J- T) |
2 ?4 b' t! ?- B2 Q. z: ~( v
% --- Executes on button press in pushbuttonDiplay.. Y+ Y' T, u. A4 F% ?
function pushbuttonDiplay_Callback(hObject, eventdata, handles)" j8 V3 R$ T2 D& `2 b+ r0 t9 ]
% hObject    handle to pushbuttonDiplay (see GCBO)9 y8 u: Z! F3 C, j4 t
% eventdata  reserved - to be defined in a future version of MATLAB
( i" s! a* z5 U: N; g7 h% handles    structure with handles and user data (see GUIDATA)
1 S6 U/ M* I" o" V5 cif ~isempty(handles.File)
$ S5 O( X' K+ \) e7 Z4 Y    F = [];! q6 R0 Z5 F! o2 n
    F{1} = sprintf('文件名:%s', handles.File);" u% ]/ R+ m. Z! ^( J1 O3 }9 q
    F{2} = sprintf('阈值信息%.2f', handles.Result.BwTh);
" D1 `* B1 r9 R  |    F{3} = sprintf('面积信息%.2f', handles.Result.BwArea);! k- Y+ p4 b$ r* ~8 P9 D1 i5 X
    F{4} = sprintf('长度信息%.2f', handles.Result.BwLength);4 ]4 ^1 |$ D7 B7 W
    F{5} = sprintf('最大宽度信息%.2f', handles.Result.BwWidthMax);) Q9 P3 ^1 y* a. [% A3 O, e- g
    F{6} = sprintf('最小宽度信息%.2f', max(handles.Result.BwWidthMin,0.01));
" V+ G( M$ X  m' T% ]    F{7} = sprintf('形状信息%s', handles.Result.str);, x+ f2 M: @' J; T" O( ~( G
    listdlg('PromptString', '参数显示:',...
, r7 \; T7 M5 M- V        'Name', '参数信息', ...
- X, u8 E( k. S6 s        'ListSize', [300, 150], ...0 [  G6 h& q9 `  d  W
        'SelectionMode','single',...
1 M' z; i, `0 w) }' u& e% j6 Q        'ListString', F);
4 V3 Z9 z# V1 z( A+ B5 S" lend
0 O+ S: a- Z5 B: {! \: t1 @
3 ~7 Q% Q  Q  l1 ^3 n三、运行结果
8 g* C- ~/ X. U! B5 i8 z" v; d. D% A
7 `# h( A: R: E1 E
6 c4 y/ ^, p8 g) j- j  ~; u
3 |( U& S7 l4 r0 e$ O
8 o$ [% {& A, @0 K3 B

该用户从未签到

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

本版积分规则

关闭

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

EDA365公众号

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

GMT+8, 2025-10-6 09:18 , Processed in 0.156250 second(s), 26 queries , Gzip On.

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

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

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