【问题标题】:How to count the number of connected components in a blob using Aforge.Net如何使用 Aforge.Net 计算 blob 中连接组件的数量
【发布时间】:2012-07-20 23:05:20
【问题描述】:

在我的车牌识别应用程序(英国车牌)中,我进行了矩形检测,并使用了几个标准,例如车牌的宽度/长度比以及车牌的最小宽度和长度。我已经设法显着减少了非车牌区域。我的最后一个标准是获取每个候选区域的连接分量的数量,以便我可以验证我在研究论文中读到的车辆图像的真实车牌区域。

我正在使用 C# 和 Aforge.Net 库。但是如何使用 ConnectedComponentsLabeling 获取车牌中的连接组件数呢?

【问题讨论】:

    标签: c# image-processing aforge anpr


    【解决方案1】:

    我正在这样做:

    FiltersSequence preOcr = new FiltersSequence(
        Grayscale.CommonAlgorithms.BT709, 
        new BradleyLocalThresholding());
    
    Bitmap grayscale = preOcr.Apply(original);
    var labels = new ConnectedComponentsLabeling();
    labels.Apply(new Invert().Apply(grayscale));
    
    //Console.WriteLine(labels.ObjectCount);    // Here you go
    foreach (var candidate in labels.BlobCounter.GetObjectsInformation())
    {
        using (Bitmap symbol = new Bitmap(candidate.Rectangle.Width, 
                                          candidate.Rectangle.Height))
        using (Graphics g2 = Graphics.FromImage(symbol))
        {
            g2.DrawImage(grayscale, 0, 0, candidate.Rectangle, GraphicsUnit.Pixel);
            symbol.Save(String.Format(@"temp\{0}-{1}.jpg",i,++n), ImageFormat.Jpeg);
            // do stuff
        }
    }
    

    【讨论】:

      【解决方案2】:

      当您找到与车牌相对应的 blob 后,使用此 blob Image 作为另一个 blob 计数器实例的输入。结果将告诉您此 blob Image 中的组件数量。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-02-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多