找回密码
 立即注册→加入我们

QQ登录

只需一步,快速开始

搜索
热搜: 下载 VB C 实现 编写
查看: 1899|回复: 0

车牌识别(八)模板比较

[复制链接]
发表于 2018-8-4 14:35:08 | 显示全部楼层 |阅读模式

欢迎访问技术宅的结界,请注册或者登录吧。

您需要 登录 才可以下载或查看,没有账号?立即注册→加入我们

×
本帖最后由 乘简 于 2018-8-4 14:37 编辑

就是把缩放后的图片,与事先准备好的模板进行比较,找到最优解,再输入车牌。

我这里用了与原作者不同的方法,原方法简单字符与复杂字比只会白点越少
而我所采用的就是在比较的时候,如果两点都为白色,则为黑色
如果两点不相同,则为白色,这样只有最相似的字白点才会最少
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>

  4. typedef unsigned long       DWORD;
  5. typedef int                 BOOL;
  6. typedef unsigned char       BYTE;
  7. typedef unsigned short      WORD;
  8. typedef float               FLOAT;
  9. typedef unsigned char       byte;

  10. #define max(a,b)            (((a) > (b)) ? (a) : (b))
  11. #define min(a,b)            (((a) < (b)) ? (a) : (b))

  12. //车牌点阵字体,16*32字体,逐行式,两字节占一行
  13. byte const FONT[][64]={
  14. {0x07,0xE0,0x1F,0xF8,0x3F,0xFC,0x7C,0x3E,0x78,0x1E,0xF0,0x0F,0xE0,0x07,0xE0,0x07,
  15. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  16. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  17. 0xE0,0x07,0xE0,0x07,0xF0,0x0F,0x78,0x1E,0x7C,0x3E,0x3F,0xFC,0x1F,0xF8,0x07,0xE0},/*"0.BMP",0*/

  18. {0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,
  19. 0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,
  20. 0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,
  21. 0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00},/*"1.BMP",0*/

  22. {0x07,0xE0,0x1F,0xF8,0x3F,0xFC,0x7C,0x3E,0x78,0x1E,0xF0,0x0F,0xE0,0x07,0xE0,0x07,
  23. 0x00,0x07,0x00,0x07,0x00,0x0F,0x00,0x0F,0x00,0x1F,0x00,0x1E,0x00,0x3C,0x00,0x3C,
  24. 0x00,0x78,0x00,0x78,0x00,0xF0,0x01,0xE0,0x03,0xE0,0x07,0xC0,0x07,0x80,0x0F,0x00,
  25. 0x1E,0x00,0x3E,0x00,0x7C,0x00,0xF8,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},/*"2.BMP",0*/

  26. {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x1F,0x00,0x3E,0x00,0x7C,0x00,0xF8,0x01,0xF0,
  27. 0x03,0xE0,0x07,0xC0,0x07,0x80,0x0F,0xF0,0x1F,0xF8,0x3F,0xFC,0x1F,0xFE,0x0C,0x3E,
  28. 0x00,0x1E,0x00,0x0F,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,
  29. 0xE0,0x07,0xE0,0x07,0xF0,0x0F,0x78,0x1E,0x7C,0x3E,0x3F,0xFC,0x1F,0xF8,0x07,0xE0},/*"3.BMP",0*/

  30. {0x00,0x1C,0x00,0x1C,0x00,0x3C,0x00,0x3C,0x00,0x7C,0x00,0x7C,0x00,0xFC,0x00,0xFC,
  31. 0x01,0xDC,0x01,0xDC,0x03,0x9C,0x03,0x9C,0x07,0x1C,0x07,0x1C,0x0E,0x1C,0x0E,0x1C,
  32. 0x1C,0x1C,0x1C,0x1C,0x38,0x1C,0x70,0x1C,0x70,0x1C,0xE0,0x1C,0xFF,0xFF,0xFF,0xFF,
  33. 0xFF,0xFF,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C},/*"4.BMP",0*/

  34. {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,
  35. 0xE0,0x00,0xE0,0x00,0xE3,0xC0,0xEF,0xF0,0xFF,0xF8,0xFF,0xFC,0xFC,0x3E,0xF0,0x1E,
  36. 0xE0,0x0F,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0xE0,0x07,
  37. 0xE0,0x07,0xE0,0x07,0xF0,0x0F,0x78,0x1E,0x7C,0x3E,0x3F,0xFC,0x1F,0xF8,0x07,0xE0},/*"5.BMP",0*/

  38. {0x00,0xE0,0x00,0xE0,0x01,0xC0,0x01,0xC0,0x03,0xC0,0x03,0x80,0x07,0x80,0x07,0x00,
  39. 0x0F,0x00,0x0F,0x00,0x0F,0x00,0x1E,0x00,0x1E,0x00,0x3E,0x00,0x3F,0xE0,0x7F,0xF8,
  40. 0x7F,0xFC,0x7C,0x3E,0xF8,0x1E,0xF0,0x0F,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  41. 0xE0,0x07,0xE0,0x07,0xF0,0x0F,0x78,0x1E,0x7C,0x3E,0x3F,0xFC,0x1F,0xF8,0x07,0xE0},/*"6.BMP",0*/

  42. {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x0F,0x00,0x0E,0x00,0x0E,0x00,0x1C,0x00,0x1C,
  43. 0x00,0x38,0x00,0x38,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0xE0,0x00,0xE0,0x01,0xC0,
  44. 0x01,0xC0,0x01,0xC0,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x07,0x00,0x07,0x00,
  45. 0x07,0x00,0x0F,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x1E,0x00,0x1C,0x00},/*"7.BMP",0*/

  46. {0x07,0xE0,0x1F,0xF8,0x3F,0xFC,0x7C,0x3E,0x78,0x1E,0xF0,0x0F,0xE0,0x07,0xE0,0x07,
  47. 0xE0,0x07,0xF0,0x0F,0x70,0x0E,0x78,0x1E,0x3C,0x3C,0x1F,0xF8,0x0F,0xF0,0x1F,0xF8,
  48. 0x3F,0xFC,0x7C,0x3E,0x78,0x1E,0xF0,0x0F,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  49. 0xE0,0x07,0xE0,0x07,0xF0,0x0F,0x78,0x1E,0x7C,0x3E,0x3F,0xFC,0x1F,0xF8,0x07,0xE0},/*"8.BMP",0*/

  50. {0x07,0xE0,0x1F,0xF8,0x3F,0xFC,0x7C,0x3E,0x78,0x1E,0xF0,0x0F,0xE0,0x07,0xE0,0x07,
  51. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xF0,0x0F,0x78,0x1F,0x7C,0x3E,0x3F,0xFE,
  52. 0x1F,0xFE,0x0F,0xFC,0x00,0x3C,0x00,0x78,0x00,0x78,0x00,0xF0,0x00,0xF0,0x00,0xF0,
  53. 0x00,0xE0,0x01,0xE0,0x01,0xC0,0x03,0xC0,0x03,0x80,0x03,0x80,0x07,0x00,0x07,0x00},/*"9.BMP",0*/

  54. {0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,
  55. 0x07,0xE0,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x1C,0x38,0x1C,0x38,
  56. 0x1C,0x38,0x1C,0x38,0x1C,0x38,0x3F,0xFC,0x3F,0xFC,0x3F,0xFC,0x38,0x1C,0x38,0x1C,
  57. 0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0xE0,0x07,0xE0,0x07,0xE0,0x07},/*"A.BMP",0*/

  58. {0xFF,0xE0,0xFF,0xF8,0xFF,0xFC,0xE0,0x7E,0xE0,0x1E,0xE0,0x0F,0xE0,0x07,0xE0,0x07,
  59. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x0E,0xE0,0x1E,0xE0,0x7C,0xFF,0xF8,0xFF,0xF0,
  60. 0xFF,0xFC,0xE0,0x7E,0xE0,0x1E,0xE0,0x0F,0xE0,0x0F,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  61. 0xE0,0x07,0xE0,0x07,0xE0,0x0F,0xE0,0x1E,0xE0,0x7E,0xFF,0xFC,0xFF,0xF8,0xFF,0xE0},/*"B.BMP",0*/

  62. {0x07,0xE0,0x1F,0xF8,0x3F,0xFC,0x7C,0x3E,0x78,0x1E,0xF0,0x0F,0xE0,0x07,0xE0,0x07,
  63. 0xE0,0x07,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,
  64. 0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x07,
  65. 0xE0,0x07,0xE0,0x07,0xF0,0x0F,0x78,0x1E,0x7C,0x3E,0x3F,0xFC,0x1F,0xF8,0x07,0xE0},/*"C.BMP",0*/

  66. {0xFF,0xE0,0xFF,0xF8,0xFF,0xFC,0xE0,0x7E,0xE0,0x1E,0xE0,0x0F,0xE0,0x07,0xE0,0x07,
  67. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  68. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  69. 0xE0,0x07,0xE0,0x07,0xE0,0x0F,0xE0,0x1E,0xE0,0x7E,0xFF,0xFC,0xFF,0xF8,0xFF,0xE0},/*"D.BMP",0*/

  70. {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,
  71. 0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xFF,0xFC,0xFF,0xFC,
  72. 0xFF,0xFC,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,
  73. 0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},/*"E.BMP",0*/

  74. {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,
  75. 0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xFF,0xFC,0xFF,0xFC,
  76. 0xFF,0xFC,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,
  77. 0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00},/*"F.BMP",0*/

  78. {0x07,0xE0,0x1F,0xF8,0x3F,0xFC,0x7C,0x3E,0x78,0x1E,0xF0,0x0F,0xE0,0x07,0xE0,0x07,
  79. 0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0xFF,
  80. 0xE0,0xFF,0xE0,0xFF,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  81. 0xE0,0x07,0xE0,0x07,0xF0,0x0F,0x78,0x0E,0x7C,0x3E,0x3F,0xFC,0x1F,0xF8,0x07,0xE0},/*"G.BMP",0*/

  82. {0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  83. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xFF,0xFF,0xFF,0xFF,
  84. 0xFF,0xFF,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  85. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07},/*"H.BMP",0*/

  86. {0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,
  87. 0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,
  88. 0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  89. 0xE0,0x07,0xE0,0x07,0xF0,0x0F,0x78,0x1E,0x7C,0x3E,0x3F,0xFC,0x1F,0xF8,0x07,0xE0},/*"J.BMP",0*/

  90. {0xE0,0x1E,0xE0,0x1E,0xE0,0x3C,0xE0,0x78,0xE0,0x78,0xE0,0xF0,0xE0,0xE0,0xE1,0xE0,
  91. 0xE3,0xC0,0xE3,0xC0,0xE7,0x80,0xEF,0x00,0xEF,0x00,0xFE,0x00,0xFF,0x00,0xFF,0x80,
  92. 0xFF,0x80,0xFB,0xC0,0xF3,0xC0,0xE1,0xE0,0xE1,0xE0,0xE0,0xF0,0xE0,0xF0,0xE0,0x70,
  93. 0xE0,0x78,0xE0,0x78,0xE0,0x3C,0xE0,0x3C,0xE0,0x1E,0xE0,0x1E,0xE0,0x0E,0xE0,0x0F},/*"K.BMP",0*/

  94. {0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,
  95. 0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,
  96. 0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,
  97. 0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},/*"L.BMP",0*/

  98. {0xF0,0x0F,0xF8,0x1F,0xF8,0x1F,0xF8,0x1F,0xF8,0x1F,0xFC,0x3F,0xFC,0x3F,0xFC,0x3F,
  99. 0xEE,0x77,0xEE,0x77,0xE7,0xE7,0xE7,0xE7,0xE3,0xC7,0xE1,0x87,0xE0,0x07,0xE0,0x07,
  100. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  101. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07},/*"M.BMP",0*/

  102. {0xE0,0x07,0xE0,0x07,0xF0,0x07,0xF0,0x07,0xF8,0x07,0xF8,0x07,0xFC,0x07,0xFC,0x07,
  103. 0xEE,0x07,0xEE,0x07,0xE6,0x07,0xE7,0x07,0xE7,0x07,0xE3,0x07,0xE3,0x87,0xE3,0x87,
  104. 0xE1,0xC7,0xE1,0xC7,0xE1,0xE7,0xE0,0xE7,0xE0,0xE7,0xE0,0x77,0xE0,0x77,0xE0,0x77,
  105. 0xE0,0x3F,0xE0,0x3F,0xE0,0x3F,0xE0,0x1F,0xE0,0x1F,0xE0,0x1F,0xE0,0x0F,0xE0,0x0F},/*"N.BMP",0*/

  106. {0xFF,0xE0,0xFF,0xF8,0xFF,0xFC,0xE0,0x3E,0xE0,0x1E,0xE0,0x0F,0xE0,0x07,0xE0,0x07,
  107. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x0F,0xE0,0x1E,0xE0,0x3E,
  108. 0xFF,0xFC,0xFF,0xF8,0xFF,0xE0,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,
  109. 0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00},/*"P.BMP",0*/

  110. {0x07,0xE0,0x1F,0xF8,0x3F,0xFC,0x7C,0x3E,0x78,0x1E,0xF0,0x0F,0xE0,0x07,0xE0,0x07,
  111. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  112. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0xC7,
  113. 0xE1,0xE7,0xE1,0xF7,0xF0,0xFF,0x78,0x7E,0x7C,0x3E,0x3F,0xFF,0x1F,0xFF,0x07,0xEE},/*"Q.BMP",0*/

  114. {0xFF,0xE0,0xFF,0xF8,0xFF,0xFC,0xE0,0x3E,0xE0,0x1E,0xE0,0x0F,0xE0,0x07,0xE0,0x07,
  115. 0xE0,0x07,0xE0,0x07,0xE0,0x0F,0xE0,0x0E,0xE0,0x1E,0xE0,0x3C,0xE0,0xFC,0xFF,0xF8,
  116. 0xFF,0xF0,0xFF,0xE0,0xE1,0xE0,0xE1,0xE0,0xE0,0xE0,0xE0,0xF0,0xE0,0x70,0xE0,0x70,
  117. 0xE0,0x78,0xE0,0x38,0xE0,0x3C,0xE0,0x3C,0xE0,0x1C,0xE0,0x1E,0xE0,0x0F,0xE0,0x0F},/*"R.BMP",0*/

  118. {0x07,0xE0,0x1F,0xF8,0x3F,0xFC,0x7C,0x3E,0x78,0x1E,0xF0,0x0F,0xE0,0x07,0xE0,0x07,
  119. 0xE0,0x07,0xE0,0x00,0xF0,0x00,0x78,0x00,0x7C,0x00,0x3F,0x00,0x1F,0xE0,0x0F,0xF8,
  120. 0x03,0xFC,0x00,0x3E,0x00,0x1E,0x00,0x0F,0x00,0x07,0x00,0x07,0x00,0x07,0xE0,0x07,
  121. 0xE0,0x07,0xE0,0x07,0xF0,0x0F,0x78,0x1E,0x7C,0x3E,0x3F,0xFC,0x1F,0xF8,0x07,0xE0},/*"S.BMP",0*/

  122. {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,
  123. 0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,
  124. 0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,
  125. 0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0},/*"T.BMP",0*/

  126. {0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  127. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  128. 0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,
  129. 0xE0,0x07,0xE0,0x07,0xF0,0x0F,0x78,0x1E,0x7C,0x3E,0x3F,0xFC,0x1F,0xF8,0x07,0xE0},/*"U.BMP",0*/

  130. {0xE0,0x07,0xE0,0x07,0xF0,0x0F,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x78,0x1E,
  131. 0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x3C,0x3C,0x1C,0x38,0x1C,0x38,0x1C,0x38,
  132. 0x1C,0x38,0x1C,0x38,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x07,0xE0,
  133. 0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0},/*"V.BMP",0*/

  134. {0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE1,0x87,0xF1,0x8F,0x71,0x8E,0x71,0x8E,
  135. 0x73,0xCE,0x73,0xCE,0x73,0xCE,0x73,0xCE,0x73,0xCE,0x73,0xCE,0x73,0xCE,0x73,0xCE,
  136. 0x73,0xCE,0x3B,0xDC,0x3E,0x7C,0x3E,0x7C,0x3E,0x7C,0x3E,0x7C,0x3E,0x7C,0x3E,0x7C,
  137. 0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x3C,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x18,0x18},/*"W.BMP",0*/

  138. {0xE0,0x07,0xF0,0x0F,0x70,0x0E,0x78,0x1C,0x38,0x1C,0x3C,0x3C,0x1C,0x38,0x1C,0x78,
  139. 0x0E,0x70,0x0E,0x70,0x0F,0xE0,0x07,0xE0,0x07,0xE0,0x03,0xC0,0x03,0xC0,0x03,0xC0,
  140. 0x03,0xC0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x1C,0x38,
  141. 0x1C,0x38,0x3C,0x38,0x38,0x1C,0x38,0x1C,0x70,0x1E,0x70,0x0E,0xF0,0x0F,0xE0,0x07},/*"X.BMP",0*/

  142. {0xE0,0x07,0xE0,0x0F,0xF0,0x0E,0x70,0x0E,0x70,0x1C,0x78,0x1C,0x38,0x3C,0x38,0x38,
  143. 0x3C,0x38,0x1C,0x70,0x1E,0x70,0x1E,0x70,0x0E,0xE0,0x0F,0xE0,0x0F,0xE0,0x07,0xC0,
  144. 0x07,0xC0,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,
  145. 0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80},/*"Y.BMP",0*/

  146. {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x0F,0x00,0x0E,0x00,0x1E,0x00,0x1C,0x00,0x3C,
  147. 0x00,0x38,0x00,0x78,0x00,0x70,0x00,0x70,0x00,0xE0,0x00,0xE0,0x01,0xE0,0x01,0xC0,
  148. 0x03,0xC0,0x03,0x80,0x07,0x80,0x07,0x00,0x0F,0x00,0x0E,0x00,0x1E,0x00,0x1C,0x00,
  149. 0x3C,0x00,0x38,0x00,0x78,0x00,0x70,0x00,0xF0,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},/*"Z.BMP",0*/

  150. {0x00,0xC0,0x00,0xC0,0x60,0xC0,0x61,0x80,0x37,0xFE,0x34,0x02,0x14,0x62,0x15,0x6A,
  151. 0x05,0x4A,0x05,0xD2,0x44,0x52,0xC4,0x42,0x65,0xFA,0x75,0xFA,0x24,0xD2,0x04,0xD2,
  152. 0x05,0xDA,0x05,0x5A,0x27,0x4A,0x34,0x62,0x24,0x06,0x24,0x62,0x20,0x60,0x2F,0xFF,
  153. 0x6F,0xFF,0x60,0x60,0x40,0xF0,0x40,0x90,0x41,0x98,0xC3,0x0E,0xDE,0x07,0x0C,0x03},/*"澳.BMP",0*/

  154. {0x04,0x60,0x04,0x60,0x04,0x60,0xFF,0xFF,0xFF,0xFF,0x04,0x64,0x04,0x66,0x00,0x12,
  155. 0x40,0x14,0x5F,0xFF,0x5F,0xFF,0x50,0x10,0x50,0x10,0x77,0xD0,0x77,0xD2,0x74,0x92,
  156. 0x14,0x92,0x14,0x92,0x17,0xD2,0xF7,0xDE,0xF4,0x5C,0x54,0x4C,0x57,0xCC,0x57,0xCC,
  157. 0x54,0x8C,0x54,0x8C,0xD4,0x9D,0x97,0xDD,0xB7,0xF7,0xB0,0x77,0x20,0x63,0x20,0x43},/*"藏.BMP",0*/

  158. {0x00,0x03,0x38,0x03,0x38,0x03,0x38,0xC3,0x38,0xC3,0x38,0xC3,0x38,0xC3,0x38,0xC3,
  159. 0x38,0xC3,0x38,0xC3,0x38,0xC3,0x38,0xC3,0x38,0xC3,0x38,0xC3,0x38,0xC3,0x38,0xC3,
  160. 0x38,0xC3,0x38,0xC3,0x38,0xC3,0x30,0xC3,0x30,0xC3,0x30,0xC3,0x30,0xC3,0x70,0xC3,
  161. 0x70,0xC3,0x70,0xC3,0x60,0xC3,0xE0,0xC3,0xE0,0xC3,0xE0,0xC3,0xC0,0x03,0xC0,0x03},/*"川.BMP",0*/

  162. {0xF7,0x80,0xF7,0xBF,0xF7,0xBF,0xD4,0xA3,0xD4,0xA2,0xD4,0xA2,0xF7,0xA2,0xF7,0xA2,
  163. 0xF7,0xA6,0x00,0x26,0x00,0x24,0xFF,0xAC,0xFF,0xB8,0x00,0x3C,0x00,0x26,0x00,0x22,
  164. 0xFF,0xE2,0xFF,0xE3,0x30,0x23,0x30,0x21,0x30,0x21,0x3F,0xA1,0x3F,0xA1,0x3F,0x21,
  165. 0x01,0x3F,0x01,0x2F,0x01,0x26,0x01,0x24,0x03,0x20,0x0F,0x20,0x0F,0x20,0x06,0x20},/*"鄂.BMP",0*/

  166. {0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
  167. 0xFF,0xFF,0xFF,0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
  168. 0x18,0x18,0x1F,0xF8,0x1F,0xF8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
  169. 0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0xF8,0x1F,0xF8,0x18,0x18,0x18,0x18,0x18,0x18},/*"甘.BMP",0*/

  170. {0x30,0x20,0x30,0x60,0x18,0x7E,0xFE,0x7E,0xFE,0xC4,0x4C,0xE4,0x4D,0xAC,0x6C,0x38,
  171. 0x28,0x18,0xFE,0x7F,0xFF,0xE7,0x01,0x81,0x00,0x7E,0xFC,0x7E,0xFC,0x10,0xC4,0x10,
  172. 0xC5,0xFF,0xFD,0xFF,0xC4,0x00,0xC4,0xFE,0xFC,0xFE,0xFC,0x82,0x10,0x82,0x10,0x92,
  173. 0xFE,0x92,0xFE,0xB2,0xFE,0x30,0x10,0x6C,0x10,0xEE,0x13,0xC7,0x11,0x83,0x11,0x00},/*"赣.BMP",0*/

  174. {0x01,0x18,0x41,0x18,0x61,0x18,0x61,0x18,0x31,0x18,0x27,0xFE,0x07,0xFE,0x01,0x18,
  175. 0x01,0x18,0x01,0x18,0x81,0x18,0xC1,0x18,0xEF,0xFF,0x6F,0xFF,0x21,0x18,0x01,0x08,
  176. 0x03,0x08,0x02,0x0C,0x07,0xFE,0x0F,0xFE,0x2F,0xFB,0x3B,0x0B,0x2B,0x08,0x23,0x08,
  177. 0x63,0xF8,0x63,0xF8,0x43,0x00,0x43,0x00,0x43,0x06,0xC3,0x06,0xC3,0xFE,0x81,0xFC},/*"港.BMP",0*/

  178. {0x01,0x80,0x01,0x80,0x01,0x80,0x3F,0xFC,0x3F,0xFC,0x21,0x84,0x21,0x84,0x21,0x84,
  179. 0x3F,0xFC,0x3F,0xFC,0x01,0x80,0x01,0x80,0x01,0x80,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
  180. 0x00,0x00,0x3F,0xFC,0x3F,0xFC,0x30,0x0C,0x30,0x0C,0x31,0x8C,0x31,0x8C,0x31,0x0C,
  181. 0x31,0x0C,0x33,0x40,0x03,0x70,0x06,0x78,0x0E,0x1C,0x3C,0x0E,0xF8,0x06,0x70,0x02},/*"贵.BMP",0*/

  182. {0x00,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x11,0xFE,0x11,0xFE,
  183. 0xFC,0x20,0xFC,0x20,0x30,0x20,0x30,0x20,0x30,0x20,0x33,0xFF,0x33,0xFF,0x3C,0x00,
  184. 0x7C,0x20,0x7C,0x20,0x56,0x20,0x54,0x20,0xD1,0xFE,0xD1,0xFE,0x90,0x20,0x90,0x20,
  185. 0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x17,0xFF,0x17,0xFF,0x10,0x00,0x10,0x00},/*"桂.BMP",0*/

  186. {0x7F,0xFE,0x7F,0xFE,0x61,0x86,0x61,0x86,0x69,0x96,0x6D,0xB6,0x6D,0xB6,0x6D,0xB6,
  187. 0x65,0xA6,0x61,0xA6,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x01,0x80,0x01,0x80,0x01,0x80,
  188. 0x7F,0xFE,0x7F,0xFE,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0xFF,0xFF,0xFF,0xFF,
  189. 0x00,0x00,0x40,0x02,0x64,0x46,0x46,0x66,0x46,0x66,0xC6,0x63,0xC6,0x23,0xC6,0x02},/*"黑.BMP",0*/

  190. {0x00,0x60,0x60,0x60,0x60,0x20,0x30,0x30,0x38,0x30,0x10,0x20,0x01,0xFF,0x01,0xFF,
  191. 0x01,0x03,0x81,0x03,0xC1,0x03,0xE1,0x03,0x71,0x03,0x31,0x03,0x21,0x03,0x01,0x03,
  192. 0x01,0xFF,0x01,0xFF,0x11,0x03,0x19,0x00,0x19,0x00,0x13,0x00,0x33,0x00,0x33,0x00,
  193. 0x23,0x00,0x22,0x00,0x62,0x00,0x66,0x00,0x46,0x00,0xC4,0x00,0x4C,0x00,0x0C,0x00},/*"沪.BMP",0*/

  194. {0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0xFF,0xFF,0xFF,0xFF,
  195. 0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,
  196. 0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFC,0x3F,0xFC,0x3F,0xFC,0x30,0x0C,0x30,0x0C,
  197. 0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x3F,0xFC,0x3F,0xFC,0x3F,0xFC,0x30,0x0C},/*"吉.BMP",0*/

  198. {0x02,0x40,0x02,0x4C,0xFE,0x7E,0xFE,0x70,0x02,0x40,0x06,0x43,0xFE,0x7F,0xF2,0x7E,
  199. 0x82,0x00,0x3F,0xFC,0x3F,0xFC,0x21,0x84,0x21,0x84,0x3F,0xFC,0x3F,0xFC,0x21,0x84,
  200. 0x3F,0xFC,0x3F,0xFC,0x04,0x20,0x04,0x20,0x3F,0xFC,0x3F,0xFC,0x04,0x20,0x04,0x20,
  201. 0xFF,0xFF,0xFF,0xFF,0x04,0x20,0x06,0x30,0x1C,0x3C,0x38,0x1E,0x70,0x06,0x40,0x02},/*"冀.BMP",0*/

  202. {0x00,0x60,0x00,0x60,0x00,0x60,0x60,0x60,0x67,0xFE,0x37,0xFE,0x30,0x66,0x10,0x66,
  203. 0x00,0x66,0x0F,0xFF,0x0F,0xFF,0xC0,0x66,0xE0,0x66,0x60,0x66,0x20,0x66,0x27,0xFE,
  204. 0x07,0xFE,0x00,0x60,0x00,0x60,0x30,0x60,0x37,0xFE,0x27,0xFE,0x20,0x60,0x60,0x60,
  205. 0x60,0x60,0x4F,0xFF,0x4F,0xFF,0xC0,0x60,0xC0,0x60,0xC0,0x60,0x00,0x60,0x00,0x60},/*"津.BMP",0*/

  206. {0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x06,0x40,0x06,0x48,0x36,0x4C,0x36,0x4C,0x16,0x48,
  207. 0x16,0x58,0x1E,0x58,0x16,0x50,0x06,0x50,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
  208. 0x00,0x00,0x1F,0xF8,0x1F,0xF8,0x1F,0xF8,0x10,0x08,0x10,0x08,0x10,0x08,0x1F,0xF8,
  209. 0x1F,0xF8,0x1F,0xF8,0x10,0x08,0x10,0x08,0x10,0x08,0x1F,0xF8,0x1F,0xF8,0x10,0x08},/*"晋.BMP",0*/

  210. {0x03,0x00,0x03,0x00,0x01,0x80,0x01,0x80,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
  211. 0x00,0x00,0x00,0x00,0x1F,0xF8,0x1F,0xF8,0x10,0x08,0x10,0x08,0x10,0x08,0x10,0x08,
  212. 0x10,0x08,0x1F,0xF8,0x1F,0xF8,0x1F,0xF8,0x00,0x80,0x08,0x90,0x08,0x90,0x18,0xB8,
  213. 0x18,0x98,0x30,0x8C,0x30,0x8E,0x60,0x86,0xE1,0x86,0x41,0x82,0x47,0x80,0x03,0x00},/*"京.BMP",0*/

  214. {0x12,0x10,0x12,0x30,0xFF,0xA0,0xFF,0xBF,0x12,0x7F,0x32,0x44,0x3F,0xE4,0x7F,0xA4,
  215. 0x60,0xA4,0xC0,0x9C,0xFC,0x9C,0xC5,0x98,0x47,0x9F,0x7D,0x77,0x7F,0x63,0x01,0xC0,
  216. 0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x1F,0xF8,0x1F,0xF8,0x00,0x00,0x00,0x00,0x1F,0xF8,
  217. 0x1F,0xF8,0x00,0x00,0x3F,0xFC,0x1F,0xFC,0x10,0x0C,0x10,0x0C,0x1F,0xFC,0x30,0x0C},/*"警.BMP",0*/

  218. {0x60,0x00,0x63,0xFE,0x23,0xFE,0x33,0xFE,0x30,0x06,0x30,0x0C,0x20,0x1C,0x00,0x18,
  219. 0x00,0x30,0x00,0x30,0x00,0x30,0xF0,0x30,0xF0,0x30,0xF0,0x30,0x30,0x30,0x30,0x30,
  220. 0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0xE0,
  221. 0x30,0xE0,0x30,0xE0,0x30,0x00,0x78,0x00,0xCE,0x00,0xC7,0xFF,0xC3,0xFF,0x00,0xFF},/*"辽.BMP",0*/

  222. {0x06,0x00,0x0F,0xF0,0x0F,0xF0,0x18,0x20,0x10,0x60,0x30,0x40,0x7F,0xFC,0xFF,0xFC,
  223. 0xF1,0x8C,0xB1,0x8C,0x3F,0xFC,0x3F,0xFC,0x31,0x8C,0x31,0x8C,0x3F,0xFC,0x00,0x00,
  224. 0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x3F,0xFC,0x3F,0xFC,0x30,0x0C,
  225. 0x30,0x0C,0x3F,0xFC,0x3F,0xFC,0x30,0x0C,0x30,0x0C,0x3F,0xFC,0x3F,0xFC,0x30,0x0C},/*"鲁.BMP",0*/

  226. {0x0C,0x60,0x0C,0x60,0x0C,0x60,0xFF,0xFF,0xFF,0xFF,0x0C,0x60,0x0C,0x60,0x00,0x00,
  227. 0xFF,0xFF,0xFF,0xFF,0xC0,0x03,0xDF,0xFB,0xDF,0xFB,0x00,0x00,0x00,0x00,0x7F,0xFE,
  228. 0x7F,0xFE,0x41,0x82,0x07,0x00,0x0F,0x8C,0x3D,0x9C,0x73,0xF8,0x66,0xF0,0x0E,0xD0,
  229. 0x1C,0xD8,0x79,0xC8,0x73,0x4C,0x67,0x4E,0x0E,0x47,0x3C,0x43,0xF9,0xC2,0x61,0xC0},/*"蒙.BMP",0*/

  230. {0x60,0x00,0x67,0xFF,0x67,0xFF,0x20,0x01,0x20,0x01,0x01,0x81,0xC1,0x81,0x81,0x81,
  231. 0x81,0x81,0x9F,0xF9,0x8F,0xF9,0x89,0x99,0x89,0x99,0x89,0x99,0x89,0x99,0x89,0x99,
  232. 0x8F,0xF9,0x8F,0xF9,0x89,0x81,0x89,0x91,0x99,0x91,0x81,0x99,0x81,0x99,0x83,0xF9,
  233. 0x9F,0xFD,0x9E,0x09,0x90,0x01,0x80,0x01,0x80,0x01,0x80,0x03,0x80,0x0F,0x00,0x06},/*"闽.BMP",0*/

  234. {0x03,0x00,0x03,0x80,0x01,0x80,0x01,0x80,0x01,0x00,0xFF,0xFF,0xFF,0xFF,0xC0,0x03,
  235. 0xC0,0x03,0xC0,0x03,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
  236. 0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,
  237. 0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x07,0x80,0x07,0x80,0x03,0x00},/*"宁.BMP",0*/

  238. {0x01,0x80,0x01,0x80,0x01,0x80,0x7F,0xFE,0x7F,0xFE,0x01,0x80,0x01,0x80,0x3F,0xFC,
  239. 0x3F,0xFC,0x01,0x80,0x01,0x80,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x1F,0xFC,
  240. 0x1F,0xFC,0x1F,0xFC,0x10,0x0C,0x10,0x0C,0x1F,0xFC,0x1F,0xFC,0x1F,0xFC,0x10,0x0C,
  241. 0x10,0x0C,0x1F,0xFC,0x1F,0xFC,0x10,0x0C,0x10,0x0C,0x10,0x1C,0x10,0x1C,0x10,0x18},/*"青.BMP",0*/

  242. {0x00,0x60,0x00,0x60,0x00,0x30,0x00,0x30,0xFC,0x30,0xFF,0xFF,0xFF,0xFF,0x20,0x00,
  243. 0x20,0x00,0x20,0x00,0x21,0xFE,0x21,0xFE,0x21,0x06,0xF9,0x06,0xF9,0x06,0x21,0x06,
  244. 0x21,0x06,0x21,0xFE,0x21,0xFE,0x20,0x30,0x20,0x30,0x24,0x30,0x3D,0x30,0x39,0x36,
  245. 0xF3,0x36,0xC3,0x32,0x82,0x33,0x06,0x33,0x06,0x31,0x04,0xE1,0x00,0x60,0x00,0x40},/*"琼.BMP",0*/

  246. {0x00,0x20,0xF8,0x20,0xF8,0x20,0x98,0x20,0x9B,0xFE,0x9B,0xFE,0x90,0x20,0x90,0x20,
  247. 0xB1,0x20,0xB3,0x22,0xF3,0x26,0xA1,0x26,0xB1,0x24,0xB1,0xAC,0x99,0x24,0x98,0x20,
  248. 0x9F,0xFF,0x8F,0xFF,0x88,0x60,0x88,0x60,0x88,0x60,0xB8,0x60,0xB8,0x70,0xB0,0xF0,
  249. 0x80,0xD0,0x81,0x98,0x81,0x98,0x83,0x0C,0x87,0x0E,0x8E,0x07,0x9C,0x07,0x88,0x02},/*"陕.BMP",0*/

  250. {0x0C,0x30,0x0C,0x30,0x08,0x30,0x08,0x30,0xFF,0xFF,0xFF,0xFF,0x08,0x30,0x08,0x30,
  251. 0x08,0x30,0x09,0x30,0x01,0x00,0x01,0x00,0x01,0x00,0x7F,0xF8,0x7F,0xF8,0x7F,0xF0,
  252. 0x03,0x10,0x03,0x10,0x13,0x14,0x32,0x16,0x32,0x16,0x22,0x12,0x66,0x13,0x66,0x13,
  253. 0xC4,0x10,0x4C,0x10,0x0C,0x10,0x18,0x10,0x18,0x30,0x30,0xF0,0x70,0x70,0x20,0x60},/*"苏.BMP",0*/

  254. {0x02,0x00,0x03,0x00,0x07,0x00,0x06,0x00,0x06,0x10,0x0C,0x30,0x0C,0x38,0x18,0x18,
  255. 0x18,0x0C,0x30,0x0C,0x30,0x06,0x60,0xFE,0xFF,0xFF,0xFF,0xFB,0x78,0x03,0x00,0x01,
  256. 0x00,0x00,0x00,0x00,0x3F,0xFE,0x3F,0xFE,0x3F,0xFE,0x20,0x06,0x20,0x04,0x20,0x04,
  257. 0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x3F,0xFC,0x3F,0xFC,0x3F,0xFE,0x20,0x06},/*"台.BMP",0*/

  258. {0x20,0x60,0x30,0x20,0x20,0x20,0x20,0x40,0x23,0xFE,0xFB,0xFE,0xFA,0x02,0xFA,0x02,
  259. 0x8A,0x02,0x8A,0x02,0x88,0x00,0x89,0xFC,0x89,0xFC,0x88,0x00,0x88,0x00,0xF8,0x00,
  260. 0xFB,0xFF,0x8B,0xFF,0x8B,0xFF,0x88,0x90,0x88,0x90,0x88,0x90,0x88,0x90,0x88,0x90,
  261. 0xF8,0x90,0xF8,0x90,0x88,0x91,0x89,0x91,0x81,0x19,0x83,0x1F,0x87,0x1F,0x06,0x0E},/*"皖.BMP",0*/

  262. {0x42,0x00,0x42,0x3F,0x62,0x3F,0x62,0x3F,0x22,0x23,0x22,0x23,0x02,0x23,0x02,0x23,
  263. 0x0F,0xA3,0x8F,0xA3,0x82,0x3F,0xC2,0x3F,0xE6,0x3F,0x66,0x23,0x26,0x23,0x07,0xA3,
  264. 0x07,0xA3,0x06,0xA3,0x4E,0xA3,0x6E,0xBF,0x6A,0x3F,0x4A,0x23,0x4A,0x23,0x5A,0x23,
  265. 0x5A,0x23,0x52,0x23,0x42,0x23,0xC2,0x3F,0xC2,0x3F,0xC2,0x3F,0xC2,0x23,0x82,0x23},/*"湘.BMP",0*/

  266. {0x08,0x03,0x08,0x1F,0x08,0x3F,0xFF,0x30,0xFF,0x20,0xFF,0x20,0x00,0x20,0x22,0x20,
  267. 0x22,0x20,0x26,0x20,0x24,0x20,0x44,0x3F,0xFF,0xBF,0xFF,0xA6,0x08,0x26,0x08,0x26,
  268. 0x08,0x26,0x08,0x26,0xFF,0xA6,0xFF,0xA6,0x88,0xA6,0x08,0x66,0x2A,0x66,0x6A,0x66,
  269. 0x6B,0x66,0x4B,0x46,0xC9,0x46,0xC8,0x46,0x88,0xC6,0x38,0xC6,0x38,0xC6,0x18,0x86},/*"新.BMP",0*/

  270. {0x01,0x0C,0x23,0x0C,0x73,0x08,0x31,0x98,0x39,0x98,0x11,0x10,0x10,0x10,0x00,0x30,
  271. 0xFF,0xFE,0xFF,0xFE,0xC0,0x02,0xC0,0x02,0xC0,0x02,0xC0,0x03,0x1F,0xF8,0x1F,0xF8,
  272. 0x00,0x38,0x00,0x70,0x00,0xE0,0x00,0xC0,0x00,0x80,0xFF,0xFF,0xFF,0xFF,0x00,0x80,
  273. 0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x01,0x80,0x07,0x80,0x07,0x80,0x03,0x00},/*"学.BMP",0*/

  274. {0x00,0x40,0x40,0xE0,0x60,0xA0,0x30,0xB0,0x31,0xB0,0x11,0x18,0x11,0x18,0x03,0x0C,
  275. 0x03,0xF6,0x07,0xF7,0x8C,0x03,0xCC,0x00,0xF8,0x00,0x6F,0xC2,0x37,0xD2,0x04,0xD2,
  276. 0x04,0xD2,0x04,0xD2,0x07,0xD2,0x27,0xD2,0x34,0xD2,0x34,0xD2,0x24,0xD2,0x27,0xD2,
  277. 0x27,0xD2,0x64,0xD2,0x64,0xC2,0x44,0xC2,0x44,0xC2,0xC5,0xCE,0xC4,0xCE,0x44,0x8C},/*"渝.BMP",0*/

  278. {0x00,0x40,0xFC,0xFC,0xFC,0xFC,0x0C,0x8C,0x0D,0x88,0x09,0x88,0x7B,0xFF,0x73,0xFF,
  279. 0x32,0x93,0x30,0x93,0x10,0x93,0x20,0xFF,0xFE,0xFF,0xFC,0x20,0x34,0x60,0x34,0x62,
  280. 0x34,0xE6,0x3D,0xB6,0x33,0x3C,0x31,0x7C,0x30,0x54,0x30,0xD4,0x31,0xB6,0x33,0x3A,
  281. 0x32,0x7A,0x30,0x5B,0x30,0xDB,0x31,0x99,0x37,0x11,0xF2,0x70,0x62,0x30,0x40,0x20},/*"豫.BMP",0*/

  282. {0x02,0x00,0x06,0x00,0x7F,0xFC,0x7F,0xFC,0x60,0x0C,0x65,0x8C,0x65,0xAC,0x65,0xAC,
  283. 0x61,0x8C,0x67,0xEC,0x67,0xEC,0x63,0x8C,0x67,0xAC,0x65,0xAC,0x65,0xAC,0x61,0x8C,
  284. 0x60,0x0C,0x7F,0xFC,0x7F,0xFC,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x0C,0x00,
  285. 0x0C,0x00,0x1F,0xFC,0x1F,0xFC,0x00,0x1C,0x00,0x18,0x00,0x78,0x01,0xF0,0x01,0xC0},/*"粤.BMP",0*/

  286. {0x3F,0xFC,0x3F,0xFC,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  287. 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x02,0x00,0x03,0x00,
  288. 0x03,0x00,0x02,0x00,0x06,0x00,0x06,0x00,0x04,0x20,0x0C,0x30,0x0C,0x30,0x08,0x18,
  289. 0x18,0x18,0x18,0x18,0x10,0x0C,0x30,0x1C,0x37,0xFC,0x3F,0xFE,0x3F,0x06,0x30,0x06},/*"云.BMP",0*/

  290. {0x02,0x02,0x42,0x3F,0xE2,0x3F,0x62,0x30,0x32,0x20,0x32,0x20,0x02,0x20,0x0A,0x20,
  291. 0x0F,0xA0,0x0F,0xA0,0x82,0x3F,0xC2,0x3F,0xE2,0x26,0x72,0x26,0x22,0xA6,0x23,0xA6,
  292. 0x03,0xA6,0x0F,0x26,0x0E,0x26,0x0A,0x26,0x32,0x26,0x32,0x26,0x22,0x26,0x22,0x26,
  293. 0x62,0x66,0x62,0x66,0x62,0x66,0x42,0x46,0x42,0x46,0xCE,0xC6,0xC6,0xC6,0x40,0x06},/*"浙.BMP",0*/
  294. };

  295. //文字表,共70个,数字英文占34个,编号0~33,汉字编号34~69
  296. char *table[]={"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",\
  297.                "A", "B", "C", "D", "E", "F", "G", "H", "J", "K",\
  298.                "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V",\
  299.                "W", "X", "Y", "Z","澳","藏","川","鄂","甘","赣",\
  300.                "港","贵","桂","黑","沪","吉","冀","津","晋","京",\
  301.                "警","辽","鲁","蒙","闽","宁","青","琼","陕","苏",\
  302.                "台","皖","湘","新","学","渝","豫","粤","云","浙"};

  303. //BMP图像结构
  304. struct BMP_img
  305. {
  306.     //{BMP头
  307.     BYTE  bfType[2];//类型,判断是否为‘B’,‘M’
  308.     DWORD size;//文件尺寸
  309.     DWORD reser;//保留,为0
  310.     DWORD header_length;//头部长度,也就是数据起始位置
  311.     //}BMP头长度,14字节

  312.     //{信息头40字节
  313.     DWORD infoheader_length;//信息头长度,40
  314.     DWORD width;//图像宽度
  315.     DWORD height;//图像高度
  316.     WORD  biplanes;//颜色平面数,为1
  317.     WORD  bmp_type;/* 8bit 24bit; */
  318.     DWORD compres;//0表示不压缩
  319.     DWORD datasize;//数据长度,size-54
  320.     DWORD bixpm;//水平分辩率
  321.     DWORD biypm;//垂直分辩率
  322.     DWORD clrused;//为0所有颜色,其它的为索引数
  323.     DWORD relclrused;//0表示都重要
  324.     //}信息头结束

  325.     //其它信息
  326.     BYTE *image;//指向一块内存,保存BMP的内容
  327.     DWORD lineBytes;//一行占多少字节
  328. };

  329. //从源BMP图中,剪切车牌所在区域的新结构
  330. struct Bmp1{
  331.     DWORD width;
  332.     DWORD height;
  333.     BYTE *image;
  334.     int left[10];//保存车牌中7个字的左右列
  335.     int right[10];
  336.     int top[10];//保存车牌上下位置
  337.     int bottom[10];
  338.     int up;
  339.     int down;
  340.     byte strr[7][2500];
  341.     byte string[7];//反回已找到的车牌下标
  342.     float ang;//倾斜角度
  343. };

  344. //蓝色车牌
  345. struct HSV{
  346.   float H;//H值范围:190 ~ 245
  347.   float S;//S值范围: 0.35 ~ 1,我理解为黑白灰度
  348.   int V;//V值范围: 0.3 ~ 1
  349. };

  350. //读图片文件到内存中
  351. int read_img(char const *fn, struct BMP_img *img)
  352. {
  353.     FILE *infile;
  354.     if((infile=fopen(fn,"rb"))==NULL)return 0;

  355.     fread(&img->bfType,2,1,infile);//BM
  356.     if(!(img->bfType[0]=='B' && img->bfType[1]=='M'))return 0;
  357.     fread(&img->size,sizeof(DWORD),1,infile);
  358.     printf("\nBMP size             :%d",(int)img->size);
  359.     fread(&img->reser,sizeof(DWORD),1,infile);
  360.     printf("\n保留位:");
  361.     fread(&img->header_length,sizeof(DWORD),1,infile);
  362.     printf("\nheader length    :%d",(int)img->header_length);
  363.     fread(&img->infoheader_length,sizeof(DWORD),1,infile);
  364.     fread(&img->width, sizeof(DWORD), 1, infile);
  365.     fread(&img->height, sizeof(DWORD), 1, infile);
  366.     printf( "\nwidth   :%d\n  height  :%d ", (int)img->width, (int)img->height);
  367.     fread(&img->biplanes, sizeof(WORD), 1, infile);
  368.     fread(&img->bmp_type, sizeof(WORD), 1, infile);
  369.     printf("\nBMP Tpye             :%d ", img->bmp_type);
  370.     fread(&img->compres, sizeof(DWORD), 1, infile);
  371.     if(img->compres==0) {printf("\nbmp图片为非压缩!");}printf(" ");
  372.     fread(&img->datasize, sizeof(DWORD), 1, infile);
  373.     printf("\nBMP Data Size        :%d ",(int)img->datasize);
  374.     fread(&img->bixpm, sizeof(DWORD), 1, infile);
  375.     fread(&img->biypm, sizeof(DWORD), 1, infile);
  376.     fread(&img->clrused, sizeof(DWORD), 1, infile);
  377.     printf("\n实际使用颜色数=%d ",(int)img->clrused);printf(" ");
  378.     fread(&img->relclrused, sizeof(DWORD), 1, infile);

  379.     //计算一行需要多少字节,对齐到4字节
  380.     img->lineBytes=(img->width*img->bmp_type+31)/32*4;//printf("\nLineBytes            :%l\n",img->lineBytes);
  381.     if(img->bmp_type==24)//24位色
  382.     {
  383.         img->image=(unsigned char *)malloc(img->lineBytes*img->height);//分配一块内存,用于保存图像数据
  384.         if(img->image==NULL) fprintf(stderr, "\n Allocation error for temp in read_bmp() \n");
  385.         fseek(infile, img->header_length, SEEK_SET);//跳过头部,也就是跳到图像位置
  386.         if(img->datasize==img->width*3)
  387.             fread(img->image, sizeof(unsigned char), (img->lineBytes)*img->height, infile);//全部读到内存中
  388.         else
  389.         {
  390.             for(int i=0;i<img->height;i++)
  391.             {
  392.                 fread(&img->image[i*img->width*3], sizeof(unsigned char), img->lineBytes, infile);//全部读到内存中
  393.             }
  394.         }
  395.     }
  396.     fclose(infile);
  397.     return 1;
  398. }

  399. //把二值图保存为24位黑白图
  400. void WriteBmp1(char const *fn,byte *bmp,int width,int height)
  401. {
  402.     int w4;
  403.     struct BMP_img img;
  404.     //一行有多少个字节
  405.     img.lineBytes=((width*3+3)>>2)<<2;//对齐到4字节边界
  406.     w4=img.lineBytes*height;//图像尺寸
  407.     img.bfType[0]='B';img.bfType[1]='M';
  408.     img.size=w4+54;
  409.     img.reser=0;
  410.     img.header_length=54;
  411.     img.infoheader_length=40;
  412.     img.width=width;
  413.     img.height=height;
  414.     img.biplanes=1;
  415.     img.bmp_type=24;
  416.     img.compres=0;
  417.     img.datasize=w4;
  418.     img.bixpm=0;
  419.     img.biypm=0;
  420.     img.clrused=0;
  421.     img.relclrused=0;
  422.    
  423.     FILE *infile;
  424.     if((infile=fopen(fn,"wb"))==NULL)
  425.     {
  426.         return;
  427.     }
  428.     fwrite(&img.bfType,2,1,infile);//printf("\n打开的图为 %d",img->bfType);//B M
  429.     fwrite(&img.size,sizeof(DWORD),1,infile);     //        printf("\nBMP size             :%l",img->size);
  430.     fwrite(&img.reser,sizeof(DWORD),1,infile);//printf("\n保留位:");
  431.     fwrite(&img.header_length,sizeof(DWORD),1,infile); //printf("\nheader length    :%l",img->header_length);
  432.     fwrite(&img.infoheader_length,sizeof(DWORD),1,infile);
  433.     fwrite(&img.width, sizeof(DWORD), 1, infile);
  434.     fwrite(&img.height, sizeof(DWORD), 1, infile);     //printf( "\nwidth   :%l\n  height  :%l ", img->width, img->height);
  435.     fwrite(&img.biplanes, sizeof(WORD), 1, infile);
  436.     fwrite(&img.bmp_type, sizeof(WORD), 1, infile);  // printf("\nBMP Tpye             :%l ", img->bmp_type);
  437.     fwrite(&img.compres, sizeof(DWORD), 1, infile);    //if(img->compres==0) {printf("\nbmp图片为非压缩!");}printf(" ");
  438.     fwrite(&img.datasize, sizeof(DWORD), 1, infile);//printf("\nBMP Data Size        :%l ",img->datasize);
  439.     fwrite(&img.bixpm, sizeof(DWORD), 1, infile);
  440.     fwrite(&img.biypm, sizeof(DWORD), 1, infile);
  441.     fwrite(&img.clrused, sizeof(DWORD), 1, infile);    //printf("\n实际使用颜色数=%d ",img->clrused);printf(" ");
  442.     fwrite(&img.relclrused, sizeof(DWORD), 1, infile);
  443.    
  444.     byte *wbmp=(byte*)malloc(w4);//后面多加两个字节,用于4字节对齐
  445.     for(int i=0,s,w;i<height;i++)
  446.     {
  447.         s=i*width;
  448.         w=i*img.lineBytes;
  449.         for(int j=0;j<width;j++)
  450.         {
  451.             if(bmp[s+j]){
  452.                 wbmp[w+j*3]=wbmp[w+j*3+1]=wbmp[w+j*3+2]=bmp[s+j];
  453.             }
  454.             else wbmp[w+j*3]=wbmp[w+j*3+1]=wbmp[w+j*3+2]=0;               
  455.         }
  456.     }
  457.     fwrite(wbmp,img.datasize,1,infile);
  458.     free(wbmp);
  459.     fclose(infile);
  460. }

  461. //水平投影,从中间往两边计算,从而去掉最上面与最下面的多余部分
  462. void shuipingtouying(struct Bmp1 *img,byte *dst)//得到车牌的上下边缘
  463. {
  464.     byte temp;
  465.     int i,j,m,n;
  466.     int *p=(int*)malloc(img->height*sizeof(int));//申请以行为单位的整型内存数

  467.     for(i=0;i<img->width;i++)//宽度循环
  468.     {
  469.         if((dst[i]==255)||(dst[img->width+i]==255))//如果第一行 或 第二行有白点
  470.         for(j=0;j<img->height;j++)//消除此白点,直到碰到黑点退出
  471.         {
  472.             if(dst[j*img->width+i]==255)
  473.                 dst[j*img->width+i]=0;
  474.             else break;
  475.         }
  476.     }
  477.     for(i=0;i<img->width;i++)
  478.     {
  479.         //倒数1,2行中有白点,则消除,否则退出
  480.         if((dst[img->width*(img->height-1)+i]==255)||(dst[img->width*(img->height-2)+i]==255))
  481.             for(j=img->height-1;j>0;j--)
  482.             {
  483.                 if(dst[j*img->width+i]==255)
  484.                     dst[j*img->width+i]=0;
  485.                 else break;
  486.             }
  487.     }

  488.     //记录每一行的白点数
  489.     for(i=0;i<img->height;i++)
  490.     {
  491.         p[i]=0;
  492.         for(j=0;j<img->width;j++)
  493.         {
  494.             if(dst[i*img->width+j]==255)
  495.                 p[i]++;
  496.         }
  497.     }

  498.     //找到白点数最多的行
  499.     temp=0;
  500.     for(i=0;i<img->height;i++)
  501.     {
  502.         if(p[i]>temp)
  503.         {
  504.           temp=p[i];
  505.         }
  506.     }

  507.     n=temp/5;//以20%做为阀值
  508.     img->up=0;
  509.     img->down=img->height;
  510.     m=img->height/2;
  511.     for(i=m-1;i>0;i--)//从中间往上下遍历,如果有一行的白点数小于20%,则做为起点与终点
  512.     {
  513.         if(p[i]<n)
  514.         {
  515.             img->up=i+1;//只有第一次,才赋值
  516.             break;
  517.         }
  518.     }
  519.     for(i=m+1;i<img->height;i++)//从下面往中间遍历
  520.     {
  521.         if(p[i]<n)
  522.         {
  523.             img->down=i-1;
  524.             break;
  525.         }
  526.     }
  527.     free(p);

  528.     //删除起始行之前的白点
  529.     for(i=0;i<img->up;i++)
  530.     {
  531.         for(j=0;j<img->width;j++)
  532.         {
  533.             dst[i*img->width+j]=0;
  534.         }
  535.     }
  536.    
  537.     //删除结束行之后的白点
  538.     for(i=img->down+1;i<img->height;i++)
  539.     {
  540.         for(j=0;j<img->width;j++)
  541.         {
  542.             dst[i*img->width+j]=0;
  543.         }
  544.     }
  545. }

  546. //垂直投影法
  547. void cuizhitouying(struct Bmp1 *img,byte *temp)
  548. {
  549.     DWORD i,j;
  550.     int num,flag;

  551.     int up;
  552.     int down;
  553.     int bd;//当前列白点数

  554.     //计算1个字符的宽度,也就是1块车牌的宽度,把所有字挨紧,空白区域占30%左右
  555.     //然后一块车牌有7个字,所以一个字的宽度大根是width*0.7/7
  556.     num=flag=0;
  557.     up=img->height;//最高一个白点
  558.     down=0;//最低一个白点
  559.     for(i=0;i<img->width;i++)//按宽遍历
  560.     {
  561.         bd=0;
  562.         for(j=0;j<img->height;j++)//按高遍历,也就是1列1列的遍历
  563.         {
  564.             if(temp[j*img->width+i]==255)//记录每列白点数
  565.             {
  566.                 bd++;
  567.                 if(up>j)up=j;//最高白点
  568.                 if(down<j)down=j;//记住最后一个白点的位置
  569.             }
  570.         }

  571.         if(bd)//当前列有白点
  572.         {
  573.             if(flag==0)//还没有记录起点
  574.             {
  575.                 flag=1;
  576.                 img->left[num]=i;//记录下起点
  577.             }
  578.         }
  579.         else//当前列没白点
  580.         {
  581.             if(flag)//如果已记录了起点
  582.             {
  583.                 if((down-up)+1>img->height/2)//找到正确的字符
  584.                 {
  585.                     img->right[num]=i-1;//记录结束区域
  586.                     img->top[num]=up;
  587.                     img->bottom[num]=down;
  588.                     num++;//查找下一个字符
  589.                 }
  590.                 flag=0;//记录下一个记点
  591.                 up=img->height;
  592.                 down=0;
  593.             }
  594.         }
  595.     }
  596.     //如果最后一个没有结束
  597.     if(flag){
  598.         img->right[num]=img->width-1;
  599.         img->top[num]=up;
  600.         img->bottom[num]=down;
  601.         num++;
  602.     }
  603.         
  604.     if(num<7)//位数不够
  605.     {
  606.         printf("car no min error\n");
  607.     }
  608.     else if(num>7)//如果找到多于7个字符,说明里面有一个“川”字
  609.     {
  610.         printf("car no error\n");
  611.     }
  612. }

  613. //复制单个字符,存进数组中
  614. void strBmp(struct Bmp1 *img,byte *temp)
  615. {
  616.     int i,j,k,n;
  617.     //int w,h;
  618.     for(i=0;i<7;i++)
  619.     {
  620.         n=0;
  621.         for(j=img->top[i];j<=img->bottom[i];j++)//高度循环
  622.         {
  623.             for(k=img->left[i];k<=img->right[i];k++)//宽度循环
  624.             {
  625.                 img->strr[i][n++]=temp[j*img->width+k];
  626.             }
  627.         }
  628.         if(i==0)WriteBmp1("z1.bmp",img->strr[i],img->right[i]-img->left[i]+1,img->bottom[i]-img->top[i]+1);
  629.         if(i==1)WriteBmp1("z2.bmp",img->strr[i],img->right[i]-img->left[i]+1,img->bottom[i]-img->top[i]+1);
  630.         if(i==2)WriteBmp1("z3.bmp",img->strr[i],img->right[i]-img->left[i]+1,img->bottom[i]-img->top[i]+1);
  631.         if(i==3)WriteBmp1("z4.bmp",img->strr[i],img->right[i]-img->left[i]+1,img->bottom[i]-img->top[i]+1);
  632.         if(i==4)WriteBmp1("z5.bmp",img->strr[i],img->right[i]-img->left[i]+1,img->bottom[i]-img->top[i]+1);
  633.         if(i==5)WriteBmp1("z6.bmp",img->strr[i],img->right[i]-img->left[i]+1,img->bottom[i]-img->top[i]+1);
  634.         if(i==6)WriteBmp1("z7.bmp",img->strr[i],img->right[i]-img->left[i]+1,img->bottom[i]-img->top[i]+1);
  635.     }
  636. }

  637. //缩放到指定的宽度与高度
  638. void changeGray(byte *srcBmp,byte *dstBmp,int width,int height,int nWidth,int nHeight)
  639. {
  640.     int i=0,j=0,i0,j0;
  641.     float xx;float yy;
  642.     xx=(float)nWidth/width;//宽度缩放比
  643.     yy=(float)nHeight/height;

  644.     memset(dstBmp,0x00,nHeight*nWidth*sizeof(byte));
  645.     if(width<nWidth/2)//说明为1
  646.     {
  647.         for(i=0;i<nHeight;i++)
  648.         {
  649.             for(j=0;j<width;j++)
  650.             {
  651.                 if(i<=height)
  652.                 {
  653.                     dstBmp[i*nWidth+j]=srcBmp[i*width+j];
  654.                 }
  655.                 else{
  656.                     dstBmp[i*nWidth+j]=srcBmp[(height-1)*width+j];
  657.                 }
  658.             }
  659.         }
  660.     }
  661.     else
  662.     {
  663.         for(i = 0; i <nHeight; i++)
  664.         {
  665.             for(j = 0; j <nWidth; j++)
  666.             {
  667.                 //i0 = (int) ((float)i/yy+0.5);
  668.                 //j0 = (int) ((float)j/xx+0.5);
  669.                 i0 = (int) ((float)i/yy);
  670.                 j0 = (int) ((float)j/xx);
  671.                 if((j0>=0)&&(j0<width)&&(i0>=0)&&(i0<height))
  672.                 // {
  673.                     dstBmp[i*nWidth+j]=srcBmp[i0*width+j0];
  674.                  //}
  675.                  //else
  676.                  //{
  677.                 //    dstBmp[i*nWidth+j]=255;
  678.                  //}
  679.             }
  680.         }
  681.     }
  682. }

  683. void guiyi(struct Bmp1 *img)
  684. {
  685.     int xxx;
  686.     int i;
  687.     int yyy;

  688.     byte *temp=(byte *)malloc(sizeof(byte)*512);
  689.     for(i=0;i<7;i++)
  690.     {
  691.         xxx=img->right[i]-img->left[i]+1;
  692.         yyy=img->bottom[i]-img->top[i]+1;

  693.         changeGray(img->strr[i],temp,xxx,yyy,16,32);

  694.         memcpy(img->strr[i],temp,sizeof(byte)*512);
  695.         if(i==0)WriteBmp1("zz1.bmp",img->strr[i],16,32);
  696.         if(i==1)WriteBmp1("zz2.bmp",img->strr[i],16,32);
  697.         if(i==2)WriteBmp1("zz3.bmp",img->strr[i],16,32);
  698.         if(i==3)WriteBmp1("zz4.bmp",img->strr[i],16,32);
  699.         if(i==4)WriteBmp1("zz5.bmp",img->strr[i],16,32);
  700.         if(i==5)WriteBmp1("zz6.bmp",img->strr[i],16,32);
  701.         if(i==6)WriteBmp1("zz7.bmp",img->strr[i],16,32);
  702.     }
  703. }

  704. //比较单个字符,我这里用了与原作者不同的方法,原方法简单字符复杂字比只会白点越少
  705. //就是在比较的时候,如果两点都为白色,则为黑色
  706. //如果两点不相同,则为白色,这样只有最相似的字白点才会最少
  707. int cmpstr(byte *src,byte const *moban)
  708. {
  709.     int i,j;
  710.     int k;
  711.     int w=16,h=32;
  712.    
  713.     byte temp[512]={0};
  714.     memcpy(temp,src,512);
  715.     byte temp1[512];
  716.     for(i=0;i<h;i++)
  717.     {
  718.         for(j=0;j<w;j++)//0~16
  719.         {
  720.             k=1<<(7-(j%8));//j%8=0~7
  721.             if((moban[(h-i-1)*2+j/8] & k) == k)
  722.                 temp1[i*w+j]=255;
  723.             else temp1[i*w+j]=0;
  724.         }
  725.     }

  726.     WriteBmp1("c1.bmp",temp,w,h);
  727.     WriteBmp1("c2.bmp",temp1,w,h);
  728.     for(i=0;i<h;i++)//模板尺寸为32*16
  729.     {
  730.         for(j=0;j<w;j++)
  731.         {
  732.             if(temp[i*w+j]==255)//如果车牌与模板当前位置都为白色,则为0
  733.             {
  734.                 if(temp1[i*w+j]==255)temp[i*w+j]=0;
  735.                 //k=1<<(7-(j%8));//当前要检查的是第几位
  736.                 //if((moban[i*2+j/8] & k) == k)
  737.                 //    temp[i*w+j]=0;
  738.             }
  739.             else if(temp1[i*w+j]==255)temp[i*w+j]=255;//如果原图为黑点,但模板有白点,则加上去
  740.         }
  741.     }
  742.     WriteBmp1("c3.bmp",temp,w,h);
  743.    
  744.     //其实根本就不用删的,反正是遍历出最批配的字
  745.     //delpoint(temp,h,w,4);//删除噪点,小于4点的删除掉
  746.     //WriteBmp1("c4.bmp",temp,w,h);
  747.    
  748.     for(i=0;i<h;i++)//计算余下的白点数
  749.     {
  750.         for(j=0;j<w;j++)
  751.         {
  752.             if(temp[i*w+j]==255)
  753.             {
  754.                 k++;
  755.             }
  756.         }
  757.     }
  758.     return k;
  759. }

  760. //比较7个字符,得到最相似的那个
  761. void strout(struct Bmp1 *img)
  762. {
  763.     int i,j,k=0,m=800,n=0;
  764.     //int p[5]={0};
  765.     for(i=34;i<70;i++)//只扫描汉字
  766.     {
  767.         k=cmpstr(img->strr[0],FONT[i]);//比较车牌的汉字与模板文件
  768.         if(k==0)//如果完全批配,则返回ID号
  769.         {
  770.            n=i;
  771.            break;
  772.         }
  773.         else//否则,找到噪点数最少的ID
  774.         {
  775.             if(k<m)
  776.             {
  777.                 m=k;
  778.                 n=i;
  779.             }
  780.         }
  781.     }
  782.     img->string[0]=n;//把找到的ID保存进string[0]中

  783.     //继续找后面的字符
  784.     for(i=1;i<7;i++)
  785.     {
  786.         n=0;k=0;m=800;
  787.         for(j=0;j<34;j++)//34个字符
  788.         {
  789.             k=cmpstr(img->strr[i],FONT[j]);
  790.             if(k==0)
  791.             {
  792.                 n=j;
  793.                 break;
  794.             }
  795.             else
  796.             {
  797.                 if(k<m)
  798.                 {
  799.                     m=k;
  800.                     n=j;
  801.                 }
  802.             }
  803.         }
  804.         img->string[i]=n;
  805.     }
  806. }

  807. //输出车牌号
  808. void outtext(struct Bmp1 img1)
  809. {
  810.     //10+26+31=67个车牌字符
  811.     int i;

  812.     printf("\n\n\n\n\n\n");
  813.     printf("\n        The Car Id Is\n");
  814.     printf("\n");
  815.     for(i=0;i<7;i++)
  816.     {
  817.         printf("   ");
  818.         printf("%s",table[img1.string[i]]);
  819.     }
  820.     printf("\n");
  821.     printf("\n   This is designed by liujia\n");//刘佳就是原作者
  822.     printf("\n\n\n\n\n\n\n\n");
  823. }

  824. int main(int argc, char **argv)
  825. {
  826.     struct BMP_img img;//定义结构
  827.     struct Bmp1 img1;

  828.     //把当前文件夹下的1.bmp文件内容,读到img结构中,并上下镜像
  829.     if(read_img("1.bmp", &img)==0)
  830.     {
  831.         printf("error");
  832.         return 0;
  833.     }
  834.    
  835.     img1.width=img.width;
  836.     img1.height=img.height;
  837.     byte *temp=(byte*)malloc(img.width*img.height);
  838.     //24位灰度图转单色灰度图
  839.     for(int i=0;i<img.height;i++)
  840.     {
  841.         for(int j=0;j<img.width;j++)
  842.         {
  843.             temp[i*img.width+j]=img.image[i*img.width*3+j*3];
  844.         }
  845.     }
  846.    
  847.     //水平投影,去掉上下非文字区域
  848.     shuipingtouying(&img1,temp);
  849.    
  850.     //垂直投影,去掉车牌中的点,并计算7个字各在什么位置
  851.     cuizhitouying(&img1,temp);//垂直投影,框住每一个字符
  852.    
  853.     //写入镜像后的数据到2.bmp中
  854.     WriteBmp1("2.bmp",temp,img.width,img.height);
  855.    
  856.     //把每个文字切出来
  857.     strBmp(&img1,temp);//把车牌字符放到数组里面

  858.     //缩放每个文字,与模板大小相等
  859.     guiyi(&img1);

  860.     strout(&img1);//比较车牌与模板,得到最优解
  861.     outtext(img1);//输出车牌,前面已经成功分解出车牌
  862.    
  863.     free(img.image);//释放动态分配的内存
  864.     free(temp);
  865.    
  866.     printf("请打开2.bmp进行查看\n");
  867.     system("pause");
  868.     return 0;
  869. }
复制代码




举个例子:

可以看到,比较两个完全不同的字,结果中的白点,只会比原来的多,如果比较两个相似的图片,白点就少了,白点越少就是最优解

待比较的图片     模板图片      比较结果
3.jpg
2.jpg
1.jpg

car.rar

3.99 MB, 下载次数: 4

回复

使用道具 举报

本版积分规则

QQ|Archiver|小黑屋|技术宅的结界 ( 滇ICP备16008837号 )|网站地图

GMT+8, 2024-11-22 02:34 , Processed in 0.042597 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表