【图像识别】Fisher分类手写数字识别 【Matlab 456期】

一、简介

Fisher分类器用于解决二类线性可分问题。

Fisher准则基本原理:找到一个最合适的投影轴,使两类样本在该轴上投影之间的距离尽可能远,而每一类样本的投影尽可能紧凑,从而使分类效果为最佳。
在这里插入图片描述
例如上图中:通过将方块点和圆点向w1投影,然后再在设置合适的阈值即可将方块和圆点分离。
在这里插入图片描述

二、源代码

function varargout = main_gui(varargin)
% MAIN_GUI MATLAB code for main_gui.fig
%      MAIN_GUI, by itself, creates a new MAIN_GUI or raises the existing
%      singleton*.
%
%      H = MAIN_GUI returns the handle to a new MAIN_GUI or the handle to
%      the existing singleton*.
%
%      MAIN_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MAIN_GUI.M with the given input arguments.
%
%      MAIN_GUI('Property','Value',...) creates a new MAIN_GUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before main_gui_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to main_gui_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 main_gui

% Last Modified by GUIDE v2.5 02-Apr-2019 15:37:29

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @main_gui_OpeningFcn, ...
                   'gui_OutputFcn',  @main_gui_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 main_gui is made visible.
function main_gui_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 main_gui (see VARARGIN)
% set( handles.axes1, 'visible', 'off' );
% set( handles.axes1, 'box', 'on' );
global W W0;
load W 
load W0

% Choose default command line output for main_gui
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes main_gui wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = main_gui_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 mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
function figure1_WindowButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global draw_enable;  %定义一个标志,1表示绘图,0表示停止绘图
global x;
global y;
draw_enable=1;
if draw_enable
    position=get(gca,'currentpoint');  %gca(获取当前坐标轴的句柄)
    x(1)=position(1);
    y(1)=position(3);
end


% --- Executes on mouse motion over figure - except title and menu.
function figure1_WindowButtonMotionFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global draw_enable;
global x;
global y;
global h1;
if draw_enable==1
    position=get(gca,'currentpoint');
    x(2)=position(1);
    y(2)=position(3);
    h1=line(x,y,'LineWidth',25,'color','k','Linestyle','-.');
    x(1)=x(2);
    y(1)=y(2);   %鼠标移动,随时更新数据
end


% --- Executes on mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
function figure1_WindowButtonUpFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global draw_enable;
    draw_enable=0;

