如何从图像中检测对象的数量?

How to detect number of objects from image?

我有一个 windows 表单应用程序,我想计算医学图像中的对象数量。例如

我使用了一种算法,可以从图像中提取每个对象的轮廓。

private void findContoursToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Image<Gray, byte> imgOutput = imgInput.Convert<Gray, byte>().ThresholdBinary(new Gray(100), new Gray(255));
        Emgu.CV.Util.VectorOfVectorOfPoint contours = new Emgu.CV.Util.VectorOfVectorOfPoint();
        Mat hier = new Mat();

        Image<Gray, byte> imgout = new Image<Gray, byte>(imgInput.Width, imgInput.Height, new Gray(100));

        CvInvoke.FindContours(imgOutput, contours, hier, Emgu.CV.CvEnum.RetrType.External, Emgu.CV.CvEnum.ChainApproxMethod.ChainApproxSimple);
        CvInvoke.DrawContours(imgout, contours, -1, new MCvScalar(123, 0, 0));

        pictureBox2.Image = imgout.Bitmap;

    } 

但是我无法从图像中找出单元格的数量。我必须使用任何建议或算法吗?

我在 EMGU 文档中进行了搜索,但没有找到任何功能符合我的要求。

任何建议或回答都将得到奖励。

如果您认为这太宽泛,我不想要已实现的算法。我只需要一些想法或我必须使用的算法建议。

这可能有点基础和蛮力,但是如何 select 在图像上随机选择一个接近绿色的点,然后有效地搜索 'matching' 颜色(使用相同颜色的公差。当您访问每个像素时,将其着色为黑色,这样您就不会再次查看它并计算您着色的像素数。每次 select 一个像素,确保它不是黑色. 一旦你找不到更多的点,如果黑色像素的数量大于一个公差(所以你只找到'big'个多边形),然后将其计入单元格数