广告
返回顶部
首页 > 资讯 > 精选 >怎么使用Matlab制作图形验证码生成器
  • 667
分享到

怎么使用Matlab制作图形验证码生成器

2023-06-29 07:06:39 667人浏览 安东尼
摘要

这篇文章主要介绍了怎么使用Matlab制作图形验证码生成器,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。突然发现cla函数也可以应用到app designer控件上,因而对部

这篇文章主要介绍了怎么使用Matlab制作图形验证码生成器,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

    突然发现cla函数也可以应用到app designer控件上,因而对部分内容做出更改,将绘制隐藏像素刷新的方式改为用cla

    hold(acAxes,'off');image(acAxes,[-1,0],[-1,0],ones(1,1,3),'visible','off');hold(acAxes,'on');delete(findobj('tag','ax'));

    cla(acAxes)cla(ax)

    0效果

    怎么使用Matlab制作图形验证码生成器

    怎么使用Matlab制作图形验证码生成器

    1字符图片生成

    如果我们单纯的用text绘制图形,就无法做到效果中符号和符号边缘两个颜色,也无法做到更大程度的变形,因此我们需要将字符转换为矩阵形式。

    想要实现也非常简单,我们只需要创建一个不可视的fig,在其上绘制字符,保存fig为png格式图片,再通过imread读取图片,就能获得字符矩阵:

    第一次运行程序因为要生成字符图片因而会比较慢,再次运行就可以读取之前已经生成过的图片啦:

    % 字符图片矩阵构造 ========================================================% 以下为字符图片创建过程% 原理为构造隐藏的figure和axes% 在其上用text绘制字符并保存figure为图片% 导入图片if ~exist('Materials','dir')   mkdir('Materials');endfig=figure('units','pixels',...        'position',[20 80 200 200],...        'Numbertitle','off',...        'Color',[1 1 1],...        'resize','off',...        'visible','off',...         'menubar','none');ax=axes('Units','pixels',...        'parent',fig,...          'Color',[1 1 1],...        'Position',[0 0 200 200],...        'XLim',[0 200],...        'YLim',[0 200],...        'XColor',[1 1 1],...        'YColor',[1 1 1]);strPic{length(strElement)}=[];for i=1:length(strElement)    % 若是不存在该字符图片则生成,否则直接导入    if ~exist(['.\Materials\',strElement(i),'.png'],'file')        delete(findobj('tag','textStr'));        text(ax,100,100,strElement(i),'HorizontalAlignment',...            'center','FontSize',140,'tag','textStr','FontWeigh','bold')        saveas(fig,['.\Materials\',strElement(i),'.png']);     % 保存图片    end    tempPic=imread(['.\Materials\',strElement(i),'.png']);     % 读取图片    strPic{i}=imresize(tempPic,[150,150]);             % 重新调整图片大小end

    怎么使用Matlab制作图形验证码生成器

    2刷新按钮生成

    大家可以看到这个按钮的样式与大部分按钮不同:

    怎么使用Matlab制作图形验证码生成器

    实际上这是一个html控件,输入html文件的位置就可以形成类似嵌入页面的效果:

    acHTML=uihtml(acFigure);acHTML.HTMLSource='.\Materials\textbtn.html';acHTML.DataChangedFcn=@refresh;acHTML.Position=[300 50 88 26];

    如代码所示,我们导入的是Materials文件夹内的textbtn.html文件

    textbtn.html长这样:

    <!DOCTYPE html><html>    <head>        <meta charset=UTF-8>        <script type="text/javascript">        function setup(htmlComponent) {                       document.getElementById("btnonclink").addEventListener("click", function(event) {                htmlComponent.Data="test";            });            }        </script>    </head>    <body>        <a href="" id=" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" btnonclink">看不清?</a>    </body></html>

    当然为了防止大家不会创建,我在m文件中写了一段能够自动创建html文件的代码,原理就是将字符串信息写入txt,再将txt文件后缀改为html:

    % .html文件自动生成及引入 - - - - - - - - - - - - - - - - - - - - - - - - - htmlContent={'<!DOCTYPE html><html><head><meta charset=UTF-8>';'<script type="text/javascript">';'function setup(htmlComponent){';         'document.getElementById("btnonclink").addEventListener("click",function(event){';'htmlComponent.Data="test";});}</script></head>';'<body><a href="" id=" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" btnonclink">看不清?</a></body></html>'};if ~exist('.\Materials\textbtn.html','file')    fid=fopen('.\Materials\textbtn.txt','w');    for i=1:length(htmlContent)        fprintf(fid,'%s\r\n',htmlContent{i});     end    fclose(fid);    copyfile('.\Materials\textbtn.txt','.\Materials\textbtn.html');    delete('.\Materials\textbtn.txt')end

    3图片处理

    3.1图像任意方向拉伸

    这部分原理就是将图像旋转一定角度后,在竖直方向进行拉伸后再旋转回去

    怎么使用Matlab制作图形验证码生成器

    3.2字符边缘

    这部分原理将字符均值滤波后,把不完全是黑色的部分设置为灰色,后期再设置为其他颜色

    怎么使用Matlab制作图形验证码生成器

    3.3图像处理部分代码

    randColor=@()randi([0,200],[1,3]);   % 生成随机颜色的匿名函数% 从图像集合中提取图像tPic=strPic{randiNums(ii)};tPic=tPic(:,:,1);% 将图像旋转-拉伸-旋转randiTheta1=randi([0,90]);randiTheta2=randi([-30,30]);randiLenth=randi([0,70]);tPic=imrotate(255-tPic,randiTheta1,'bilinear','crop');tPic=imresize(tPic,[150+randiLenth,150]);tPic=imrotate(tPic,-randiTheta1+randiTheta2,'bilinear','crop');% 将图像边缘进行模糊,并将模糊的部分数值设置为150tPic=255-imfilter(tPic,I_5);tPic(tPic~=0&tPic~=255)=150;% 为符号和符号边缘赋予不同颜色tempColor1=randColor();tempColor2=randColor();tempPicR=tPic;tempPicG=tPic;tempPicB=tPic;tempPicR(tPic==150)=tempColor1(1);tempPicR(tPic==0)=tempColor2(1);tempPicG(tPic==150)=tempColor1(2);tempPicG(tPic==0)=tempColor2(2);tempPicB(tPic==150)=tempColor1(3);tempPicB(tPic==0)=tempColor2(3);tempPic_3=uint8(zeros([size(tPic),3]));tempPic_3(:,:,1)=tempPicR;tempPic_3(:,:,2)=tempPicG;tempPic_3(:,:,3)=tempPicB;

    4线条和散点生成

    散点就是生成一堆随机位置点和一些随机颜色后用scatter函数绘制,线条是生成散点后使用&rsquo;spline&rsquo;插值方法插值成线后再绘制:

    randColor=@()randi([0,200],[1,3]);           % 生成随机颜色的匿名函数randColor_n=@(n)randi([0,200],[n,3])./255;   % 生成n个随机颜色的匿名函数 randPoint_n=@(n)[randi([5,195],[n,1]),randi([5,65],[n,1])];% 生成n个随机点的匿名函数% 绘制散点pPonintsNum=randi([6,10]);pPoints=randPoint_n(pPonintsNum);pPointsColor=randColor_n(pPonintsNum);scatter(acAxes,pPoints(:,1),pPoints(:,2),6,'filled',...    'CData',pPointsColor,'AlphaData',0.6)% 绘制线lPonintsNum=randi([5,7]);lPoints=randPoint_n(lPonintsNum);lPointsColor=[randColor()./255,0.6];x_lPoints=interp1(1:lPonintsNum,lPoints(:,1),1:0.01:lPonintsNum,'spline');y_lPoints=interp1(1:lPonintsNum,lPoints(:,2),1:0.01:lPonintsNum,'spline');plot(acAxes,x_lPoints,y_lPoints,'Color',lPointsColor,'LineWidth',1.5)

    5关于图像存储

    由于目前版本uifigure还不支持存储为图像,因此我们绘制图像是在figure和uifigure分别绘制一遍,其中figure依旧是不可见状态,主要用于将图片验证码保存为png格式,可以在完整代码中看出这一点。

    同时,本程序的设置为,每次刷新图形验证码,都会刷新当前文件夹下authCode.png为最新的验证码,如需要保存请及时将其改名或复制另存:

    怎么使用Matlab制作图形验证码生成器

    6关于验证码对比

    首先就是需要提取框内验证码:

    codeInPut=acEditField.Value;

    因为我们的验证码字符都是大写的,将输入的文本用upper函数变为大写:

    codeInPut=upper(codeInPut);

    同时我们因为0和O长的太像,所以不对其进行区分,直接将输入的验证码中的0改为O:

    codeInPut(codeInPut=='0')='O';

    之后就能够用strcmp函数将当前验证码和输入的验证码进行对比:

    if strcmp(codeInPut,authCode)    msgbox('验证码正确')else    msgbox('验证码错误')end

    7完整代码

    function authCodestrElement=char([49:57,65:90]);              % 1-9,A-Z的字符randColor=@()randi([0,200],[1,3]);           % 生成随机颜色的匿名函数randColor_n=@(n)randi([0,200],[n,3])./255;   % 生成n个随机颜色的匿名函数 randPoint_n=@(n)[randi([5,195],[n,1]),randi([5,65],[n,1])];% 生成n个随机点的匿名函数global authCode;                             % 全局变量:验证码% 字符图片矩阵构造 ========================================================% 以下为字符图片创建过程% 原理为构造隐藏的figure和axes% 在其上用text绘制字符并保存figure为图片% 导入图片if ~exist('Materials','dir')   mkdir('Materials');endfig=figure('units','pixels',...        'position',[20 80 200 200],...        'Numbertitle','off',...        'Color',[1 1 1],...        'resize','off',...        'visible','off',...         'menubar','none');ax=axes('Units','pixels',...        'parent',fig,...          'Color',[1 1 1],...        'Position',[0 0 200 200],...        'XLim',[0 200],...        'YLim',[0 200],...        'XColor',[1 1 1],...        'YColor',[1 1 1]);strPic{length(strElement)}=[];for i=1:length(strElement)    % 若是不存在该字符图片则生成,否则直接导入    if ~exist(['.\Materials\',strElement(i),'.png'],'file')        delete(findobj('tag','textStr'));        text(ax,100,100,strElement(i),'HorizontalAlignment',...            'center','FontSize',140,'tag','textStr','FontWeigh','bold')        saveas(fig,['.\Materials\',strElement(i),'.png']);     % 保存图片    end    tempPic=imread(['.\Materials\',strElement(i),'.png']);     % 读取图片    strPic{i}=imresize(tempPic,[150,150]);             % 重新调整图片大小end% 更改fig ax样式,为方便后期验证码存储fig.Position=[100 100 200 70];ax.Position=[1 1 199.5 70];ax.XTick=[];ax.YTick=[];ax.XLim=[0,200];ax.YLim=[0,70];ax.XColor=[0.7 0.7 0.7];ax.YColor=[0.7 0.7 0.7];ax.Box='on';ax.YDir='reverse';hold(ax,'on');% APP designer窗口构建 ====================================================acFigure=uifigure();acFigure.Position=[100 100 370 90];acFigure.Name='authCode';acFigure.Resize='off';acAxes=uiaxes(acFigure);acAxes.Position=[10 10 200 70];acAxes.XTick=[];acAxes.YTick=[];acAxes.XLim=[0,200];acAxes.YLim=[0,70];acAxes.XColor=[0.7 0.7 0.7];acAxes.YColor=[0.7 0.7 0.7];acAxes.Box='on';acAxes.YDir='reverse';hold(acAxes,'on');acEditField=uieditfield(acFigure,'text');acEditField.Position=[220 52 70 23];acEditField.FontSize=16;acEditField.FontWeight='bold';acEditField.FontColor=[0.3,0.3,0.3];% .html文件自动生成及引入 - - - - - - - - - - - - - - - - - - - - - - - - - htmlContent={'<!DOCTYPE html><html><head><meta charset=UTF-8>';'<script type="text/javascript">';'function setup(htmlComponent){';         'document.getElementById("btnonclink").addEventListener("click",function(event){';'htmlComponent.Data="test";});}</script></head>';'<body><a href="" id=" rel="external nofollow"  rel="external nofollow"  rel="external nofollow" btnonclink">看不清?</a></body></html>'};if ~exist('.\Materials\textbtn.html','file')    fid=fopen('.\Materials\textbtn.txt','w');    for i=1:length(htmlContent)        fprintf(fid,'%s\r\n',htmlContent{i});     end    fclose(fid);    copyfile('.\Materials\textbtn.txt','.\Materials\textbtn.html');    delete('.\Materials\textbtn.txt')endacHTML=uihtml(acFigure);acHTML.HTMLSource='.\Materials\textbtn.html';acHTML.DataChangedFcn=@refresh;acHTML.Position=[300 50 88 26];% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -acButton=uibutton(acFigure);acButton.Position=[220 15 140 30];acButton.Text='确 认 验 证 码';acButton.BackgroundColor=[0.31 0.58 0.80];acButton.FontColor=[1 1 1];acButton.FontWeight='bold';acButton.FontSize=14;acButton.ButtonPushedFcn=@verify;% 回调函数 ================================================================    function refresh(~,~)        cla(acAxes)        cla(ax)                I_5=fspecial('average',[5,5]);   % 5*5均值滤波模板        randiNums=randi([1,length(strElement)],[1,4]);        authCode=strElement(randiNums);  % 验证码        disp(authCode)        for ii=1:4            tPic=strPic{randiNums(ii)};            tPic=tPic(:,:,1);            %tempPic(tempPic<250)=150;                        % 将图像旋转-拉伸-旋转            randiTheta1=randi([0,90]);            randiTheta2=randi([-30,30]);            randiLenth=randi([0,70]);                tPic=imrotate(255-tPic,randiTheta1,'bilinear','crop');            tPic=imresize(tPic,[150+randiLenth,150]);            tPic=imrotate(tPic,-randiTheta1+randiTheta2,'bilinear','crop');                         % 将图像边缘进行模糊,并将模糊的部分数值设置为150            tPic=255-imfilter(tPic,I_5);            tPic(tPic~=0&tPic~=255)=150;            % 为符号和符号边缘赋予不同颜色            tempColor1=randColor();tempColor2=randColor();            tempPicR=tPic;tempPicG=tPic;tempPicB=tPic;            tempPicR(tPic==150)=tempColor1(1);tempPicR(tPic==0)=tempColor2(1);            tempPicG(tPic==150)=tempColor1(2);tempPicG(tPic==0)=tempColor2(2);            tempPicB(tPic==150)=tempColor1(3);tempPicB(tPic==0)=tempColor2(3);                        tempPic_3=uint8(zeros([size(tPic),3]));            tempPic_3(:,:,1)=tempPicR;            tempPic_3(:,:,2)=tempPicG;            tempPic_3(:,:,3)=tempPicB;                        % 显示图片            image(acAxes,[-size(tempPic_3,2)/2,size(tempPic_3,2)/2]./3.5+40*ii+randi([-5,5]),...                         [-size(tempPic_3,1)/2,size(tempPic_3,1)/2]./3.5+35+randi([-5,5]),...                         tempPic_3,'AlphaData',tempPic_3(:,:,1)~=255,'Interpolation','bilinear')            image(ax,[-size(tempPic_3,2)/2,size(tempPic_3,2)/2]./3.5+40*ii+randi([-5,5]),...                         [-size(tempPic_3,1)/2,size(tempPic_3,1)/2]./3.5+35+randi([-5,5]),...                         tempPic_3,'AlphaData',tempPic_3(:,:,1)~=255,'Interpolation','bilinear')                 end                % 绘制散点        pPonintsNum=randi([6,10]);        pPoints=randPoint_n(pPonintsNum);        pPointsColor=randColor_n(pPonintsNum);        scatter(acAxes,pPoints(:,1),pPoints(:,2),6,'filled',...            'CData',pPointsColor,'AlphaData',0.6)        scatter(ax,pPoints(:,1),pPoints(:,2),6,'filled',...            'CData',pPointsColor,'AlphaData',0.6)                % 绘制线        lPonintsNum=randi([5,7]);        lPoints=randPoint_n(lPonintsNum);        lPointsColor=[randColor()./255,0.6];        x_lPoints=interp1(1:lPonintsNum,lPoints(:,1),1:0.01:lPonintsNum,'spline');        y_lPoints=interp1(1:lPonintsNum,lPoints(:,2),1:0.01:lPonintsNum,'spline');        plot(acAxes,x_lPoints,y_lPoints,'Color',lPointsColor,'LineWidth',1.5)        plot(ax,x_lPoints,y_lPoints,'Color',lPointsColor,'LineWidth',1.5)                saveas(fig,'.\authCode.png');    endrefresh()    function verify(~,~)        codeInPut=acEditField.Value;        codeInPut=upper(codeInPut);        codeInPut(codeInPut=='0')='O';        if strcmp(codeInPut,authCode)            msgbox('验证码正确')        else            msgbox('验证码错误')        end            endend

    :程序第一次运行由于有html文件及png文件需要生成,因而会比较慢,之后的运行速度会快很多。

    对于以前版本没有uihtml控件可以先尝试如下代码:

    怎么使用Matlab制作图形验证码生成器

    这里用正常按钮替换了uihtml控件

    function authCode2strElement=char([49:57,65:90]);              % 1-9,A-Z的字符randColor=@()randi([0,200],[1,3]);           % 生成随机颜色的匿名函数randColor_n=@(n)randi([0,200],[n,3])./255;   % 生成n个随机颜色的匿名函数 randPoint_n=@(n)[randi([5,195],[n,1]),randi([5,65],[n,1])];% 生成n个随机点的匿名函数global authCode;                             % 全局变量:验证码% 字符图片矩阵构造 ========================================================% 以下为字符图片创建过程% 原理为构造隐藏的figure和axes% 在其上用text绘制字符并保存figure为图片% 导入图片if ~exist('Materials','dir')   mkdir('Materials');endfig=figure('units','pixels',...        'position',[20 80 200 200],...        'Numbertitle','off',...        'Color',[1 1 1],...        'resize','off',...        'visible','off',...         'menubar','none');ax=axes('Units','pixels',...        'parent',fig,...          'Color',[1 1 1],...        'Position',[0 0 200 200],...        'XLim',[0 200],...        'YLim',[0 200],...        'XColor',[1 1 1],...        'YColor',[1 1 1]);strPic{length(strElement)}=[];for i=1:length(strElement)    % 若是不存在该字符图片则生成,否则直接导入    if ~exist(['.\Materials\',strElement(i),'.png'],'file')        delete(findobj('tag','textStr'));        text(ax,100,100,strElement(i),'HorizontalAlignment',...            'center','FontSize',140,'tag','textStr','FontWeigh','bold')        saveas(fig,['.\Materials\',strElement(i),'.png']);     % 保存图片    end    tempPic=imread(['.\Materials\',strElement(i),'.png']);     % 读取图片    strPic{i}=imresize(tempPic,[150,150]);             % 重新调整图片大小end% 更改fig ax样式,为方便后期验证码存储fig.Position=[100 100 200 70];ax.Position=[1 1 199.5 70];ax.XTick=[];ax.YTick=[];ax.XLim=[0,200];ax.YLim=[0,70];ax.XColor=[0.7 0.7 0.7];ax.YColor=[0.7 0.7 0.7];ax.Box='on';ax.YDir='reverse';hold(ax,'on');% APP designer窗口构建 ====================================================acFigure=uifigure();acFigure.Position=[100 100 370 90];acFigure.Name='authCode';acFigure.Resize='off';acAxes=uiaxes(acFigure);acAxes.Position=[10 10 200 70];acAxes.XTick=[];acAxes.YTick=[];acAxes.XLim=[0,200];acAxes.YLim=[0,70];acAxes.XColor=[0.7 0.7 0.7];acAxes.YColor=[0.7 0.7 0.7];acAxes.Box='on';acAxes.YDir='reverse';hold(acAxes,'on');acEditField=uieditfield(acFigure,'text');acEditField.Position=[220 52 70 23];acEditField.FontSize=16;acEditField.FontWeight='bold';acEditField.FontColor=[0.3,0.3,0.3];acfreshBtn=uibutton(acFigure);acfreshBtn.Text='看不清?';acfreshBtn.ButtonPushedFcn=@refresh;acfreshBtn.Position=[300 50 60 27];% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -acButton=uibutton(acFigure);acButton.Position=[220 15 140 30];acButton.Text='确 认 验 证 码';acButton.BackgroundColor=[0.31 0.58 0.80];acButton.FontColor=[1 1 1];acButton.FontWeight='bold';acButton.FontSize=14;acButton.ButtonPushedFcn=@verify;% 回调函数 ================================================================    function refresh(~,~)        cla(acAxes)        cla(ax)%         hold(acAxes,'off');%         image(acAxes,[-1,0],[-1,0],ones(1,1,3),'visible','off');%         hold(acAxes,'on');%         delete(findobj('tag','ax'));                I_5=fspecial('average',[5,5]);   % 5*5均值滤波模板        randiNums=randi([1,length(strElement)],[1,4]);        authCode=strElement(randiNums);  % 验证码        disp(authCode)        for ii=1:4            tPic=strPic{randiNums(ii)};            tPic=tPic(:,:,1);            %tempPic(tempPic<250)=150;                        % 将图像旋转-拉伸-旋转            randiTheta1=randi([0,90]);            randiTheta2=randi([-30,30]);            randiLenth=randi([0,70]);                tPic=imrotate(255-tPic,randiTheta1,'bilinear','crop');            tPic=imresize(tPic,[150+randiLenth,150]);            tPic=imrotate(tPic,-randiTheta1+randiTheta2,'bilinear','crop');                         % 将图像边缘进行模糊,并将模糊的部分数值设置为150            tPic=255-imfilter(tPic,I_5);            tPic(tPic~=0&tPic~=255)=150;            % 为符号和符号边缘赋予不同颜色            tempColor1=randColor();tempColor2=randColor();            tempPicR=tPic;tempPicG=tPic;tempPicB=tPic;            tempPicR(tPic==150)=tempColor1(1);tempPicR(tPic==0)=tempColor2(1);            tempPicG(tPic==150)=tempColor1(2);tempPicG(tPic==0)=tempColor2(2);            tempPicB(tPic==150)=tempColor1(3);tempPicB(tPic==0)=tempColor2(3);                        tempPic_3=uint8(zeros([size(tPic),3]));            tempPic_3(:,:,1)=tempPicR;            tempPic_3(:,:,2)=tempPicG;            tempPic_3(:,:,3)=tempPicB;                        % 显示图片            image(acAxes,[-size(tempPic_3,2)/2,size(tempPic_3,2)/2]./3.5+40*ii+randi([-5,5]),...                         [-size(tempPic_3,1)/2,size(tempPic_3,1)/2]./3.5+35+randi([-5,5]),...                         tempPic_3,'AlphaData',tempPic_3(:,:,1)~=255,'Interpolation','bilinear')            image(ax,[-size(tempPic_3,2)/2,size(tempPic_3,2)/2]./3.5+40*ii+randi([-5,5]),...                         [-size(tempPic_3,1)/2,size(tempPic_3,1)/2]./3.5+35+randi([-5,5]),...                         tempPic_3,'AlphaData',tempPic_3(:,:,1)~=255,'Interpolation','bilinear')                 end                % 绘制散点        pPonintsNum=randi([6,10]);        pPoints=randPoint_n(pPonintsNum);        pPointsColor=randColor_n(pPonintsNum);        scatter(acAxes,pPoints(:,1),pPoints(:,2),6,'filled',...            'CData',pPointsColor,'AlphaData',0.6)        scatter(ax,pPoints(:,1),pPoints(:,2),6,'filled',...            'CData',pPointsColor,'AlphaData',0.6)                % 绘制线        lPonintsNum=randi([5,7]);        lPoints=randPoint_n(lPonintsNum);        lPointsColor=[randColor()./255,0.6];        x_lPoints=interp1(1:lPonintsNum,lPoints(:,1),1:0.01:lPonintsNum,'spline');        y_lPoints=interp1(1:lPonintsNum,lPoints(:,2),1:0.01:lPonintsNum,'spline');        plot(acAxes,x_lPoints,y_lPoints,'Color',lPointsColor,'LineWidth',1.5)        plot(ax,x_lPoints,y_lPoints,'Color',lPointsColor,'LineWidth',1.5)                saveas(fig,'.\authCode.png');    endrefresh()    function verify(~,~)        codeInPut=acEditField.Value;        codeInPut=upper(codeInPut);        codeInPut(codeInPut=='0')='O';        if strcmp(codeInPut,authCode)            msgbox('验证码正确')        else            msgbox('验证码错误')        end            endend

    感谢你能够认真阅读完这篇文章,希望小编分享的“怎么使用Matlab制作图形验证码生成器”这篇文章对大家有帮助,同时也希望大家多多支持编程网,关注编程网精选频道,更多相关知识等着你来学习!

    --结束END--

    本文标题: 怎么使用Matlab制作图形验证码生成器

    本文链接: https://www.lsjlt.com/news/323624.html(转载时请注明来源链接)

    有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

    本篇文章演示代码以及资料文档资料下载

    下载Word文档到电脑,方便收藏和打印~

    下载Word文档
    猜你喜欢
    • 怎么使用Matlab制作图形验证码生成器
      这篇文章主要介绍了怎么使用Matlab制作图形验证码生成器,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。突然发现cla函数也可以应用到app designer控件上,因而对部...
      99+
      2023-06-29
    • 教你使用Matlab制作图形验证码生成器(appdesigner)
      目录1字符图片生成2刷新按钮生成3图片处理3.1图像任意方向拉伸3.2字符边缘3.3图像处理部分代码4线条和散点生成5关于图像存储6关于验证码对比7完整代码突然发现cla函数也可以应...
      99+
      2022-11-13
    • 怎么使用微信小程序canvas2d生成图形验证码
      本篇内容主要讲解“怎么使用微信小程序canvas2d生成图形验证码”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么使用微信小程序canvas2d生成图形验证码”吧!成品展示:背景:大致看了一下...
      99+
      2023-06-30
    • 怎么用Python实现随机生成图片验证码
      本篇内容主要讲解“怎么用Python实现随机生成图片验证码”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么用Python实现随机生成图片验证码”吧!导入模块import random...
      99+
      2023-06-26
    • Python利用wxPython制作一个有趣的验证码生成器
      目录1.引言2.正文3.实例分析4.总结1.引言 2.正文 CAPTCHA的应用场景主要是在需要验证用户身份或者防止恶意攻击的场景中,下面列举几个常见的应用场景: 用户登录验证:在...
      99+
      2023-05-18
      Python wxPython制作验证码生成器 Python 验证码生成器 Python 验证码 Python wxPython
    • 使用python怎么生成一个字母数字验证码图片
      今天就跟大家聊聊有关使用python怎么生成一个字母数字验证码图片,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。python是什么意思Python是一种跨平台的、具有解释性、编译性、...
      99+
      2023-06-14
    • 使用Java怎么生成一个随机验证码
      这篇文章将为大家详细讲解有关使用Java怎么生成一个随机验证码,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。源代码:RandomGen.java(实现产生验证码功能的类)package ve...
      99+
      2023-05-31
      java ava
    • Node.JS怎么使用纯JavaScript生成图片或滑块式验证码功能
      本篇内容介绍了“Node.JS怎么使用纯JavaScript生成图片或滑块式验证码功能”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!有一些N...
      99+
      2023-06-17
    • 使用canvas怎么实现一个图形验证码功能
      本篇文章给大家分享的是有关使用canvas怎么实现一个图形验证码功能,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。<!DOCTYPE html><h...
      99+
      2023-06-09
    • 怎么用纯JavaScript生成图片或滑块式验证码功能
      本文小编为大家详细介绍“怎么用纯JavaScript生成图片或滑块式验证码功能”,内容详细,步骤清晰,细节处理妥当,希望这篇“怎么用纯JavaScript生成图片或滑块式验证码功能”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来...
      99+
      2023-07-04
    • 怎么使用PyQt5制作一个数据图表生成器
      这篇文章主要介绍了怎么使用PyQt5制作一个数据图表生成器,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。我的需求:手动配置X轴、Y轴、图表标题等参数自动通过Pyecharts...
      99+
      2023-06-29
    • 使用Spring Boot怎么样实现一个验证码生成功能
      这篇文章给大家介绍使用Spring Boot怎么样实现一个验证码生成功能,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。1、验证码生成类import java.awt.*;import java.awt.image.Bu...
      99+
      2023-05-31
      springboot spring boo
    软考高级职称资格查询
    编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
    • 官方手机版

    • 微信公众号

    • 商务合作