function num_Callback(hObject, eventdata, handles)
% hObject    handle to num (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 num as text
%        str2double(get(hObject,'String')) returns contents of num as a double


% --- Executes during object creation, after setting all properties.
function num_CreateFcn(hObject, eventdata, handles)
% hObject    handle to num (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 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)
global W
global W0
img=getframe(handles.axes1);
img=imresize(img.cdata,[28,28]);
img=im2bw(img,graythresh(img)); 
img=~img;
axes(handles.axes2);
img1=~img;
imshow(img1);%img1为预览图像
%计算概率
for cnt=1:4
    for cnt2=1:4
        Atemp=sum(img(((cnt*7-6):(cnt*7)),((cnt2*7-6):(cnt2*7))));%10*10box
        lett((cnt-1)*4+cnt2)=sum(Atemp);
    end

三、运行结果

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

四、备注

完整代码或者代写添加QQ912100926
往期回顾>>>>>>
【图像压缩】图像处理教程系列之图像压缩【Matlab 074期】
【图像分割】图像处理教程系列之图像分割(一)【Matlab 075期】
【图像分割】图像处理教程系列之图像分割(二)【Matlab 076期】
【模式识别】银行卡号之识别【Matlab 077期】
【模式识别】指纹识别【Matlab 078期】
【图像处理】基于GUI界面之DWT+DCT+PBFO改进图像水印隐藏提取【Matlab 079期】
【图像融合】CBF算法之图像融合【Matlab 080期】
【图像去噪】自适应形态学之图像去噪【Matlab 081期】
【图像增强】DEHAZENET和HWD之水下去散射图像增强【Matlab 082期】
【图像增强】PSO寻优ACE之图像增强【Matlab 083期】
【图像重建】ASTRA算法之图像重建【Matlab 084期】
【图像分割】四叉树之图像分割【Matlab 085期】
【图像分割】心脏中心线之提取【Matlab 086期】
【图像识别】SVM植物叶子之疾病检测和分类【Matlab 087期】
【图像识别】基于GUI界面之模板匹配手写数字识别系统【Matlab 088期】
【图像识别】基于GUI界面之不变矩的数字验证码识别【Matlab 089期】
【图像识别】条形码识别系统【Matlab 090期】
【图像识别】基于GUI界面RGB和BP神经网络之人民币识别系统【Matlab 091期】
【图像识别】CNN卷积神经网络之验证码识别【Matlab 092期】
【图像分类】极限学习分类器之对遥感图像分类【Matlab 093期】
【图像变换】DIBR-3D之图像变换【Matalb 094期】
【图像分割】模糊聚类算法之FCM图像分割【Matlab 095期】
【模式识别】银行监控系统之人脸识别【Matlab 096期】
【模式识别】基于GUI界面之疲劳检测系统【Matlab 097期】
【图像识别】国外车牌识别【Matlab 098期】
【图像分割】最大类间方差法(otsu)之图像分割【Matlab 099期】
【图像分割】直觉模糊C均值聚类之图像分割IFCM【Matlab 100期】
【图像分割】基于matlab形态学重建和过滤改进FCM算法(FRFCM)之图像分割【Matlab 101期】
【图像增强】局部对比度增强CLAHE算法之直方图增强【Matlab 102期】
【图像融合】Frequency Partition之图像融合【Matlab 103期】
【图像评价】SVM之图像无参考质量评价【Matlab 104期】
【图像边缘检测】最小二乘法用于椭圆边缘检测【Matlab 105期】
【图像加密】基于GUI界面之混沌系统图像加密解密【Matlab 106期】
【图像配准】SIFT算法之图像配准【Matlab 107期】
【图像分割】随机游走算法用于图像分割【Matlab 108期】
【图像分割】形态学重建和过滤改进FCM算法(FRFCM)用于图像分割【Matlab 109期】
【图像分割】图像分割IFCM之直觉模糊C均值聚类【Matlab 110期】
【图像增强】区域相似变换函数与蜻蜓算法之灰度图像增强【Matlab 111期】
【图像直线拟合】最小二乘法之图像直线拟合【Matlab 112期】
【图像去雾】暗通道之图像去雾【Matlab 113期】
【图像识别】基于matlab GUI界面之路面裂缝识别【Matlab 114期】
【图像识别】身份证号码之识别【Matlab 115期】
【图像聚类】FCM和改进之FCM脑部CT图像聚类【Matlab 116期】
【图像评价】CCF算法之图像质量评价【Matlab 117期】
【图像分割】蚁群优化模糊聚类之图像分割【Matlab 118期】
【模式识别】基于GUI界面之水果检测系统【Matlab 119期】
【模式识别】基于GUI界面之水果分类系统【Matlab 120期】
【模式识别】基于GUI界面之水果分级系统【Matlab 121期】
【模式识别】人脸识别之检测脸、眼、鼻子和嘴【Matlab 122期】
【图像处理】基于 GUI界面之图像加解密【Matlab 124期】
【模式识别】基于GUI界面BP网络之手写体大写字母识别【Matlab 125期】
【图像分割】基于GUI界面之医学影像分割【Matlab 126期】
【图频处理】基于GUI界面之环图像处理与音乐播放系统【Matlab 127期】
【图像隐藏】基于Laguerre 变换之图像隐藏【Matlab 128期】
【图像处理】基于dwt函数之实现二维小波变换【Matlab 129期】
【图像处理】分形插值算法之调换图片【Matlab 130期】
【图像边缘检测】基于GUI界面之图像边缘检测系统【Matlab 131期】
【图像分割】基于GUI界面之彩色图像分割【Matlab 132期】
【图像去噪】基于GUI界面之图像滤波去噪【Matlab 133期】
【图像几何运算】基于GUI界面之图像几何运算系统【Matlab 134期】
【图像处理】基于GUI界面之图像处理系统【Matlab 135期】
【图像识别】基于matlab之细胞识别和边缘检测【Matlab 136期】
【模式识别】反馈神经Hopfield的数字识别【Matlab 172期】
【模式识别】指纹图像细节特征提取 【Matlab 173期】
【图像分割】RGB HSV YCbCr Lab颜色空间人脸检测之图像分割【Matlab 174期】
【图像压缩】小波变换之图像压缩【Matlab 175期】
【模式识别】基于GUI界面的火灾检测【Matlab 230期】
【模式识别】基于Hough变换的答题卡识别【Matlab 231期】
【模式识别】二值膨胀差分和椒盐滤波之教室内人数识别系统【Matlab 232期】
【小波变换】基于GUI界面DWT与SVD算法的数字水印 【Matlab 233期】
【模式识别】基于GUI界面的指针式表盘识别【Matlab 234期】
【模式识别】基于Hough变换图片车道线检测 【Matlab 235期】
【图像分割】粒子群优化T熵图像分割【Matlab 236期】
【图像分割】粒子群优化指数熵图像分割【Matlab 237期】
【图像分割】粒子群优化指数熵图像分割【Matlab 238期】
【模式识别】基于GUI贝叶斯最小错误率手写数字识别【Matlab 239期】
【模式识别】PCA手写数字识别【Matlab 240期】
【模式识别】特征匹配的英文印刷字符识别【Matlab 241期】
【模式识别】知识库的手写体数字识别【Matlab 242期】
【模式识别】银行卡数字识别【Matlab 243期】
【边缘检测】插值法亚像素边缘检测【Matlab 248期】
【图像识别】表情检测【Matlab 288期】
【图像检测】LSD直线检测【Matlab 289期】
【图像融合】红外与可见光的融合与配准算法【Matlab 290期】
【图像识别】帧差法跌倒检测【Matlab 291期】
【图像识别】组合BCOSFIRE过滤器进行墙体裂缝识别【Matlab 292期】
【模式识别】中值滤波和二值化的跌倒检测【Matlab 293期】
【图像隐写】DCT的图像隐写【Matlab 294期】
【图像隐写】LSB的图像隐写提取【Matlab 295期】
【图像隐写】高斯模型的JPEG图像隐写【Matlab 296期】
【图像隐写】图像自适应隐写算法wow【Matlab 297期】
【模式识别】基于GUI SVM和PCA的人脸识别【Matlab 298期】
【视频识别】轨迹方法行为识别【Matlab 299期】
【模式识别】基于GUI HSV和RGB模型水果分类【Matlab 300期】
【图像处理】基于GUI数字图像处理平台【Matlab 301期】
【图像分割】视网膜图像分割【Matlab 302期】
【模式识别】k-means聚类的手势识别【Matlab 303期】
【图像处理】Hough变换的人眼虹膜定位【Matlab 304期】
【图像处理】Kalman滤波的目标跟踪【Matlab 305期】
【图像分割】GAC水平集方法实现图像分割【Matlab 306期】
【图像分割】分水岭算法的图像分割【Matlab 307期】
【图像去噪】基于小波变换的图像去噪【Matlab 308期】
【图像融合】基于小波变换的图像融合【Matlab 309期】
【图像识别】图像识别物体计数【Matlab 310期】
【图像增强】模糊集的图像增强【Matlab 311期】
【图像处理】图像RGB三色的合成、分离【Matlab 312期】
【图像处理】鼠标画图【Matlab 313期】
【图像识别】基于二值化条形码识别【Matlab 314期】
【图像压缩】行程编码实现的图像压缩【Matlab 315期】
【图像几何】投影法测距【Matlab 316期】
【边缘检测】插值法亚像素边缘检测【Matlab 317期】
【图像分割】关键像素点的FLICM图像分割【Matlab 318期】
【图像识别】gabor滤波布匹瑕疵检测【Matlab 319期】
【图像识别】基于GUI车牌库识别【Matlab 320期】
【图像识别】国内车牌识别【Matlab 321期】
【图像分割】snake模型的图像分割【Matlab 322期】
【图像去噪】全变分算法图像去噪【Matlab 323期】
【图像去噪】非局部均值(NLM)滤波图像去噪【Matlab 324期】
【图像去噪】中值滤波图像去噪【Matlab 325期】
【边缘检测】元胞自动机图像边缘检测【Matlab 432期】
【图像识别】基于LBP+LPQ算法融合人脸表情识别【Matlab 433期】
【图像识别】OCR识别系统【Matlab 434期】
【边缘检测】拉普拉斯边缘检测与图像增强【Matlab 435期】
【图像处理】全变差图像处理【Matlab 436期】
【图像处理】直方图的医学图像处理【Matlab 437期】
【图像分割】GMM-HMRF图像分割【Matlab 438期】
【图像识别】ksvd字典学习之人脸表情识别【Matlab 439期】
【图像去噪】基于curvelet变换图像去噪【Matlab 440期】
【图像去噪】基于小波变换(中值、硬阙值、软阙值)的图像去噪【Matlab 441期】
【图像配准】sift图像配准【Matlab 442期】
【图像识别】扑克牌灰度二值化识别【Matlab 443期】
【图像转换】二维图转三维图【Matlab 444期】
【图像识别】基于阈值的裂痕、划痕检测【Matlab 445期】
【图像识别】基于Hough变换形状检测【Matlab 446期】
【图像识别】车辆出入库计时系统【Matlab 447期】
【图像识别】基于颜色直方图的危险品识别【Matlab 448期】
【图像识别】基于RBF手写数字识别【Matlab 449期】
【图像识别】花朵分类【Matlab 450期】
【图像增强】拉氏滤波的图像质量提升【Matlab 451期】
【边缘检测】基于CNN的灰度图像边缘提取【Matlab 452期】
【图像增强】虹膜图像高斯滤波、低通滤波、巴特沃斯滤波【Matlab 453期】
【视频识别】高斯模型视频车辆计数【Matlab 454期】
【视频识别】视频的车流量统计【Matlab 455期】

猜你喜欢

转载自blog.csdn.net/m0_54742769/article/details/114825620