【问题标题】:Aforge get blobs from one image and extract same location from otherAforge 从一个图像中获取 blob 并从其他图像中提取相同的位置
【发布时间】:2012-09-26 17:39:21
【问题描述】:

我有一张图像,我对其进行了一些处理,以便将背景与前景分开,从而创建一个二进制(黑/白)图像。

使用 AForge,我能够从处理后的图像中检测到所有 blob,并将它们返回。

所以,我把我的原始图像复制到“SourceImg”,做一些过滤以分离背景并使其成为二进制图像,然后我可以正确地进行blob提取。

    public static List<Bitmap> ApplyBlobExtractor(Bitmap SourceImg)
    {
        List<Bitmap> ImgLetters = new List<Bitmap>();
        AForge.Imaging.BlobCounter blobCounter = new AForge.Imaging.BlobCounter();

        // Sort order
        blobCounter.ObjectsOrder = AForge.Imaging.ObjectsOrder.XY;
        blobCounter.ProcessImage(SourceImg);
        AForge.Imaging.Blob[] blobs = blobCounter.GetObjects(SourceImg, false);

        // Adding images into the image list            
        AForge.Imaging.UnmanagedImage currentImg;
        foreach (AForge.Imaging.Blob blob in blobs)
        {
            currentImg = blob.Image;
            ImgLetters.Add(currentImg.ToManagedImage());
        }
        return ImgLetters;
    }

我真正想做的是使用这些 blob 的信息从原始的、未处理的图像中提取位置。

理想情况下,我想像切饼干一样使用 blob,然后从我最初的未处理图像文件中提取它们。

【问题讨论】:

    标签: c# image aforge


    【解决方案1】:

    您可以使用 AForge.Imaging.Filters.Intersect 类来使用您的 blob 图像和源图像。

    【讨论】:

    • 该死的......有一个过滤器可以做到这一点?我只是手工完成的。
    【解决方案2】:

    假设您的部分图像处理没有调整原始图像的大小,为什么不循环应用裁剪变换到原始图像,将裁剪矩形设置为 blob 的 Rectangle 属性?

    【讨论】:

    • 这个问题是我可以抓住边界框,但边界框内可能有另一个斑点。
    猜你喜欢
    • 2012-03-09
    • 2020-01-14
    • 2018-11-01
    • 1970-01-01
    • 2019-07-19
    • 2011-08-03
    • 1970-01-01
    • 2013-03-28
    • 1970-01-01
    相关资源
    最近更新 更多