1

有人有想法从对象中获取大小和位置吗?在具有白色像素的二值图像中检测到对象:

例如:检测到/原始

http://ivrgwww.epfl.ch/supplementary_material/RK_CVPR09/Images/segmentation/2_sal/0_12_12171.jpg http://ivrgwww.epfl.ch/supplementary_material/RK_CVPR09/Images/comparison/orig/0_12_12171.jpg

我知道CvMoments- 方法。但我不知道在这种情况下如何使用它。

顺便说一句:我怎样才能让我的面具更清楚?

4

2 回答 2

3

简单算法:

  1. 使用形态学操作(侵蚀)删除小区域的白色像素。
  2. 用于findContours查找所有轮廓。
  3. 使用countNonZerocontourArea查找每个轮廓的面积。
  4. 循环遍历每个轮廓的所有点并找到它们的平均值。这将是轮廓的中心。
于 2012-07-17T09:39:05.710 回答
1

If the object is tree, you should delete small areas by using morphology as Astor written.

Alternative of finding mass, and mass center is using moments: http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=moments#moments

m00 as doc says is mass

There are also formulas for mass center.

This approach works when only your object remains on image after segmentation.

于 2012-07-17T12:58:25.820 回答