图像算法上的物体计数

发布于 2024-12-23 01:23:27 字数 171 浏览 1 评论 0原文

我又接到学校任务了。这次,我的老师给我的任务是创建算法来计算图片上有多少只鸭子。

图片与此类似:

我想我应该使用模式识别来搜索上面有多少只鸭子。但我不知道每只鸭子适合哪种图案。

I got school task again. This time, my teacher gave me task to create algorithm to count how many ducks on picture.

The picture is similar to this one:

I think I should use pattern recognition for searching how many ducks on it. But I don't know which pattern match for each duck.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烟若柳尘 2024-12-30 01:23:27

我认为你可以通过分割鸭嘴并计算连接组件的数量来解决这个问题< /a> 在二进制图像中。

要分割鸭嘴,首先将图像转换为 HSV 颜色空间,然后使用色调组件执行二值化。请注意,鸭子喙的色调与图像的其他部分不同。

I think that you can solve this problem by segmenting the ducks' beaks and counting the number of connected components in the binary image.

To segment the ducks' beaks, first convert the image to HSV color space and then perform a binarization using the hue component. Note that the ducks' beaks hue are different from other parts of the image.

_失温 2024-12-30 01:23:27

这是一种方法:

圆的霍夫变换:

  • 初始化一个由 (x,y,radius) 索引的累加器数组
  • 对于每个像素:
    • 计算边缘(例如 Sobel 算子将提供幅度和方向),如果幅度超过某个阈值,则:
      • 递增该边可能提供证据的每个累加器(仅边方向上的 (x,y),仅 min_duck_radius 和 max_duck_radius 之间的半径)
  • 现在对累加器数组进行平滑和阈值处理,以及最高的坐标累加器会告诉你头在哪里。如果您对累加器中的值进行直方图绘制,则阈值可能会突然出现(“大量证据”和“噪音”之间可能存在明显差异)。

这非常简洁,但它可以帮助您入门。

Here's one way:

Hough transform for circles:

  • Initialize an accumulator array indexed by (x,y,radius)
  • For each pixel:
    • calculate an edge (e.g. Sobel operator will provide both magnitude and direction), if magnitude exceeds some threshold then:
      • increment every accumulator for which this edge could possibly lend evidence (only the (x,y) in the direction of the edge, only radii between min_duck_radius and max_duck_radius)
  • Now smooth and threshold the accumulator array, and the coordinates of highest accumulators show you where the heads are. The threshold may leap out at you if you histogram the values in the accumulators (there may be a clear difference between "lots of evidence" and "noise").

So that's very terse, but it can get you started.

昔梦 2024-12-30 01:23:27

这可能只是因为我现在正在使用 SIFT,但对我来说,它看起来可能对您的问题有好处。

它是一种在两张不同图片上匹配同一对象的算法,其中对象可以在两张图片上具有不同的方向、比例并从不同的角度观看。当一个对象被另一个对象部分隐藏(就像你的鸭子一样)时,它也可以工作。

我建议找到一张清晰的橡皮鸭图片(:D),然后使用一些 SIFT 实现(VLFeat - C 库有 SIFT 但没有可视化 SIFT++ - 基于 VLFeat,但采用 C++ 语言Rob Hess 使用 C 语言与 OpenCV...)。

您应该记住,与 SIFT(以及其他任何东西)的匹配并不完美 - 因此您可能无法获得图片中橡皮鸭的准确数量。

It might be just because I'm working with SIFT right now, but to me it looks like it could be good for your problem.

It is an algorithm that matches the same object on two different pictures, where the objects can have different orientations, scales and be viewed from different perspectives on the two pictures. It can also work when an object is partially hidden (as your ducks are) by another object.

I'd suggest finding a good clear picture of a rubber ducky ( :D ) and then use some SIFT implementation (VLFeat - C library with SIFT but no visualization, SIFT++ - based on VLFeat, but in C++ , Rob Hess in C with OpenCV...).

You should bear in mind that matching with SIFT (and anything else) is not perfect - so you might not get the exact number of rubber duckies in the picture.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文