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

基于matlab GUI路面裂缝识别

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x

. \7 F& _/ i0 S# `0 g- R一、简介. P1 z% X: W; O) V
高速公路路面病害养护和管理的重要部分就是路面裂缝的检测。近年来,路面裂缝自动检测技术已得到了广泛应用,而由于路面裂缝图像的复杂性,检测算法直接影响着检测结果的精确度。因此,本文将重点放在路面裂缝病害的检测上,为了提高检测的精度,分别从裂缝图像的去噪、图像的增强、图像的分割以及检测后路面裂缝图像的特征提取方面进行深入研究。  在路面裂缝图像中,由于裂缝信息与背景对比度偏低,难以将裂缝直接检测到。对于图像的预处理,首先对图像进行灰度校正,再对校正之后的图像滤波,本文提出了一种改进的中值滤波方法,对图像进行去噪,之后用基于模糊理论的图像增强原理对图像做进一步增强,有效提高了路面裂缝图像的对比度。  针对路面裂缝图像分割,本文分别用了阈值分割和基于形态学多尺度的思想,对于形状规则的裂缝采用的是阈值分割,对于裂缝形状不规则的图像,本文设计了一种多结构元素的抗噪型边缘检测算子,且依据不同形状的结构元素对裂缝边缘填充的几率不同,确定了自适应权重,使得算子检测到了各种类型的裂缝边缘,有效地提高了检测的精度。  对于经过分割后的路面裂缝图像中存在噪声和裂缝断裂的问题,本文对于断裂较窄的图像用形态学中的闭运算和开运算去处理,对于断裂较宽的图像,提出了一种基于生长的断裂裂缝块的连接方法。提高了连接的效率和准确率,使整个检测结果清晰完整。最终,从识别结果图中提取裂缝信息。根据得到的识别结果图,设定一系列判定条件,提取出裂缝的连通域,对裂缝的类型进行判断,最后计算出网状裂缝的面积及线性裂缝的长宽信息。
0 m: w, y; h$ A4 O7 v6 \- f2 I& o, e2 w3 L* h6 c4 [9 X
二、源代码- E1 P" Z+ \$ R
function varargout = Gui_Main(varargin)
% }" e9 M3 f5 b( h& m- x% GUI_MAIN M-file for Gui_Main.fig1 C6 p  Y& C% A2 d/ k! d3 @& O
%      GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing
; _# L2 H! y& A2 n/ G%      singleton*.
; P) J! O8 E: V  z: g%; K4 ~4 E4 p0 X9 i, K: q
%      H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to: C) q& B( M4 W% a3 ^0 Y* ^9 w
%      the existing singleton*.
; m6 m! }8 Q& v5 \%
) b- c& d0 b7 y4 b%      GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local: ~. ^9 w. S. m2 |
%      function named CALLBACK in GUI_MAIN.M with the given input arguments.4 U9 b) o- S( d9 v! k0 D4 J7 O
%1 q; w& Z  b4 N/ z
%      GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the
5 `" f8 p4 K/ a( d%      existing singleton*.  Starting from the left, property value pairs are: v$ f& q+ ~& Y9 s9 P  A
%      applied to the GUI before Gui_Main_OpeningFcn gets called.  An" X( ?4 ?0 h/ x( Y8 D
%      unrecognized property name or invalid value makes property application5 @: I+ j1 y  W
%      stop.  All inputs are passed to Gui_Main_OpeningFcn via varargin.2 V( F0 g$ _! ]+ h$ E) }
%* j: W" X, T3 ]$ h7 b, J3 x
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one; {0 T1 U0 C" ], x, r
%      instance to run (singleton)".7 v! ]! x/ [' U" Q
%: {- w! p* y0 J6 P3 f& O' U6 {
% See also: GUIDE, GUIDATA, GUIHANDLES, S$ _4 \. U) S, y( M' [( ]

) Q7 u/ s& a5 h& L% Edit the above text to modify the response to help Gui_Main4 z6 R0 C) X$ n& d# Q' S9 B$ ]5 H
$ R8 b  x8 W' G$ f4 }- S
% Last Modified by GUIDE v2.5 29-Mar-2011 22:28:586 R% K8 x* D2 D. [

2 A/ {$ R4 O, Z- P8 D# n; t" n% Begin initialization code - DO NOT EDIT
0 j7 Y( g; ~, O: S) D  Sgui_Singleton = 1;
( C, ]+ L: q+ p9 I& ggui_State = struct('gui_Name',       mfilename, ...
+ U  D. `* r3 v$ K    'gui_Singleton',  gui_Singleton, ...
- B2 p+ r3 v/ s( P. n$ X6 L8 W& n5 f    'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...1 N3 I4 x! X$ }$ r# ]
    'gui_OutputFcn',  @Gui_Main_OutputFcn, ...: H: L2 c4 }9 l# b0 I! I, I
    'gui_LayoutFcn',  [] , ...$ W9 z9 x0 I6 r
    'gui_Callback',   []);
