资源简介
包括详细讲解与源代码,目的是将一幅图像中的数字识别出来,图像中数字有一定的倾斜角度,且各个部分光照不均,数字大体分布位置相同。作者根据图像的这些性质,对图像进行分析,写出了识别数字的一个算法,该算法先对图像进行尺度变换,将倾斜的图像正立,同时提取图像中的数字部分,再对数字进行特征的提取,最后确定所识别的是哪一个具体数字。在识别过程中,由于数字的特征不同,识别难度也不同,因此识别时有顺序区别,遵循先识别较难识别的数字,再识别简单的,并不是严格按照从0到9的顺序。对于题目材料中所给的6幅图像能进行准确的识别,作者再将材料中的某些图像稍加改动后,仍能识别,识别效果较好。

代码片段和文件信息
#include “stdafx.h“
#include “cvapp.h“
#include “math.h“
ImageProcessor *proc = 0;
int H;//图像高度
int W;//图像宽度
//计算直线距离
int dst(int xint yfloat afloat bfloat c)
{
return abs((a*x+b*y+c)/sqrt(a*a+b*b));
}
//用于表示图像上点的一个结构体
struct Point
{
int h; //该点高度坐标
int w; //该点宽度坐标
Point(int aint b)
{
h=a;
w=b;
}
};
//计算两点之间距离
int dst(Point p1Point p2)
{
int dist=sqrt((p1.h-p2.h)*(p1.h-p2.h)+(p1.w-p2.w)*(p1.w-p2.w));
return dist;
}
//根据索引获取一维数组值
unsigned char Getdata(int hint wunsigned char* data)
{
return data[h*W+w];
}
//查找p点左上方的点是否为0
bool checkLU(Point punsigned char* data)
{
if (p.w==0)//没有左
return false;
else if (p.h==0) //没有上
return false;
else if (Getdata(p.h-1p.w-1data)!=0)//左上方不为0
return false;
return true;
}
//查找p点正上方的点是否为0
bool checkU(Point punsigned char* data)
{
if (p.h==0)//没有上
return false;
else if (Getdata(p.h-1p.wdata)!=0)//正上方不为0
return false;
return true;
}
//查找p点右上方的点是否为0
bool checkRU(Point punsigned char* data)
{
if (p.w==W-1) //没有右
return false;
else if (p.h==0)//没有上
return false;
else if (Getdata(p.h-1p.w+1data)!=0)//右上方不为0
return false;
return true;
}
//查找p点正左方的点是否为0
bool checkL(Point punsigned char* data)
{
if (p.w==0) //没有左
return false;
else if (Getdata(p.hp.w-1data)!=0)//正左方不为0
return false;
return true;
}
//查找p点正右方的点是否为0
bool checkR(Point punsigned char* data)
{
if (p.w==W-1) //没有右
return false;
else if (Getdata(p.hp.w+1data)!=0)//正右方不为0
return false;
return true;
}
//查找p点左下方的点是否为0
bool checkLD(Point punsigned char* data)
{
if (p.w==0) //没有左
return false;
else if (p.h==H-1)//没有下
return false;
else if (Getdata(p.h+1p.w-1data)!=0)//左下方不为0
return false;
return true;
}
//查找p点正下方的点是否为0
bool checkD(Point punsigned char* data)
{
if (p.h==H-1)//没有下
return false;
else if (Getdata(p.h+1p.wdata)!=0)//正下方不为0
return false;
return true;
}
//查找p点右下方的点是否为0
bool checkRD(Point punsigned char* data)
{
if (p.w==W-1) //没有右
return false;
else if (p.h==H-1)//没有下
return false;
else if (Getdata(p.h+1p.w+1data)!=0)//右下方不为0
return false;
return true;
}
//寻找从点p开始,最左最上的点
Point Find_LU(Point punsigned char* data)
{
Point p1=pp2=p;
int i=1j=0;
while (i*=-1) //让i在1和-1之间来回切换,用于记录最近两个时刻所要求的目标点
{
if (checkLU(pdata))//左上方
{
if (i==1)
{
if (p.h-1!=p1.h||p.w-1!=p1.w) //查找的点为新点
p1=Point(p.h-1p.w-1);
else break;//改点已经找过,则改点为要找的点
}
else
{
if (p.h-1!=p2.h||p.w-1!=p2.w) //查找的点为新点
p2=Point(p.h-1p.w-1);
else break;
}
}
else if (checkU(pdata))//上方
{
if(i==1)
{
if (p.h-1!=p1.h||p.w!=p1.w)
p1=Point(p.h-1p.w);
else break;
}
else
{
if (p.h-1!=p2.h||p.w!=p2.w)
p2=Point(p.h-1p.w);
else break;
}
}
else if (checkRU(pdata))//右上方
{
if (i==1)
{
if (p.h-1!=p1.h
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 31534 2009-01-15 20:33 数字识别源程序\cvapp.cpp
文件 972 2009-01-12 16:23 数字识别源程序\cvapp.h
文件 20740 2009-01-14 11:50 数字识别源程序\Imgrcv.aps
文件 1155 2009-01-15 19:31 数字识别源程序\Imgrcv.clw
文件 2063 2008-12-28 15:23 数字识别源程序\Imgrcv.cpp
文件 4340 2008-12-28 17:14 数字识别源程序\Imgrcv.dsp
文件 537 2008-12-28 15:23 数字识别源程序\Imgrcv.dsw
文件 1324 2008-12-28 15:23 数字识别源程序\Imgrcv.h
文件 181248 2009-01-15 21:11 数字识别源程序\Imgrcv.ncb
文件 48640 2009-01-15 21:11 数字识别源程序\Imgrcv.opt
文件 453 2009-01-15 21:11 数字识别源程序\Imgrcv.plg
文件 5312 2009-01-02 15:15 数字识别源程序\Imgrcv.rc
文件 4724 2009-01-14 13:48 数字识别源程序\ImgrcvDlg.cpp
文件 1363 2009-01-02 15:15 数字识别源程序\ImgrcvDlg.h
文件 3579 2008-12-28 15:23 数字识别源程序\ReadMe.txt
文件 1078 2008-12-28 15:23 数字识别源程序\res\Imgrcv.ico
文件 398 2008-12-28 15:23 数字识别源程序\res\Imgrcv.rc2
..A.SH. 3072 2009-01-15 22:47 数字识别源程序\res\Thumbs.db
文件 776 2009-01-02 15:15 数字识别源程序\resource.h
文件 208 2008-12-28 15:23 数字识别源程序\StdAfx.cpp
文件 1054 2008-12-28 15:23 数字识别源程序\StdAfx.h
文件 1144 2009-01-15 21:11 数字识别源程序\图片\1.txt
文件 1144 2009-01-15 21:11 数字识别源程序\图片\2.txt
文件 1144 2009-01-15 21:11 数字识别源程序\图片\3.txt
文件 1144 2009-01-15 21:11 数字识别源程序\图片\4.txt
文件 14690 2009-01-15 18:52 数字识别源程序\图片\Image0.BMP
文件 14690 2009-01-15 18:59 数字识别源程序\图片\Image1.bmp
文件 14690 2009-01-15 19:59 数字识别源程序\图片\Image2.BMP
文件 14690 2009-01-15 20:02 数字识别源程序\图片\Image3.BMP
文件 14690 2009-01-15 14:25 数字识别源程序\图片\Image4.bmp
............此处省略18个文件信息
相关资源
- 遥感图像几何校正模型探讨
- 《Visual Prolog 集成开发环境(下)》
- 《Visual Prolog 基础类》 中文参考.chm
- 我的界面(visual foxpro)源码
- 图像的小波包分解
- VisualStudioUninstaller vs卸载工具
- 组态王驱动开发包3.0.0.7(中文)
- 多窗口后台鼠标连点器
- 使用选择性重传协议实现UDP可靠通信
- 图像二维小波变换的实现源代码
- VC 获得文件属性 获取文件的创建时
- 读者写者问题(读者优先,写者优先
- 图像二值化
- 用VC 编写的仿QQ聊天室程序源代码
- [免费]图像识别c 源码
- 三维重建(旋转)由已知对应图像点
- 外点法程序
- 外罚函数程序
- jcrop v0.9.12
- qt-电子点菜系统
- 防火墙编程-Visual C 网络通信开发
- 推箱子及人工智能寻路C 源代码
- 自己写的航空订票系统c 版--数据结构
- 数据结构实验魔王语言
- MUSIC算法c 实现
- C 餐厅叫号系统(QT平)
- 国际象棋c 完整版
- 冈萨雷斯 数字图像处理 源代码(m文
-
ob
jectARX给Auto CAD加工具条 - qt图像处理
评论
共有 条评论