1、数字图像处理课程设计报告数字图像处理课程设计报告姓 名:宋东洋、祁飞、登科 学 号: 、 班 级: 软件开发 .NET 3班 设计题目: 手写体数字识别 教 师: 庞海波老师 提交日期: 2015年12月25日 一、设计容:主题:手写体数字识别详细说明:读入手写体数字图片,选择要识别的数字然后通过寻找数字边界将图像裁剪的边缘,然后生成裁剪后图像的二进制图像,并将其转换成57的图像,然后进行特征提取,运行Simulink模型识别数字。二、现实意义:手写体数字的识别有着非常广泛的应用(如:邮政编码、统计报表、财务报表、银行票据等等)。三、涉及知识容:1、边界查找2、二值化3、Simulink模型四
2、、实例分析及截图效果:(1)代码显示:1、程序中定义图像变量说明 (1)S-原图变量;(2)img_crop-选择的图象;(3)imgGray-灰度图像变量(4)BW-二值化图像;(5)charvec-5*7图像变量;2、实现代码:Index.mfunction varargout = charGUI(varargin)% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, mfilename, . gui_Singleton, gui_Singleton, . gui_Op
3、eningFcn, charGUI_OpeningFcn, . gui_OutputFcn, charGUI_OutputFcn, . gui_LayoutFcn, , . gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);endif nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initi
4、alization code - DO NOT EDIT% - Executes just before charGUI is made visible.function charGUI_OpeningFcn(hObject, eventdata, handles, varargin)load data;assignin(base,net,net);handles.output = hObject;guidata(hObject, handles);% - Outputs from this function are returned to the command line.function
5、varargout = charGUI_OutputFcn(hObject, eventdata, handles) varargout1 = handles.output;% - Executes on button press in pbLoad.function pbLoad_Callback(hObject, eventdata, handles)filename, pathname = uigetfile(*.bmp;*.jpg;*.gif;*.*, Pick an Image File);S = imread(pathname,filename);axes(handles.axes
6、1);imshow(S);handles.S = S;guidata(hObject, handles);% - Executes on button press in pbSelect.function pbSelect_Callback(hObject, eventdata, handles)S = handles.S;axes(handles.axes1);img_crop = imcrop(S);axes(handles.axes2);imshow(img_crop);handles.img_crop = img_crop;guidata(hObject, handles);% - E
7、xecutes on button press in pbPreprocess.function pbPreprocess_Callback(hObject, eventdata, handles)img_crop = handles.img_crop;imgGray = rgb2gray(img_crop);bw = im2bw(img_crop,graythresh(imgGray);axes(handles.axes3);imshow(bw);bw2 = edu_imgcrop(bw);axes(handles.axes4);imshow(bw2);handles.bw2 = bw2;g
8、uidata(hObject, handles);% - Executes on button press in pbExtract.function pbExtract_Callback(hObject, eventdata, handles)bw2 = handles.bw2;charvec = edu_imgresize(bw2);axes(handles.axes5);plotchar(charvec);handles.charvec = charvec;guidata(hObject, handles);% - Executes on button press in pbRecogn
9、ize.function pbRecognize_Callback(hObject, eventdata, handles)charvec = handles.charvec;selected_net = get(handles.editNN,string);selected_net = evalin(base,selected_net);result = sim(selected_net,charvec);val, num = max(result);set(handles.editResult, string,mod(num,10);% - Executes on button press
10、 in pbNN.function pbNN_Callback(hObject, eventdata, handles)function editNN_Callback(hObject, eventdata, handles)% - Executes during object creation, after setting all properties.function editNN_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicont
11、rolBackgroundColor) set(hObject,BackgroundColor,white);endfunction editResult_Callback(hObject, eventdata, handles)% - Executes during object creation, after setting all properties.function editResult_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,default
12、UicontrolBackgroundColor) set(hObject,BackgroundColor,white);endedu_imgcrop.mfunction bw2 = edu_imgcrop(bw)% 求图像的边界y2temp x2temp = size(bw);x1=1;y1=1;x2=x2temp;y2=y2temp;% 寻找左侧空白空间cntB=1;while (sum(bw(:,cntB)=y2temp) x1=x1+1; tB=cntB+1;end% 寻找右侧空白空间cntB=1;while (sum(bw(cntB,:)=x2temp) y1=y1+1; tB=cn
13、tB+1;end% 寻找上边空白空间cntB=x2temp;while (sum(bw(:,cntB)=y2temp) x2=x2-1; tB=cntB-1;end% 寻找下边空白空间cntB=y2temp;while (sum(bw(cntB,:)=x2temp) y2=y2-1; tB=cntB-1;end% 将图像裁剪到边缘bw2=imcrop(bw,x1,y1,(x2-x1),(y2-y1);edu_imgresize.mfunction lett = edu_imgresize(bw2)% 此功能将采取裁剪的二进制图像,并将其改为57% 单个向量中的特征表示。bw_7050=imre
14、size(bw2,70,50);fort=1:7 fort2=1:5 Atemp=sum(bw_7050(cnt*10-9:cnt*10),(cnt2*10-9:cnt2*10); lett(cnt-1)*5+cnt2)=sum(Atemp); endendlett=(100-lett)/100);lett=lett;3、运行效果截图:第一步:读取原图,并显示第二步:选择图像并显示第三步:预处理(二值化、查找边界、裁剪图片)第四步: 特征提取第五步:显示数字(运行Simulink模型)四、算法分析(1)Simulink模型sim函数用来运行Simulink模型。需要注意的是,用户无法控制其仿真
15、过程(例如暂停、继续),一旦运行就会直到达到结束条件为止这一点和通过模型窗口界面运行仿真不同。五、心得体会通过这次的课程设计,我对Matlab有了一定的了解,刚开始做的时候有点不知所措,主要是因为平时不够努力,书上的知识了解得不够多,课下没有及时地复习。这次作业我和组员商量后选择了手写体数字识别,做作业之前上网查了很多资料,通过网络了解了一些关于数字识别方面的知识,通过课本也了解了一些,经过不断地努力我和我的组员一起完成了这次作业。虽然作业完成了,但也有一些缺陷,由于时间比较紧迫,所以希望以后有时间能自己再完善一下。我相信只要能坚持到底就能成功。六、程序资料清单和源代码电子档打包发送到FTP。
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1