: D0 z/ L3 j$ T4 Lif nargin && ischar(varargin{1})* ^7 @( `0 L! B% e" c
    gui_State.gui_Callback = str2func(varargin{1});" \) v' a) k' b  Q* z" f6 y% B* N1 U
end/ Z6 }1 P; E+ k" H

) J# r% ^  Q( lif nargout
) m* n2 G* L8 Q* B" @  K( P' B    [varargout{1:nargout}] = gui_maiNFCn(gui_State, varargin{:});8 a: D+ J, ~# _5 Z' T, z6 z
else
+ [" \& }8 I/ j4 |$ Z    gui_mainfcn(gui_State, varargin{:});
% t0 J' K  i* z+ K3 b# Fend$ Y+ A0 u2 M3 T7 Z& n1 Z  i
% End initialization code - DO NOT EDIT
; `* b% A3 D$ Y# H 7 Y) b; D0 k8 [7 P

1 S% r. U2 n) F* N; U+ h% --- Executes just before Gui_Main is made visible./ r7 v8 J, D+ j# o0 z  ]3 X
function Gui_Main_OpeningFcn(hObject, eventdata, handles, varargin)
7 B$ x( W2 @- D$ o% This function has no output args, see OutputFcn.1 Y( H5 p$ l7 j) [* ?- h
% hObject    handle to figure
' f5 H/ @4 k9 G+ s% eventdata  reserved - to be defined in a future version of MATLAB
4 R0 o/ J8 X# y% handles    structure with handles and user data (see GUIDATA). c, v7 J6 d9 u& H5 H
% varargin   command line arguments to Gui_Main (see VARARGIN)
, q6 H0 R# V3 Z: O( G ! ~: c0 \; w9 g: A' f/ h; H
% Choose default command line output for Gui_Main  Z: j5 x. n" h! y! `' Y( t. U
handles.output = hObject;( b) s7 d% W6 o& r( s" }7 Z) B
handles.Result = [];
- d2 r) P7 ?2 B* u/ jhandles.File = [];+ r3 G, ~6 {# g% P3 Y
% Update handles structure1 n$ b, v+ @% U0 g$ O/ K
guidata(hObject, handles);
7 n6 N+ y$ C3 Q2 ~  Iclc; warning off all;
) ?* S9 k. p+ Y, W: ], |InitAxes(handles);
2 I& z0 q8 p0 g/ z  F/ A
* t* f# L' c( h* @+ O) f% UIWAIT makes Gui_Main wait for user response (see UIRESUME)7 G) v/ b* s" Q
% uiwait(handles.figure1);
# a6 c% X8 s4 R2 T
; O6 S3 U+ i" k
. d8 B7 h8 }% \% G& I% --- Outputs from this function are returned to the command line.
: [. o7 p) Z# Tfunction varargout = Gui_Main_OutputFcn(hObject, eventdata, handles)) l7 v' R  w+ R
% varargout  cell array for returning output args (see VARARGOUT);3 |# F, ]3 ?3 q1 u) Y/ L$ e
% hObject    handle to figure/ R8 W3 Z6 o& r" {% A, W
% eventdata  reserved - to be defined in a future version of MATLAB
! |3 X3 G5 o- f& \* S% handles    structure with handles and user data (see GUIDATA)
. ^! _% N; z9 F! b- A. P
1 V. b1 ^$ V- O, s  q" M# R% Get default command line output from handles structure
) Q2 ~  M- D8 Y- Avarargout{1} = handles.output;$ `* F. _; Q. H
! q  [2 K: y/ E  ~# r: z7 q4 V
3 p* p4 C  w" v% t, j0 E6 F7 K
% --- Executes on button press in pushbuttonOpenFile.
1 Z- v7 K' r8 E. b' F$ Ofunction pushbuttonOpenFile_Callback(hObject, eventdata, handles)# [; n6 n2 i, p  Y, P
% hObject    handle to pushbuttonOpenFile (see GCBO)
0 F# u) S7 H2 X1 A7 y8 L4 }- a% eventdata  reserved - to be defined in a future version of MATLAB6 e& ~+ w, p; {- E5 g
% handles    structure with handles and user data (see GUIDATA)
! b; E2 L( C, T$ T[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bmp','All Image Files';...1 W* f+ R6 r; ~5 H5 O& @
    '*.*','All Files' },'载入图像',...
, i0 o1 c7 N# m! b2 O/ w' i6 D    fullfile(pwd, 'images'));6 H. C9 s* W, {' c7 t8 c
if isequal(filename, 0) || isequal(pathname, 0)
9 Q0 U- u1 ?! f- z  A    return;
! h2 n) q! |0 q9 j- Y$ fend1 O3 g- N2 D" P4 Z' ?0 w- d2 t
I = imread(fullfile(pathname, filename));0 M- ~6 N! T8 d# _8 e
Result = Process_Main(I);: y0 i) z7 Z$ i7 \. o
handles.File = fullfile(pathname, filename);
) J4 z9 X9 k( s- y! v/ @* ~handles.Result = Result;4 T# o: }- J6 |$ j( I3 g
guidata(hObject, handles);4 H( m1 s: k0 U/ }; M
InitAxes(handles)
) u& f  ]9 M: Y1 T. _, }axes(handles.axes1); imshow(handles.Result.Image); title('原图像');. Y8 A+ `0 Z& p  |) M$ t
. M6 Z2 o2 d; B- h( e; \

; \/ X( H/ j/ ~% o6 L9 V% --- Executes on button press in pushbuttonHisteq.' {9 _0 [- U0 F2 ^6 }
function pushbuttonHisteq_Callback(hObject, eventdata, handles); j; L2 R# _- H; C
% hObject    handle to pushbuttonHisteq (see GCBO)- `) h& A- E) D9 F1 @
% eventdata  reserved - to be defined in a future version of MATLAB7 a3 a# e# @) }& D/ r7 l
% handles    structure with handles and user data (see GUIDATA)* ?8 H* ]& X& K# f1 w2 \
if ~isempty(handles.Result)
: \2 K2 Z" T0 c! K    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');# o9 H- ]- {- d' V9 Q
    axes(handles.axes2); imshow(handles.Result.hist); title('直方图均衡化图像');
0 q% f& P. `5 Fend% j1 F6 \- }3 A% V' h3 ~- w" V

. q8 B+ X$ P6 z: u6 X6 |  m & y- H  H) l  m5 C

