一、不变矩验证码识别简介

1 背景意义
验证码具有多变性特点,而当前的识别系统往往具有很强的针对性, 只能够识别某种类型的验证码。随着网络安全技术及验证码生成技术的不断发展,已经出现了更加复杂的验证码生成方法,如基于动态图像的验证码系统等。运用计算机视觉、模式识别等相关理论对多种不同类型的验证码进行识别研究。矩特征主要表征了图像区域的几何特征,又称为几何矩, 由于其具有旋转、平移、尺度等特性的不变特征,所以又称其为不变矩。

2 理论基础
本案例提出了以处理颜色加噪的数字字符为理论研究素材, 将模板匹配作为基本框架的验证码识别系统。本系统的优点在于能够对特定类型的数字验证码进行精确识别,实验中识别准确率可达到95%以上,并提供动态更新样本库的功能,可根据实际运行的环境提高验证码的识别率。
本案例选择了经典的数字验证码识别作为识别的对象。验证码的识别涉及图像预处理、分割、特征提取、识别等相关技术,本案例通过对彩色验证码图像进行灰度化、二值化、去噪和归一化等步骤来进行预处理,通过建立模板库的动态更新机制来提高系统的兼容性,进一步提升验证码识别的效率和准确性。
流程图如下:

3 算法流程
为了进行验证码识别, 建立模板库建立动态模板库,加入自动更新的功能提高对数字验证码的识别率。数字验证码待识别对象即数字0 ~ 9,调用mkdir 函数来自动建立模板数据库文件夹。
由于图中有类似于椒盐噪声的带有颜色的噪声,数字验证码中的数字个数保持常量并且分布均匀、易于分割。因此,为了进行下一步的数字分割操作,需要先进行验证码图像去噪步骤。本案例采用颜色空间转换到hsv 的方式,用阈值过滤的手段进行去噪。进行图像去噪之后,可以发现验证码图像中的数字呈现分布均匀的状态,并且未明显受到倾斜、形变等因素的影响。借用数字图像二值化、积分投影的方式可对数字进行定位。在实际处理过程中,为了保证分割有效,加入了区域面积滤波操作,将剩余的噪声点进行滤除。为了进行下一步的识别操作,需要将分割结果进行归一化处理, 整合成固定维数的数字集合。数字图像分割完成后,通过提取数字图像的不变矩特征信息,与模板库中的数字图像
进行对比,得到识别结果。

二、部分源代码

