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;

            }

     

     

     

    参考

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

  • 相关阅读:
    Java多线程总结之线程安全队列Queue
    Android模拟器Genymotion使用详解
    Failed to resolve:com.android.support:appcompat-v7:报错处理
    第一次使用Android Studio时你应该知道的一切配置
    sdk manager 打不开
    Android app设置全屏模式
    Android设备与外接U盘实现数据读取操作
    IIS相关优化
    集群、负载均衡、分布式
    docker启动
  • 原文地址:https://www.cnblogs.com/attilax/p/15199850.html
Copyright © 2011-2022 走看看