' X  \/ r4 q5 G  F% --- Executes on button press in pushbuttonMedfilt.7 o+ P& @5 m# r4 |, i: c) |
function pushbuttonMedfilt_Callback(hObject, eventdata, handles)
" P* _$ t: v9 g  |% hObject    handle to pushbuttonMedfilt (see GCBO)
8 L( E; }, v1 c) I7 o% eventdata  reserved - to be defined in a future version of MATLAB
" I; G' q5 I* S; w) a) J" a& M% handles    structure with handles and user data (see GUIDATA)& Y! v$ X+ _! X
if ~isempty(handles.Result)
# l7 e! A& \- b7 f% d    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
. h$ E( U' [5 |  g% V4 B/ R    axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');& Y) a7 x6 p5 m6 c5 i9 `* f
end
/ Q. t! ]/ V- Q6 I7 c6 D. }, M/ l ! C+ Y* d0 n$ Y* m" l6 Z
2 W; {6 ~. t. k  w. C0 Y- \( r
% --- Executes on button press in pushbuttonBw.& `! r# E. Q! _: s
function pushbuttonBw_Callback(hObject, eventdata, handles)
: W9 Z2 b& Z7 X( V5 [9 x% hObject    handle to pushbuttonBw (see GCBO)
$ r4 U4 I6 y# j% K% eventdata  reserved - to be defined in a future version of MATLAB
& J7 h$ v1 }, \5 u. V% handles    structure with handles and user data (see GUIDATA)" {3 f  _6 _; N0 h% |
if ~isempty(handles.Result)# p: p/ a* R) ?
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
* g, g  G8 e6 @1 {    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');" d6 B; q: Z& F8 U9 K8 v9 z
end& J4 S5 ]1 R9 G
. r  D% W  C4 e5 n
% --- Executes on button press in pushbuttonEnance.
6 n! h$ C' v$ Q( r+ G( m) {" q6 \function pushbuttonEnance_Callback(hObject, eventdata, handles)
0 t+ m6 }! g: _) Y$ g6 J- }' P% hObject    handle to pushbuttonEnance (see GCBO)
& o- X8 |/ f7 _. D& \: a( N- s# ~% eventdata  reserved - to be defined in a future version of MATLAB: b. |2 |- M3 B
% handles    structure with handles and user data (see GUIDATA)
, U( u. V, C) Y- lif ~isempty(handles.Result)- c3 E+ g% t; }5 M# d. _9 S
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
/ }, D% v- p7 T8 L+ R( ]6 r5 f$ @' c7 s    axes(handles.axes2); imshow(handles.Result.Enance); title('增强图像');
& `; ]7 h! i# q# F( M- r& L* c9 tend) {5 ]8 k! R) _  |! T8 g. E6 k

8 Y6 C2 A0 _. }" q* l$ ?: Z. {1 K+ s% --- Executes on button press in pushbuttonBwfilter.
. i) Z( t* a7 n9 [function pushbuttonBwfilter_Callback(hObject, eventdata, handles)7 X; U7 C( l8 ], \9 R2 p
% hObject    handle to pushbuttonBwfilter (see GCBO)' x; A  a9 e+ N
% eventdata  reserved - to be defined in a future version of MATLAB4 U$ h% j$ d, N( X- Z
% handles    structure with handles and user data (see GUIDATA)1 S1 Y5 u0 C! _) E, C
if ~isempty(handles.Result)
9 N- B5 Z+ s" Y% \' I    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');& A9 o8 E$ D( H5 M7 B
    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');' H- B3 {5 Q: h. ]5 R
    axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');
; Y5 j, X& X' H5 f  @  w/ ?end
$ o. U% C& c: |' [5 l& U
+ h/ J& R* j1 q/ N. O4 m0 A% --- Executes on button press in pushbuttonCrackRec.
  z% X# x1 b. R' R5 j5 q- Z  m3 Jfunction pushbuttonCrackRec_Callback(hObject, eventdata, handles)
# ^  w! t9 z/ v3 ~/ g& y3 i3 @% hObject    handle to pushbuttonCrackRec (see GCBO)
0 L. n7 n' G8 ?: F5 U0 x) I% eventdata  reserved - to be defined in a future version of MATLAB
  ^' M3 H, x# l% [: z5 B3 n' G% handles    structure with handles and user data (see GUIDATA)
. {2 r8 d) Y1 h- ?: }. Dif ~isempty(handles.Result)- J; P/ D" y9 @
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');1 @$ s$ \; P3 G8 h
    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');
" R$ ]) Y0 M# W( H    axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');
2 u) A. ]9 B6 h& R2 G* _% `' D% d    axes(handles.axes4); imshow(handles.Result.CrackRec); title('裂缝识别');
9 j; \8 O) P" ^7 b# ~end
% }8 O; k# ?" Z8 H+ T% k! k & |( v& P- j6 U9 ~+ ]) J7 e' x3 i
! [9 W6 l) L0 p: Y
% --- Executes on button press in pushbuttonCrackJudge.
7 B$ b0 L7 j. G9 |function pushbuttonCrackJudge_Callback(hObject, eventdata, handles)
& u2 X" I  A7 C# a5 A% hObject    handle to pushbuttonCrackJudge (see GCBO)" R8 R8 {# Q/ A" Y! z8 G* T6 m5 a
% eventdata  reserved - to be defined in a future version of MATLAB, e3 Q8 c3 P% E/ F$ K& Y; V5 O
% handles    structure with handles and user data (see GUIDATA)
" j( F% \8 _( r* {3 l0 [if ~isempty(handles.Result)) V  \8 K8 @3 k) t' J8 n
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');3 [0 t5 w* H, o: b& o/ F2 ?% T
    axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');
0 g$ H% N( g5 c6 T2 |, j( _    axes(handles.axes3); imshow(handles.Result.CrackRec); title('裂缝识别');
2 }3 z+ o& `9 o6 M6 T' f/ z( d    axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝判断');
0 O* o4 B* S, ^/ a( |+ Qend, I9 ?6 y. S) `9 ^# K

; d7 q" V& }2 X4 n) z0 T/ X% --- Executes on button press in pushbuttonCrackLoc.) f, f) g/ s7 u1 P5 W7 c" k- u2 `
function pushbuttonCrackLoc_Callback(hObject, eventdata, handles)" u- |. t& }3 g% C9 }* K, O
% hObject    handle to pushbuttonCrackLoc (see GCBO)
6 ^7 x( R) _" Y9 s% eventdata  reserved - to be defined in a future version of MATLAB
; K" Y: [0 m: C# n: y+ X1 d* J8 O4 d% handles    structure with handles and user data (see GUIDATA)' K8 \4 c8 n/ E+ w
if ~isempty(handles.Result)6 [5 X  r: @( x
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');5 [0 ^+ n3 D+ N9 f
    axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');2 g  o) N+ }4 u
    axes(handles.axes3); imshow(handles.Result.CrackJudge); title(handles.Result.str);# D7 w. I: r0 K" y' k4 M3 j& f
    axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝标记图像');. G5 v# w( [) \) g; E1 [+ E3 W: U1 F
    hold on;% {9 j; `: l: h+ Z5 }+ `* q
    rectangle('Position', handles.Result.rect, 'EdgeColor', 'g', 'LineWidth', 2);
  w% U' e# ?7 {3 v    hold off;
, g- r  M+ n7 c* w  N- t$ m' Fend
! E; l6 y! ?0 @) l) z9 t* S # T+ c5 t. }9 P4 _; S+ }
% --- Executes on button press in pushbuttonProject.) c7 V6 r, a% E' e2 T
function pushbuttonProject_Callback(hObject, eventdata, handles)
% D- E* l- @" p4 H, R2 }% @% hObject    handle to pushbuttonProject (see GCBO)
3 ]$ I8 Z4 F8 b) B$ h% eventdata  reserved - to be defined in a future version of MATLAB
- n; g+ D3 Q/ U* z" S8 ^; r  `0 X% handles    structure with handles and user data (see GUIDATA)& P# ^+ I8 I5 q! u( a: o
if ~isempty(handles.Result)
. e# \  M0 s' |    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');! Z$ x5 l. ]! h+ B% r
    axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');
+ h; _- B  }; q8 s/ q    axes(handles.axes3); plot(1:size(handles.Result.Image, 1), handles.Result.Projectr);# [7 b- W  g+ G" m* O4 L/ j- X
    title('行投影');) o3 A- D: a( H5 Z! `
    axes(handles.axes4); plot(1:size(handles.Result.Image, 2), handles.Result.Projectc);
4 D" n* g1 `2 I& T+ i    title('列投影');
; g  ?, \7 N- N* qend9 E" U2 W- `7 Q; i- T

% X$ G- U4 T1 B! ` " E# C5 r+ i% A% H8 c+ \" x
% --- Executes on button press in pushbuttonClose.' ?6 t( c5 J/ z! o( H2 Z5 L6 \1 b6 V
function pushbuttonClose_Callback(hObject, eventdata, handles)
; i  L% d7 l( F2 A% hObject    handle to pushbuttonClose (see GCBO). D9 ~; B) b; v( B
% eventdata  reserved - to be defined in a future version of MATLAB
% T/ ^( h) a; Y" ~% handles    structure with handles and user data (see GUIDATA)
+ k; K' y& W9 b& \3 a* U( g; Q' Mchoice = questdlg('确定退出?', ...
+ x7 r* N  v. j! T! l$ d% j  Z    '退出', ...
1 L' M! o, f+ |( L* e# G. t    '是','否','否');3 g" g) V$ z2 E; x% t- @6 Q1 W+ f
switch choice
! y# w1 n+ G: A. \    case '是'
  I1 ^/ f( j' a# O        close;
4 e8 J% T& B$ A. B- R/ W* d% o    otherwise
* _2 J( O% z2 `2 G7 d        return;
6 E$ m$ r$ A: n8 s6 b' yend
$ Z' G7 S, H5 c( u1 f / q  W1 [% ~5 l" r- y+ P

# t% B- x6 W! m6 {& h+ h6 D
; G3 t' b( S1 K* E" u; ^$ R% --- Executes on button press in pushbuttonSaveResult.
; }9 \( x; l5 f8 lfunction pushbuttonSaveResult_Callback(hObject, eventdata, handles)% {# @/ a! r! a1 ]1 [. Z
% hObject    handle to pushbuttonSaveResult (see GCBO)' _6 d1 w2 d8 E# v/ ]& n  b
% eventdata  reserved - to be defined in a future version of MATLAB
0 @- V( y, Q* s0 B% handles    structure with handles and user data (see GUIDATA)
. `2 j/ a8 t" Q7 k$ p7 J2 ]; X! jtry  l% J, v8 {) o* Z9 G* O
    if ~isempty(handles.File)
+ w' _/ y1 y! q4 b4 @        raw = [];
  D4 u$ h5 ^4 L! V2 _        xlsfile = fullfile(pwd, 'Result/result.xls');
. H$ q  i" D( m2 ?- }, u        if exist(xlsfile, 'file')
% M; p& h( \% i; n8 W8 I6 Q            [num, txt, raw] = xlsread(xlsfile);
% k: U8 W, O' H! G        end
' g0 G2 y1 y7 F, s        
5 M8 f* G5 C; H% Y+ C) H- H        F = [];
7 M, H6 D) `4 F3 H  w7 e        F{1, 1} = '文件名';! X7 [$ M; O2 j  L" }
        F{1, 2} = '阈值信息';1 @7 Y3 h; L1 }: G2 u, I
        F{1, 3} = '面积信息';
& V: B0 r; v& d  N        F{1, 4} = '长度信息';
5 V1 Z4 k- U6 I        F{1, 5} = '最大宽度信息';2 h* D5 h" |; h$ e( \- B* U: _+ h
        F{1, 6} = '最小宽度信息';9 H% F# O0 T; ^. K* o
        F{1, 7} = '形状信息';
# Q: @7 D0 H+ ^+ t8 v        
! R' p# U: f+ ]        F{2, 1} = handles.File;1 D- ~1 _. m( Z) b: v3 p3 L
        F{2, 2} = handles.Result.BwTh;
1 u2 n" s( ?1 O' n+ n" B; J        F{2, 3} = handles.Result.BwArea;: Z. r8 O- x7 b8 K
        F{2, 4} = handles.Result.BwLength;% t% [( g+ Z0 \! R! M; ^% D0 B% \
        F{2, 5} = handles.Result.BwWidthMax;: _& B! U. I  v3 |5 _
        F{2, 6} = max(handles.Result.BwWidthMin,0.01);
: s+ l& W+ l) _        F{2, 7} = handles.Result.str;4 r% h. X# i8 c' U! q
        
5 }( g- m$ G- P% u        F = [raw; F];+ w/ r: H7 S7 b, n: N
        xlswrite(xlsfile, F);
; W. C! e# {( L3 M6 q8 V" }        
) A  x4 C" ?; X/ s+ n        msgbox('保存结果成功!', '信息提示框');
# K% V' p( u9 b7 O: K    end
6 c+ m$ A# ~1 O% d: h: O1 P- {3 Ycatch
, H  J) A3 ]! R- p; g) V" T    msgbox('保存结果失败,请检查程序!', '信息提示框');( x# j2 X6 B8 |& }: w# B. d/ M
end" R& n! o5 i2 |. s& P$ o* b. k1 \

