【车辆识别】基于matlab GUI小波和盒维数车型识别【含Matlab源码 727期】
一、差分盒维数简介
差分盒维数(differential box-counting,DBC),可以作为图像表面纹理粗糙程度的度量,因为它有很好的精确性和适用性,而且能满足计算效率和动态特性的要求。
1 处理流程
对于一个MM大小的图像,在三维空间中,(x,y)代表空间的位置,z代表其对应点的灰度值gray(x,y)。
1.1 图像分块,ss,r = s/M
1.2 在每一个ss的分块中,都有一个盒子柱ss*s’。如果最大灰度值为G,通常为256,则G/s’ = M/s。
1.3 计算每个分块的最大灰度值和最小灰度值,它们分别落在盒子k和l中,则
nr = k-l+1
1.4 Nr = sum(nr), d = log(Nr) / log(1/r)
1.5 对图像进行不同的分块,将最后结果进行最小二乘拟合。
2 QUESTION
2.1 s’怎么理解?
s’表示需要多少个盒子覆盖整个灰度曲面。
2.2 怎么理解灰度最大值和最小值落在盒子k和l中?
对图像进行分块,可能看成是对其按一定比例缩小的过程,对于灰度也要按照相同的比例缩小。比如分块大小为22,图像大小为256256,则k = maxgray/(256/2),同样,l = mingray /(256/2)。
二、部分源代码
function varargout = Carcheck(varargin)
% CARCHECK M-file for Carcheck.fig
% CARCHECK, by itself, creates a new CARCHECK or raises the existing
% singleton*.
%
% H = CARCHECK returns the handle to a new CARCHECK or the handle to
% the existing singleton*.
%
% CARCHECK('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CARCHECK.M with the given input arguments.
%
% CARCHECK('Property','Value',...) creates a new CARCHECK or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Carcheck_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Carcheck_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Subfunction:
% FindCentroidLaserSpotUsingFourier.m
% boundaries.m
% FractalDim.m
% Edit the above text to modify the response to help Carcheck
% Last Modified by GUIDE v2.5 29-Apr-2014 11:42:42
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Carcheck_OpeningFcn, ...
'gui_OutputFcn', @Carcheck_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Carcheck is made visible.
function Carcheck_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Carcheck (see VARARGIN)
% Choose default command line output for Carcheck
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Carcheck wait for user response (see UIRESUME)
% uiwait(handles.carcheck);
% --- Outputs from this function are returned to the command line.
function varargout = Carcheck_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on selection change in list.
function list_Callback(hObject, eventdata, handles)
% hObject handle to list (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns list contents as cell array
% contents{get(hObject,'Value')} returns selected item from list
car_pic = get(handles.carorigin, 'UserData');
set(handles.list,'UserData',car_pic{get(handles.list,'Value')});
disp(['--> 选择汽车原图: ', car_pic{get(handles.list,'Value')}]);
% --- Executes during object creation, after setting all properties.
function list_CreateFcn(hObject, eventdata, handles)
% hObject handle to list (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in backgroup.
function backgroup_Callback(hObject, eventdata, handles)
% hObject handle to backgroup (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[fname, pname] = uigetfile(...
{'*.jpg','jpg-files (*.jpg)'; ...
'*.png','png-files (*.png)'; ...
'*.*', 'All Files (*.*)'}, ...
'选择一个图片文件', ...
'MultiSelect', 'off');
if isequal(fname,0) || isequal(pname,0)
return;
else
backgroup_pic = fullfile(pname, fname);
bg = imread(backgroup_pic);
axes(handles.axesorigin);
imshow(bg);
set(handles.backgroup,'UserData',backgroup_pic);
set(handles.capinon, 'String', ['背景图片: ', backgroup_pic]);
disp(['--> 背景图片: ', backgroup_pic]);
end
% --- Executes on button press in carorigin.
function carorigin_Callback(hObject, eventdata, handles)
% hObject handle to carorigin (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[fname, pname] = uigetfile(...
{'*.jpg','jpg-files (*.jpg)'; ...
'*.png','png-files (*.png)'; ...
'*.*', 'All Files (*.*)'}, ...
'选择一个或多个图片文件', ...
'MultiSelect', 'on');
if isequal(fname,0) || isequal(pname,0)
return;
else
if ischar(fname)
fname = {fname};
end
car_pic = cell(1,length(fname));
for k = 1:length(fname);
car_pic{k} = fullfile(pname, fname{k});
end
set(handles.capinon, 'String', ['汽车原图目录: ', pname]);
set(handles.list,'String', fname, 'Value', 1, 'UserData',car_pic{k});
set(handles.carorigin,'UserData',car_pic);
disp(['--> 汽车原图目录: ', pname]);
end
% --- Executes on button press in run.
function run_Callback(hObject, eventdata, handles)
% hObject handle to run (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% S1: 调入图片文件
backgroup_pic = get(handles.backgroup,'UserData'); % 背景图片的地址
car_pic = get(handles.list,'UserData'); % 汽车图片的地址
if isempty(backgroup_pic)
helpdlg('请单击[背景图片]按钮,导入背景图片','提示');
return;
end
if isempty(car_pic)
helpdlg('请单击[汽车原图]按钮,导入汽车原图','提示');
return;
end
cla(handles.axescarpic); % 清除图像
cla(handles.capinon);
cla(handles.axesgnomon);
set(handles.axesgnomon,'XTick',[],'YTick',[]);
cla(handles.axeswave);
set(handles.axeswave,'XTick',[],'YTick',[]);
bg = imread(backgroup_pic); % 调入背景图片
bc = imread(car_pic); % 调入汽车图片
if size(bg,1) ~= size(bc,1) || size(bg,2) ~= size(bc,2)
errordlg('汽车图片与背景图片大小不一致!','警告');
return;
end
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/115518185
- 点赞
- 收藏
- 关注作者
评论(0)