function varargout = captcha(varargin)
% CAPTCHA MATLAB code for captcha.fig
% CAPTCHA, by itself, creates a new CAPTCHA or raises the existing
% singleton*.
%
% H = CAPTCHA returns the handle to a new CAPTCHA or the handle to
% the existing singleton*.
%
% CAPTCHA('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CAPTCHA.M with the given input arguments.
%
% CAPTCHA('Property','Value',...) creates a new CAPTCHA or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before captcha_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to captcha_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 captcha
% Last Modified by GUIDE v2.5 31-May-2017 09:25:53
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @captcha_OpeningFcn, ...
'gui_OutputFcn', @captcha_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 captcha is made visible.
function captcha_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 captcha (see VARARGIN)
% Choose default command line output for captcha
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes captcha wait for user response (see UIRESUME)
% uiwait(handles.figure_captcha);
% --- Outputs from this function are returned to the command line.
function varargout = captcha_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_Callback(hObject, eventdata, handles)
% hObject handle to m_file (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
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); % 用axes命令设定当前操作的坐标轴是axes_src
fpath=[pathname filename]; % 将文件名和目录名组合成一个完整的路径
img_src=imread(fpath);
imshow(img_src); % 用imread读入图片,并用imshow在axes_src上显示
% 显示文件名
set(handles.text_srcname, 'String', filename);
% 初始化checkbox
set(handles.checkbox1, 'Value', 0);
set(handles.checkbox2, 'Value', 0);
set(handles.checkbox3, 'Value', 0);
set(handles.checkbox4, 'Value', 0);
N = 25;
k = 4;
[Centroids, cooridx, IbSet] = seg_picture(fpath, k, N);
setappdata(handles.figure_captcha, 'IbSet', IbSet);
setappdata(handles.figure_captcha, 'N', N);
setappdata(handles.figure_captcha, 'k', k);
setappdata(handles.figure_captcha, 'answer', filename(1:4));
% --------------------------------------------------------------------
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_captcha);
% --- Executes on button press in predict_button.
function predict_button_Callback(hObject, eventdata, handles)
% hObject handle to predict_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
IbSet = getappdata(handles.figure_captcha, 'IbSet'); % 取得打开图片的数据
N = getappdata(handles.figure_captcha, 'N');
k = getappdata(handles.figure_captcha, 'k');
answer = getappdata(handles.figure_captcha, 'answer');
% 显示单个二值图片,这段写的太丑了
load trainData_knn.mat
KNEAREST = 5;
Mdl = fitcknn(knnChars, knnLabels, 'NumNeighbors', KNEAREST);
correctCnt = 0;
axes(handles.axes_1); % 用axes命令设定当前操作的坐标轴是axes_src
Ib = extractIb(IbSet, N, 1);
imshow(Ib);
label = knn_predict(Mdl, Ib);
set(handles.text_1, 'String', label);
if label == answer(1)
set(handles.checkbox1, 'Value', 1);
correctCnt = correctCnt + 1;
end
axes(handles.axes_2); % 用axes命令设定当前操作的坐标轴是axes_src
Ib = extractIb(IbSet, N, 2);
imshow(Ib);
label = knn_predict(Mdl, Ib);
set(handles.text_2, 'String', label);
if label == answer(2)
set(handles.checkbox2, 'Value', 1);
correctCnt = correctCnt + 1;
end
axes(handles.axes_3); % 用axes命令设定当前操作的坐标轴是axes_src
Ib = extractIb(IbSet, N, 3);
imshow(Ib);
label = knn_predict(Mdl, Ib);
set(handles.text_3, 'String', label);
if label == answer(3)
set(handles.checkbox3, 'Value', 1);
correctCnt = correctCnt + 1;
end
axes(handles.axes_4); % 用axes命令设定当前操作的坐标轴是axes_src
Ib = extractIb(IbSet, N, 4);
imshow(Ib);
label = knn_predict(Mdl, Ib);
set(handles.text_4, 'String', label);
if label == answer(4)
set(handles.checkbox4, 'Value', 1);
correctCnt = correctCnt + 1;
end
set(handles.text_rate, 'String', sprintf('%2.2f%%', correctCnt / 4 * 100) );
% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of checkbox1
% --- Executes on button press in checkbox2.
function checkbox2_Callback(hObject, eventdata, handles)
% hObject handle to checkbox2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of checkbox2
% --- Executes on button press in checkbox3.
function checkbox3_Callback(hObject, eventdata, handles)
% hObject handle to checkbox3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of checkbox3
% --- Executes on button press in checkbox4.
function checkbox4_Callback(hObject, eventdata, handles)
% hObject handle to checkbox4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Val
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
<项目介绍> 课程设计-基于matlab实现的验证码识别源码(带GUI界面).zip 该资源内项目源码是个人的毕设,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到94.5分,放心下载使用! 该资源适合计算机相关专业(如人工智能、通信工程、自动化、软件工程等)的在校学生、老师或者企业员工下载,适合小白学习或者实际项目借鉴参考! 当然也可作为毕业设计、课程设计、课程作业、项目初期立项演示等。如果基础还行,可以在此代码基础之上做改动以实现更多功能。
资源推荐
资源详情
资源评论
收起资源包目录
课程设计-基于matlab实现的验证码识别源码(带GUI界面).zip (2000个子文件)
M-3-29M5.bmp 2KB
6-4-BR46.bmp 2KB
5-2-35C4.bmp 2KB
N-1-NLR5.bmp 2KB
0-4-1E80.bmp 2KB
A-2-IA44.bmp 2KB
4-4-V3F4.bmp 2KB
6-3-6460.bmp 2KB
7-4-I5G7.bmp 2KB
4-2-4497.bmp 2KB
V-3-F7V9.bmp 2KB
5-4-D1G5.bmp 2KB
8-1-807Q.bmp 2KB
0-3-K602.bmp 2KB
4-2-04L8.bmp 2KB
E-1-EQUE.bmp 2KB
7-4-3AV7.bmp 2KB
8-3-O78N.bmp 2KB
8-1-8157.bmp 2KB
4-4-P5O4.bmp 2KB
A-3-28A3.bmp 2KB
6-1-6460.bmp 2KB
6-2-9671.bmp 2KB
N-2-TN6D.bmp 2KB
7-2-472N.bm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671.bmp 2KB
I-1-IL90.bmp 2KB
2-3-8729.bmp 2KB
7-3-OJ70.bmp 2KB
0-3-3Z07.bmp 2KB
9-2-4991.bmp 2KB
T-2-ETZM.bmp 2KB
2-4-8BF2.bmp 2KB
O-2-8O9D.bmp 2KB
6-1-6L5L.bmp 2KB
A-1-A483.bmp 2KB
5-4-I3J5.bmp 2KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
Make程序设计
- 粉丝: 6675
- 资源: 3576
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功