' `5 B$ X) Z/ \/ I' |5 @
( g5 T8 a& w# s* D* A1 N1 G, y0 \% --- Executes on button press in pushbuttonBridge.' A' n* G8 \+ g) ]& E2 j
function pushbuttonBridge_Callback(hObject, eventdata, handles)
9 r- u; A9 E. i( w! q7 Q% hObject    handle to pushbuttonBridge (see GCBO)
9 ^/ B# m' j& O* a% eventdata  reserved - to be defined in a future version of MATLAB
, Z& e2 P- z1 |. j% handles    structure with handles and user data (see GUIDATA)
7 z! {7 z/ Q4 h7 j) cif ~isempty(handles.Result)
6 C7 L8 c3 F& k( e    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');" X* V9 W' u1 _
    axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');
0 o+ j- v! C% A' ?6 ^8 K6 J8 w    axes(handles.axes3); imshow(handles.Result.CrackJudge); title('裂缝判断');
7 |! s+ E) Z2 E& X9 J0 T5 }+ p    axes(handles.axes4); imshow(handles.Result.CrackBridge); title('裂缝拼接');: v1 e1 b' [( z5 J9 P
end# D; M$ x4 m4 o  L2 J5 x! W, s
( f9 t1 u% Z% Z' F. C8 z

/ }6 ]" A/ x2 r7 |% f- N4 @# U% --- Executes on button press in pushbuttonSaveImage.2 y$ A! _/ v( g$ b0 t9 @3 L2 S
function pushbuttonSaveImage_Callback(hObject, eventdata, handles)/ X: d) i/ g4 c. ]* i6 X" y) z1 d  _  {
% hObject    handle to pushbuttonSaveImage (see GCBO)) e0 d) k  A& `
% eventdata  reserved - to be defined in a future version of MATLAB  S( p( A3 I! n3 d* ?8 y- f
% handles    structure with handles and user data (see GUIDATA)1 N! o8 b. Y- W' d/ I  w
[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...: s4 `6 ^* c8 h5 [( {
    '*.*','All Files' },'Save Image',...- e; F0 C1 k; H
    fullfile(pwd, 'Result/result.png'));
# B9 ?! J) b0 a5 y# \* [5 U) xif ~isequal(filename, 0)
, d6 i) E! L/ {8 L( M9 h" H    imwrite(handles.Result.BwEnd, fullfile(pathname, filename));1 l$ A. g5 G, q1 d; a
    msgbox('保存图像成功!', '信息提示框');5 r  _! o1 u7 \) k+ y- D
end+ V2 @' d  Q% v# Y9 d: u  Y: i
- K6 h$ y9 W+ d
) b1 V: s5 l% L) N! w
% --- Executes on button press in pushbuttonDiplay.: l$ W3 m9 a2 A& e- D) v
function pushbuttonDiplay_Callback(hObject, eventdata, handles)" |" `! U7 z# b- B4 |( N7 v
% hObject    handle to pushbuttonDiplay (see GCBO)% q" C- [7 P" c
% eventdata  reserved - to be defined in a future version of MATLAB
: n) q# b( j) @8 T6 D4 n% handles    structure with handles and user data (see GUIDATA)
  f- P2 f0 x$ U0 g  M# Pif ~isempty(handles.File)8 c8 b2 {) r6 ~4 F: o+ [& {
    F = [];
/ L5 y% M+ p) f+ @" F    F{1} = sprintf('文件名:%s', handles.File);( \6 E! r5 x8 f: c2 Y
    F{2} = sprintf('阈值信息%.2f', handles.Result.BwTh);8 C, J% N( F7 `
    F{3} = sprintf('面积信息%.2f', handles.Result.BwArea);% o  V% t8 j; e3 d
    F{4} = sprintf('长度信息%.2f', handles.Result.BwLength);1 Y4 Z1 j  o; }+ o" r) j7 e& }1 X
    F{5} = sprintf('最大宽度信息%.2f', handles.Result.BwWidthMax);
