zoukankan      html  css  js  c++  java
  • paip.验证码识别分割.使用投影直方图

    paip.验证码识别---分割.--使用投影直方图

     

    验证码识别的时候,需要纵向分割字符。需要识别字符的边界..此时可以使用投影直方图

    1.做y轴的投影    2. 在直方图观察像素的分布

     

     

     

    C#代码

    Bitmap projectHistogram(Bitmapbmp)

            {

     

                // stats

                if (histo!= null)

                    histo= null;

     

                int width=bmp.Width;

                int height=bmp.Height;

     

                histo= new int[width];

     

                for (int y=0; y<height; y++)

                    for (int x=0; x<width; x++)

                    {

                        Color color=bmp.GetPixel(x, y);

     

                        if (color.R<50&&color.G<50&&color.B<50)

                            //if (color.A > 200)

                            histo[x]++;

                    }

     

                // draw

                //int max = getMax(histo);

     

                Bitmap tmp= new Bitmap(width, height);

                using (Graphics g=Graphics.FromImage(tmp))

                    for (int i=0; i<width; i++)

                        g.DrawLine(

                            Pens.Black,

                            i,

                            height,

                            i,

                            height-histo[i]);

     

                return tmp;

            }

     

     

     

    参考

    图像识别练习(字符验证码、车牌号、身份证号)

  • 相关阅读:
    Redis和MySQL的结合方案
    Java-CyclicBarrier的简单样例
    第十话-模板方法模式
    Codeforces 19D Points 线段树+set
    操作系统: 二级文件夹文件系统的实现(c/c++语言)
    mongodb数据库的启动和停止
    XML,HTML,XHTML
    android之ViewStub的使用
    教你实现语音识别(基于科大讯飞)
    android通过代码判断手机是否root
  • 原文地址:https://www.cnblogs.com/attilax/p/15199850.html
Copyright © 2011-2022 走看看