资源简介
初学者的实用代码,对熟悉模式识别技术有一定的帮助,还可用于其他字符识别的算法参考

代码片段和文件信息
#include “stdafx.h“
#include “cdib.h“
#include “windowsx.h“
#include “math.h“
#define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4)
CDib::CDib()
{
size=0;
}
CDib::~CDib()
{
GlobalFreePtr(m_pBitmapInfo);
}
void CDib::LoadFile(const char* dibFileName)
{
strcpy(m_fileNamedibFileName);
CFile dibFile(m_fileName CFile::modeRead);
dibFile.Read((void*)&bitmapFileHeadersizeof(BITMAPFILEHEADER));
if (bitmapFileHeader.bfType == 0x4d42)
{
DWORD fileLength = dibFile.GetLength();
size = fileLength -sizeof(BITMAPFILEHEADER);
pDib =(BYTE*)GlobalAllocPtr(GMEM_MOVEABLE size);
dibFile.Read((void*)pDib size);
dibFile.Close();
m_pBitmapInfo = (BITMAPINFO*) pDib;
m_pBitmapInfoHeader = (BITMAPINFOHEADER*) pDib;
m_pRGB = (RGBQUAD*)(pDib +
m_pBitmapInfoHeader->biSize);
int m_numberOfColors = GetNumberOfColors();
if (m_pBitmapInfoHeader->biClrUsed == 0)
m_pBitmapInfoHeader->biClrUsed =
m_numberOfColors;
DWORD colorTableSize = m_numberOfColors *
sizeof(RGBQUAD);
m_pData = pDib + m_pBitmapInfoHeader->biSize
+ colorTableSize;
if (m_pRGB == (RGBQUAD*)m_pData) // No color table
m_pRGB = NULL;
m_pBitmapInfoHeader->biSizeImage = GetSize();
m_valid = TRUE;
}
else
{
m_valid = FALSE;
AfxMessageBox(“This isn‘t a bitmap file!“);
}
}
BOOL CDib::IsValid()
{
return m_valid;
}
char* CDib::GetFileName()
{
return m_fileName;
}
UINT CDib::GetWidth()
{
return (UINT) m_pBitmapInfoHeader->biWidth;
}
UINT CDib::GetHeight()
{
return (UINT) m_pBitmapInfoHeader->biHeight;
}
DWORD CDib::GetSize()
{
if (m_pBitmapInfoHeader->biSizeImage != 0)
return m_pBitmapInfoHeader->biSizeImage;
else
{
DWORD height = (DWORD) GetHeight();
DWORD width = (DWORD) GetWidth();
return height * width;
}
}
void CDib::SetWidth(UINT width)
{
m_pBitmapInfoHeader->biWidth=width;
}
void CDib::SetHeight(UINT height)
{
m_pBitmapInfoHeader->biHeight=height;
}
UINT CDib::GetNumberOfColors()
{
int numberOfColors;
if ((m_pBitmapInfoHeader->biClrUsed == 0) &&
(m_pBitmapInfoHeader->biBitCount < 9))
{
switch (m_pBitmapInfoHeader->biBitCount)
{
case 1: numberOfColors = 2; break;
case 4: numberOfColors = 16; break;
case 8: numberOfColors = 256;
}
}
else
numberOfColors = (int) m_pBitmapInfoHeader->biClrUsed;
return numberOfColors;
}
BYTE* CDib::GetData()
{
return m_pData;
}
RGBQUAD* CDib::GetRGB()
{
return m_pRGB;
}
BITMAPINFO* CDib::GetInfo()
{
return m_pBitmapInfo;
}
WORD CDib::PaletteSize(LPBYTE lpDIB)
{
return (DIBNumColors(lpDIB) * sizeof(RGBTRIPLE));
}
WORD CDib::DIBNumColors(LPBYTE lpDIB)
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3606 2008-08-05 10:38 字符识别程序,26个英文字母的识别\CDib.cpp
文件 844 2008-08-05 10:38 字符识别程序,26个英文字母的识别\CDib.h
文件 0 2008-08-06 09:26 字符识别程序,26个英文字母的识别\chardefine.h
文件 5092 2005-01-01 09:02 字符识别程序,26个英文字母的识别\Classification.cpp
文件 1145 2005-01-01 09:02 字符识别程序,26个英文字母的识别\Classification.h
文件 17246 2013-01-03 16:15 字符识别程序,26个英文字母的识别\Debug\CDib.obj
文件 23413 2013-01-03 16:15 字符识别程序,26个英文字母的识别\Debug\Classification.obj
文件 12978 2013-01-03 16:15 字符识别程序,26个英文字母的识别\Debug\DlgSave.obj
文件 10541 2013-01-03 16:15 字符识别程序,26个英文字母的识别\Debug\GetFeature.obj
文件 22428 2013-01-03 16:15 字符识别程序,26个英文字母的识别\Debug\MainFrm.obj
文件 151664 2013-01-04 22:33 字符识别程序,26个英文字母的识别\Debug\pattern.exe
文件 429588 2013-01-04 22:33 字符识别程序,26个英文字母的识别\Debug\pattern.ilk
文件 24100 2013-01-03 16:15 字符识别程序,26个英文字母的识别\Debug\pattern.obj
文件 5497428 2013-01-03 16:15 字符识别程序,26个英文字母的识别\Debug\pattern.pch
文件 533504 2013-01-04 22:33 字符识别程序,26个英文字母的识别\Debug\pattern.pdb
文件 7660 2013-01-03 16:15 字符识别程序,26个英文字母的识别\Debug\pattern.res
文件 25233 2013-01-04 22:32 字符识别程序,26个英文字母的识别\Debug\patternDoc.obj
文件 41727 2013-01-03 16:15 字符识别程序,26个英文字母的识别\Debug\patternView.obj
文件 33878 2013-01-03 16:20 字符识别程序,26个英文字母的识别\Debug\PatternView2.obj
文件 106245 2013-01-03 16:15 字符识别程序,26个英文字母的识别\Debug\StdAfx.obj
文件 230400 2013-01-05 12:30 字符识别程序,26个英文字母的识别\Debug\vc60.idb
文件 372736 2013-01-04 22:32 字符识别程序,26个英文字母的识别\Debug\vc60.pdb
文件 927 2008-08-06 09:30 字符识别程序,26个英文字母的识别\DlgSave.cpp
文件 1196 2008-08-06 09:30 字符识别程序,26个英文字母的识别\DlgSave.h
文件 3904 2008-08-06 09:14 字符识别程序,26个英文字母的识别\GetFeature.cpp
文件 1403 2008-08-06 09:14 字符识别程序,26个英文字母的识别\GetFeature.h
文件 3010 2008-08-05 09:56 字符识别程序,26个英文字母的识别\MainFrm.cpp
文件 1704 2008-08-05 09:44 字符识别程序,26个英文字母的识别\MainFrm.h
文件 8160 2005-01-13 00:00 字符识别程序,26个英文字母的识别\Matrix.h
文件 30324 2013-01-03 16:28 字符识别程序,26个英文字母的识别\pattern.aps
............此处省略51个文件信息
- 上一篇:基于单片机的循迹小车各个模块原理图
- 下一篇:电子商务支付平台一期数据库设计文档
相关资源
- 语音信号处理 赵力
- [免费]图像识别c 源码
- 一个人脸识别程序源码
- 基于bp神经网络的表情识别
- 支持向量机的船舶目标识别
- 基于OpenCV的数字识别468815
- LDA 人脸识别
- 血液图像处理—细胞识别
- 编译词法分析器识别关键字常数和符
- DSP 语音识别程序 DTW MFCC
- halcon简单实现人脸识别.hdev
- scratch -教学案例 识别物品颜色.sb3
- OCR识别字符
- halcon-ocr训练及识别
- Halcon车牌识别
- 基于HALCON识别指示灯亮灭和OCR识别.
- 滑块验证码无原图纯计算识别坐标.
- 解决Y470/Y570更新2.12BIOS后无法识别8G内
- 百度API车牌识别DEMO.rar
- 百度图片识别源码.rar
- 物联网中无线传感器节点和RFID数据融
- 常用电子元器件图片识别
- 电子元器件识别
- 基于进化算法的岩体参数智能识别
- INBarcodeOCR条码识别组件,识别率及速
- 文软快递单扫描识别软件 v8.1 简易版
- 4×4矩阵式键盘识别技术源码
- 基于模型识别的小电流接地选线方法
- 指纹自动考勤系统的设计与实现
- 特定人语音识别技术在汽车控制上的
评论
共有 条评论