function varargout = daunxujian1(varargin)
% DAUNXUJIAN1 MATLAB code for daunxujian1.fig
%      DAUNXUJIAN1, by itself, creates a new DAUNXUJIAN1 or raises the existing
%      singleton*.
%
%      H = DAUNXUJIAN1 returns the handle to a new DAUNXUJIAN1 or the handle to
%      the existing singleton*.
%
%      DAUNXUJIAN1('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in DAUNXUJIAN1.M with the given input arguments.
%
%      DAUNXUJIAN1('Property','Value',...) creates a new DAUNXUJIAN1 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before daunxujian1_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to daunxujian1_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% Edit the above text to modify the response to help daunxujian1% Last Modified by GUIDE v2.5 23-Oct-2020 21:52:34% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...'gui_Singleton',  gui_Singleton, ...'gui_OpeningFcn', @daunxujian1_OpeningFcn, ...'gui_OutputFcn',  @daunxujian1_OutputFcn, ...'gui_LayoutFcn',  [] , ...'gui_Callback',   []);
if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});
endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
elsegui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT% --- Executes just before daunxujian1 is made visible.
function daunxujian1_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 daunxujian1 (see VARARGIN)
% Choose default command line output for daunxujian1
handles.output = hObject;
handles.Result = [];
handles.File = [];
% Update handles structure
guidata(hObject, handles);
clc; warning off all;
InitAxes(handles);
% UIWAIT makes daunxujian1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.
function varargout = daunxujian1_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 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)
[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...'*.*','All Files' },'载入图像',...fullfile(pwd, 'images'));
I = imread(fullfile(pathname, filename));
Result = Process_Main(I);
handles.File = fullfile(pathname, filename);
handles.Result = Result;
guidata(hObject, handles);
InitAxes(handles)
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)axes(handles.axes1); imshow(handles.Result.Image); title('原图像');axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');
end% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)axes(handles.axes1); imshow(handles.Result.Image); title('原图像');axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');axes(handles.axes3); imshow(handles.Result.Normalize); title('归一化图像');
end% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)axes(handles.axes1); imshow(handles.Result.Image); title('原图像');axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');axes(handles.axes3); imshow(handles.Result.Normalize); title('归一化图像');axes(handles.axes4); imshow(handles.Result.Bww); title('二值化图像');
end% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)axes(handles.axes1); imshow(handles.Result.Image); title('原图像');axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');axes(handles.axes3); imshow(handles.Result.Normalize); title('归一化图像');axes(handles.axes4); imshow(handles.Result.Bww); title('二值化图像');axes(handles.axes6); imshow(handles.Result.Thin); title('细化处理');axes(handles.axes5); imshow(handles.Result.Bw); title('特征提取');hold on;h = [];for i = 1 : length(handles.Result.hs) %绘制水平线h = [h plot([1 handles.Result.sz(2)], [handles.Result.hs(i) handles.Result.hs(i)], 'r-')];endfor i = 1 : length(handles.Result.vs)%绘制竖直线h = [h plot([handles.Result.vs(i) handles.Result.vs(i)], [1 handles.Result.sz(1)], 'g-')];endh = [h plot(handles.Result.x1, handles.Result.y1, 'y-')];%绘制左对角线h = [h plot(handles.Result.x2, handles.Result.y2, 'm-')];%绘制右对角线
end% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...'*.*','All Files' },'Save Image',...fullfile(pwd, 'Result/result.png'));
if ~isequal(filename, 0)imwrite(handles.Result.label, fullfile(pathname, filename));msgbox('保存图像成功!', '信息提示框');
end% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
choice = questdlg('确定退出?', ...'退出', ...'是','否','否');
switch choicecase '是'close;otherwisereturn;
endfunction edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit 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 pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.edit1,'string',handles.Result.label);% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)axes(handles.axes1); imshow(handles.Result.Image); title('原图像');axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');axes(handles.axes3); imshow(handles.Result.Normalize); title('归一化图像');axes(handles.axes4); imshow(handles.Result.Bww); title('二值化图像');axes(handles.axes6); imshow(handles.Result.Thin); title('细化处理');
end

三、运行结果

四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.