8 P8 c% B) Q8 b+ h    F{6} = sprintf('最小宽度信息%.2f', max(handles.Result.BwWidthMin,0.01));
/ r) I6 D8 L! C    F{7} = sprintf('形状信息%s', handles.Result.str);
) e9 h) x2 {7 a7 z! Z    listdlg('PromptString', '参数显示:',..." ?1 n8 W3 |  X1 u2 W+ K. Y  |
        'Name', '参数信息', ...
" ^, A# N* l: L$ i0 x1 d        'ListSize', [300, 150], ...
, y6 j  D9 L0 r) Z        'SelectionMode','single',...
) V9 k& e0 Q' |9 ~; v+ i        'ListString', F);
0 `5 x0 w  D) \end
7 N3 h7 U7 N9 ^& V6 ~& Q. ?3 }8 b  ?( |: r7 u4 l$ l# r- x; H9 |
三、运行结果# t) G1 l- A7 y" ^

/ q; |$ c6 e1 x8 B2 w& M / t8 t' b! ?  Y% W

( ^  K" v  S1 C5 X$ x
! g) S" G1 G9 a  D4 i' C2 l
/ i& Z- q2 q, V9 |7 i

该用户从未签到

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

本版积分规则

关闭

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

EDA365公众号

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

GMT+8, 2025-7-20 08:46 , Processed in 0.140625 second(s), 26 queries , Gzip On.

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

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

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