【图像增强】基于matlab GUI gabor滤波器指纹增强【含Matlab源码 745期】
一、获取代码方式
获取代码方式1:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
获取代码方式2:
完整代码已上传我的资源:【图像增强】基于matlab GUI gabor滤波器指纹增强【含Matlab源码 745期】
备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、图像增强技术简介
1 图像增强
图像增强是对图像的某些特征,如边缘、轮廓、对比度等进行强调或锐化,以便于显示、观察或进一步分析与处理。通过对图像的特定加工,将被处理的图像转化为对具体应用来说视觉质量和效果更“好”或更“有用”的图像。
图像增强是最基本最常用的图像处理技术,常用于其他图像处理的预处理阶段。
(1)高通平滑、低通锐化;平滑模糊、锐化突出图像细节
(2)滤波器还有带通、带阻等形式
(3)根据噪声(椒盐噪声、高斯噪声…)的不同,选用不同的滤波
(4)邻域有4-邻域、对角邻域、8-邻域,相对应的有邻接,即空间上相邻、像素灰度相似
(5)图像边缘处理:忽略不处理、补充、循环使用
(6)目前尚未图像处理大多基于灰度图像
2 Gabor滤波器
2 Gabor函数结合代码分析:
三、部分源代码
function varargout = gaborlvbo(varargin)
% GABORLVBO M-file for gaborlvbo.fig
% GABORLVBO, by itself, creates a new GABORLVBO or raises the existing
% singleton*.
% H = GABORLVBO returns the handle to a new GABORLVBO or the handle to
% the existing singleton*.
% GABORLVBO('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GABORLVBO.M with the given input arguments.
% GABORLVBO('Property','Value',...) creates a new GABORLVBO or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before gaborlvbo_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to gaborlvbo_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help gaborlvbo
% Last Modified by GUIDE v2.5 28-May-2010 15:43:51
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @gaborlvbo_OpeningFcn, ...
'gui_OutputFcn', @gaborlvbo_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 gaborlvbo is made visible.
function gaborlvbo_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 gaborlvbo (see VARARGIN)
setappdata(handles.figure_gabor,'img_src',0);
setappdata(handles.figure_gabor,'thea',0);
% Choose default command line output for gaborlvbo
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes gaborlvbo wait for user response (see UIRESUME)
% --- Outputs from this function are returned to the command line.
function varargout = gaborlvbo_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;
% --------------------------------------------------------------------
function m_file_open_Callback(hObject, eventdata, handles)
% hObject handle to m_file_open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile( ...
{'*.bmp;*.jpg;*.png;*.jpeg', 'Image Files (*.bmp, *.jpg, *.png,*.jpeg)'; ...
'*.*', 'All Files (*.*)'}, ...
'Pick an image');
if isequal(filename,0) || isequal(pathname,0),
return;
end
axes(handles.axes_src);
fpath=[pathname filename];
img_src=imread(fpath);
img_src=rgb2gray(img_src);
imshow(img_src);
setappdata(handles.figure_gabor,'img_src',img_src);
% --------------------------------------------------------------------
function m_file_exit_Callback(hObject, eventdata, handles)
% hObject handle to m_file_exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(handles.figure_gabor);
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes_dst);
b1=[0 1 0
1 1 1
0 1 0];
b2=[0 0 1 0 0
0 1 1 1 0
1 1 1 1 1
0 1 1 1 0
0 0 1 0 0];
b31=[0 0 0
1 1 1
0 0 0];
b32=[0 0 1
0 1 0
1 0 0];
b33=[0 1 0
0 1 0
0 1 0];
b34=[1 0 0
0 1 0
0 0 1];
I = getappdata(handles.figure_gabor,'img_src');
I=double(I);
xs1=size(I,1);
xs2=size(I,2);
K1=sum(sum(I));
M1=K1/(xs1*xs2);
M2=ones(xs1,xs2);
M0=M2*M1;
M3=zeros(xs1,xs2);
for i=1:xs1
for j=1:xs2
M3(i,j)=(I(i,j)-M0(i,j))^2; %求一个平均值
end
end
K2=sum(sum(M3));
V0=K2/(xs1*xs2);
P1=ones(fix(xs1/15),fix(xs2/15));
P2=ones(15,15);
P3=ones(fix(xs1/15),fix(xs2/15));
for i=1:xs1
for j=1:xs2
a=mod(i,15);
b=mod(j,15);
if a==0
a=15;
end
if b==0
b=15;
end
P2(a,b)=I(i,j);
if a==15&&b==15
PK1=sum(sum(P2));
PM1=PK1/(15*15);
PM2=ones(15,15);
PM0=PM2*PM1;
PM3=zeros(15,15);
for m=1:15
for n=1:15
PM3(m,n)=(PM2(m,n)-PM0(m,n))^2;
end
end
PK2=sum(sum(PM3));
PV0=PK2/(15*15);
P1(fix(i/15),fix(j/15))=PM1;
P3(fix(i/15),fix(j/15))=PV0;
end
end
end
I_n=zeros(xs1,xs2);
for i=1:xs1
for j=1:xs2
m=ceil(i/15);
n=ceil(j/15);
if I(i,j)>M0(i,j)&&m~=ceil(xs1/15)&&n~=ceil(xs2/15)
I_n(i,j)=M0(i,j)+sqrt(V0*(I(i,j)-P1(m,n))^2/P3(m,n));
end
if I(i,j)<=M0(i,j)&&m~=ceil(xs1/15)&&n~=ceil(xs2/15)
I_n(i,j)=M0(i,j)-sqrt(V0*(P1(m,n)-I(i,j))^2/P3(m,n));
end
end
end
I=I_n;
img_src_I=I;
setappdata(handles.figure_gabor,'img_src_I',img_src_I);
bw1= I;
vertical=[ 1 2 1
0 0 0
-1 -2 -1];
horizontal=[ -1 0 1
-2 0 2
-1 0 1];
fx=conv2(bw1,vertical,'same');
fy=conv2(bw1,horizontal,'same');
mubanver=15;mubanhor=15; %模板的垂直和水平大小
middle_mu1=size(bw1,1)/mubanver;
middle_mu2=size(bw1,2)/mubanhor;
middle_mu1=fix(middle_mu1);
middle_mu2=fix(middle_mu2);
thea= zeros(middle_mu1, middle_mu2);
thea1= zeros(middle_mu1, middle_mu2);
sum1= zeros(middle_mu1, middle_mu2);
sum2= zeros(middle_mu1, middle_mu2);
sum3= zeros(middle_mu1, middle_mu2);
for i=1:middle_mu1
for j=1:middle_mu2
for y=1:mubanver
for x=1:mubanhor
sum1(i,j)=sum1(i,j)+2*fx(y+(i-1)*(mubanver),x+(j-1)*(mubanhor))*fy(y+(i-1)*(mubanver),x+(j-1)*(mubanhor));
%2Gxy
sum2(i,j)=sum2(i,j)+fx(y+(i-1)*(mubanver),x+(j-1)*(mubanhor))*fx(y+(i-1)*(mubanver),x+(j-1)*(mubanhor)) - fy(y+(i-1)*(mubanver),x+(j-1)*(mubanhor))*fy(y+(i-1)*(mubanver),x+(j-1)*(mubanhor));
%Gxx-Gyy
sum3(i,j)=sum3(i,j)+fx(y+(i-1)*(mubanver),x+(j-1)*(mubanhor))*fx(y+(i-1)*(mubanver),x+(j-1)*(mubanhor)) + fy(y+(i-1)*(mubanver),x+(j-1)*(mubanhor))*fy(y+(i-1)*(mubanver),x+(j-1)*(mubanhor));
%Gxx+Gyy
end
end
if sum2(i,j)>=0
fi=1/2*atan(sum1(i,j)/sum2(i,j));
end
if sum2(i,j)<0 && sum1(i,j)>=0
fi=1/2*(atan(sum1(i,j)/sum2(i,j))+pi);
end
if sum2(i,j)<0 && sum1(i,j)<0
fi=1/2*(atan(sum1(i,j)/sum2(i,j))-pi);
end
thea(i,j)=pi-fi; %方向角度
end
end
setappdata(handles.figure_gabor,'thea',thea);
for i=1:size(sum3,1)
for j=1:size(sum3,2)
if sum3(i,j)==0
coh(i,j)=1;
else
coh(i,j)=sqrt(sum2(i,j)*sum2(i,j)+sum1(i,j)*sum1(i,j))/sum3(i,j);
end
end
end
%figure,imshow(coh,[]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%根据置信度改变方向%%%%%%%%%%%%%%%%%%%%%%%%
[X,Y] = meshgrid(size(thea,1):-1:1,1:1:size(thea,2));
xx=X';yy=Y';
for i=1:size(thea,1)
for j=1:size(thea,2)
sum2(i,j)=cos(thea(i,j));
sum1(i,j)=sin(thea(i,j));
end
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
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
- 233
- 234
- 235
- 236
- 237
- 238
- 239
- 240
- 241
- 242
- 243
- 244
- 245
- 246
- 247
- 248
- 249
- 250
- 251
- 252
- 253
- 254
- 255
- 256
- 257
- 258
四、运行结果
五、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.
[5]刘艳华.基于MATLAB/GUI的指纹识别系统设计[J].信息与电脑(理论版). 2021,33(18)
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/115558513
- 点赞
- 收藏
- 关注作者
评论(0)