【验证码识别】基于matlab GUI不变矩验证码识别(带面板)【含Matlab源码 095期】相关推荐

  1. 【电力预测】基于matlab GUI灰色模型电力负荷预测【含Matlab源码 769期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源: [电力负荷预测]基于matlab GUI灰色模型电力负荷预测[含Matlab源码 769期] 获取代码方式2: 通过订阅紫极神光博客付费专 ...

  2. 【光学】基于matlab GUI菲涅尔系数计算【含Matlab源码 1165期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[光学]基于matlab GUI菲涅尔系数计算[含Matlab源码 1165期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: ...

  3. 【水果识别】基于matlab GUI苹果分级系统(带面板)【含Matlab源码 1827期】

    一.简介 中国苹果产销量居世界首位,传统的苹果分级由人工完成,长期以来,其劣势逐渐显现.因此,智能分拣是当今苹果分级的主要任务,而大小又是苹果分级的重要参考指标.国内外专家做了许多基于图像处理的苹果大 ...

  4. 【语音识别】基于matlab GUI智能语音识别门禁系统【含Matlab源码 596期】

    ⛄一.案例简介 本文基于Matlab设计实现了一个文本相关的声纹识别系统,可以判定说话人身份. 1 系统原理 a 声纹识别 这两年随着人工智能的发展,不少手机App都推出了声纹锁的功能.这里面所采用的 ...

  5. 【图像修复】基于matlab GUI FMM+Criminisi算法彩色图像修复【含Matlab源码 1507期】

    一.FMM+Criminisi算法简介 1 FMM算法 FMM算法是由Telea在2004年提出的,主要思想是先处理待修复区域边缘的像素,然后逐步向内推进,直到所有空洞点修复完毕.设Λ为待修复区域, ...

  6. 【语音去噪】基于matlab GUI切比雪夫+椭圆形低通滤波器语音去噪【含Matlab源码 2198期】

    一.语音处理简介 1 语音信号的特点 通过对大量语音信号的观察和分析发现,语音信号主要有下面两个特点: ①在频域内,语音信号的频谱分量主要集中在300-3400Hz的范围内.利用这个特点,可以用一个防 ...

  7. 基于matlab的串口通信,基于Matlab GUI的单片机串口与PC的通信 附源码

    我也是最近学习单片机和MATLAB的小白平时在看学习的时候 下载了一些有价值的参考文献 概述采用51单片机,atmel的STC89C52RC芯片,主要用到的是七段数码管用来做一个时钟,程序编写软件为k ...

  8. 简单物联网应用——基于老人居家声音监测系统(全!含完整源码、详细注释、测试结果、设计过程、视频详细教程)

    简单物联网应用设计与实现--基于老人居家声音监测系统 概述 设计内容: 采用标准的物联网三层架构, 感知层为可以检测声音数据并且实现无线发送的传感器节点: 网络层主要使用无线 WiFi: 应用层中, ...

  9. 【缺陷检测】基于matlab GUI印刷电路板自动缺陷检测【含Matlab源码 1912期】

    ⛄一.印刷电路板自动缺陷检测简介 我国是PCB生产大国,据世界电子电路理事会WECC各协会统计[1],2007年中国大陆PCB产值占全球总产值的27.9%,仅一年时间就比2006年增长了17.0%.但 ...

  10. 【肌电信号】基于matlab GUI脉搏信号分析(去噪+特征提取)【含Matlab源码 862期】

    ⛄一.脉搏信号分析简介 人体脉搏信号是一种微弱信号, 信噪比较低.在检测和采集时, 由于受仪器.人体等方面的影响, 所采集的信号中常存在如下3种噪声:1) 基线漂移.人体呼吸等低频干扰, 频率小于1 ...

最新文章

  1. C# WinForm程序中强制退出程序以及启动程序
  2. C#中listView列自动适应缩放的完美效果
  3. 发现自己的代码写的越来越玄幻了
  4. Linux 命令之 sed -- 功能强大的流式文本编辑器
  5. 拼智商,谷歌、苹果、微软、亚马逊的AI助手谁赢了?有些结果没料到
  6. 车载wince系统刷界面ui_UI入门秘笈,你想知道吗?
  7. 艺术字体图标设计软件Art Text 4 for Mac
  8. Java考试系统题目和选项乱序实现
  9. InletexEMC绿色好用的电脑屏幕共享软件
  10. 预设Date时间格式化参数
  11. 数控宏程序c语言,数控车床宏程序怎么写?最好带步骤解说
  12. 和的区别?以及 0x0f 的含义
  13. 犬类水疗跑步机的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告
  14. 和面试官对线HashMap
  15. 【测评】西圣Ava蓝牙耳机,一款轻便且极具性价比的真无线蓝牙耳机
  16. H3C设备的基本配置
  17. 我的Windows工具之文件查重工具——DuplicateCleaner
  18. 【学术相关】国家自然科学基金申请——函评等级与上会
  19. Ant构建工具知识概括
  20. windows获取文件列表及文件夹结构

热门文章

  1. python里的正则表达式
  2. Item 27: 明白什么时候选择重载,什么时候选择universal引用
  3. 《Python核心编程》第二版第407页第十三章练习 续六 -Python核心编程答案-自己做的-...
  4. 深圳无车日:吕锐锋搭公交 卓钦锐徒步走
  5. OpenCV人工智能图像处理学习笔记 第6章 计算机视觉加强之机器学习中 SVM和HOG特征
  6. 06-多进程之间通过Queue来实现数据共享学习笔记
  7. 190305每日一句
  8. 通过脚本找到对应的物体
  9. Atitit usrQBK13 html dsl 规范与解决方案
  10. paip.提升效率--gui 的选择--swing最佳实践swt awt