最近要做一些模式识别的课程作业,设计一个手写输入板来实现测试样本的识别,好吧,废话不多说,干货来了。
要实现的目标:
1.实现手写
2.手写的图像能够保存
大概就是下面这个样子

实现步骤:
1.添加控件,有点类似VB那种,先创建新的GUI界面,然后把控件拖里面去就行。

2.创建一些回调函数

每个回调函数下面可以写函数,用到的回调函数也就那么几个,下面一一介绍
No.1 获取鼠标位置(鼠标按下)
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;
global x;
global y;
draw_enable=1;
if draw_enable
position=get(gca,'currentpoint');
x(1)=position(1);
y(1)=position(3);
end
No.2更新鼠标位置并画线(鼠标在按下的情况下运动)
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 hand
MATLAB GUI设计手写输入板
最新推荐文章于 2022-07-17 17:40:01 发布