資源簡介
這是本人寫的有關bmp文件的關于車牌字符的代碼,請多多指教!

代碼片段和文件信息
#include
#include????
#include?
#include?“license.h“
#define?size?50?//歸一化圖像大小
using?namespace?std;
int?nWidth?=0nHeight?=?0LineByte?=?0;
BITMAPFILEHEADER??phph0;??//文件頭指針
BITMAPINFOHEADER??ih;??//數據頭指針
IMAGEDATA?*imagedata?=?NULL;//動態分配存儲圖片的像素信息的二維數組
IMAGEDATA?*imagedata0?=?NULL;
void?LoadBmp(char?*cName)
{
WORD?bfType;
FILE?*fp;
int?i?=?0j?=?0;
?if?(cName?==?nullptr)
?{
???????printf(“loadbmp?faile!?please?right?name!“);
???return;
?}
if?((fp?=?fopen(cName“rb“))?==?nullptr)
{
printf(?“open?fauliure!\n“?);
return;
}
fread(&bfTypesizeof(WORD)1fp);//讀位圖文件頭
if?(0x4D42?!=?bfType)
{
printf(“this?is?not?bmp!“);
return;
}
fread(&phsizeof(BITMAPFILEHEADER)1fp);//讀位圖文件頭
fread(&ihsizeof(BITMAPINFOHEADER)1fp);//讀位圖信息頭
nWidth?=?ih.biWidth;//寬
nHeight?=?ih.biHeight;//高
imagedata?=?(IMAGEDATA?*)(malloc(nWidth*nHeight*sizeof(IMAGEDATA)));//開辟這么多的字節
for(int?i?=?0;i? {
for(int?j?=?0;j? {
(*(imagedata?+?i?*?nWidth?+?j)).blue?=?0;
(*(imagedata?+?i?*?nWidth?+?j)).green?=?0;
(*(imagedata?+?i?*?nWidth?+?j)).red?=?0;
}
}
fread(imagedatasizeof(IMAGEDATA)*nWidthnHeightfp);
fclose(fp);
fp?=?nullptr;
}
void?GrayBinaryBmp()
{
int?i?=?0j?=?0;
FILE?*fp;
WORD?bfType?=?0x4D42;
if((fp?=?fopen(“binary.bmp““wb“))==nullptr)
{
printf(“error!?graybinarybmp!“);
return;
}
?fwrite(&bfTypesizeof(WORD)1fp);
?fwrite(&phsizeof(BITMAPFILEHEADER)1fp);
?fwrite(&ihsizeof(BITMAPINFOHEADER)1fp);
for(i?=?0;?i? ?{
?for(j?=?0;j? ?{
?(*(imagedata?+?i?*?nWidth?+?j)).green?=(BYTE)(?0.11?*?(*(imagedata?+?i?*?nWidth?+?j)).blue?+?0.3?*?(*(imagedata?+?i?*?nWidth?+?j)).red?+?0.59?*?(*(imagedata?+?i?*?nWidth?+?j)).green);
(*(imagedata?+?i?*?nWidth?+?j)).blue?=?(*(imagedata?+?i?*?nWidth?+?j)).red?=?(*(imagedata?+?i?*?nWidth?+?j)).green;
??????????}
??????}
??//二值化
??int?yuzhi?=?90;
????for(int??i?=?0;i? {
for(int?j?=?0;j? {
if(?(*(imagedata?+?i?*?nWidth?+?j)).green? ??{
??(*(imagedata?+?i?*?nWidth?+?j)).green?=(*(imagedata?+?i?*?nWidth?+?j)).blue?=(*(imagedata?+?i?*?nWidth?+?j)).red?=?0;
??????fwrite(imagedata?+?i?*?nWidth?+?j31fp);
}
??else
??{
??(*(imagedata?+?i?*?nWidth?+?j)).green?=(*(imagedata?+?i?*?nWidth?+?j)).blue?=(*(imagedata?+?i?*?nWidth?+?j)).red?=?255;
???????fwrite(imagedata?+?i?*?nWidth?+?j31fp);
??}
}
?}
???
}
//分割處理
void?segment()
{
WORD?bfType_w?=?0x4D42;
FILE?*fp1;
int?i?=?0j?=?0;
int?count?=?0k?=?0;
int?T?=?1T1?=?1;//閾值
int?flag?=?0;
int?row_start?=?0row_end?=0;//用來記錄車牌開始,結束行
int?col_start?=?0col_end?=0;//用來記錄車牌開始,結束列
for(?i?=?0;i? {
count?=?0;
for(?j?=?0;j? {
if?((*(imagedata?+?i?*?nWidth?+?j)).red?!=?(*(imagedata?+?i?*?nWidth?+?j+1)).red)
count
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????77824??2013-12-13?13:51??license\Debug\plc.exe
?????文件?????431464??2013-12-13?13:51??license\Debug\plc.ilk
?????文件?????838656??2013-12-13?13:51??license\Debug\plc.pdb
?????文件????1152054??2013-10-22?02:51??license\plc\56.bmp
?????文件????1152054??2013-12-13?13:51??license\plc\binary.bmp
?????文件????????620??2013-12-13?13:51??license\plc\Debug\cl.command.1.tlog
?????文件??????11102??2013-12-13?13:51??license\plc\Debug\CL.read.1.tlog
?????文件????????232??2013-12-13?13:51??license\plc\Debug\CL.write.1.tlog
?????文件??????????2??2013-12-13?13:51??license\plc\Debug\li
?????文件??????????2??2013-12-13?13:51??license\plc\Debug\li
?????文件??????????2??2013-12-13?13:51??license\plc\Debug\li
?????文件??????????2??2013-12-13?13:51??license\plc\Debug\li
?????文件???????1522??2013-12-13?13:51??license\plc\Debug\li
?????文件???????3600??2013-12-13?13:51??license\plc\Debug\li
?????文件????????228??2013-12-13?13:51??license\plc\Debug\li
?????文件?????176606??2013-12-13?13:51??license\plc\Debug\platelicenserecognition.obj
?????文件????????682??2013-12-13?13:25??license\plc\Debug\plc.Build.CppClean.log
?????文件?????????40??2013-12-13?13:51??license\plc\Debug\plc.lastbuildstate
?????文件???????1742??2013-12-13?13:51??license\plc\Debug\plc.log
?????文件?????257024??2013-12-13?13:51??license\plc\Debug\vc110.idb
?????文件?????339968??2013-12-13?13:51??license\plc\Debug\vc110.pdb
?????文件???????1390??2013-11-27?10:46??license\plc\license.h
?????文件??????10930??2013-12-13?13:51??license\plc\platelicenserecognition.cpp
?????文件???????4092??2013-11-26?18:59??license\plc\plc.vcxproj
?????文件???????1081??2013-11-26?18:59??license\plc\plc.vcxproj.filters
?????文件????1136970??2013-12-13?13:51??license\plc\quzaosheng.bmp
?????文件?????899214??2013-11-26?19:12??license\plc\segmentall
?????文件?????899214??2013-11-26?19:36??license\plc\segmentall.bmp
?????文件???????3129??2013-11-26?20:02??license\plc.psess
?????文件????7208960??2013-12-13?14:42??license\plc.sdf
............此處省略10個文件信息
- 上一篇:Gmap鼠標拖拽Marker
- 下一篇:基于SSH三大框架的-檔案管理系統.rar
評論
共有 條評論