5

我有一个二进制 blob(见图),我想在它上面放置一个已知宽度和高度的矩形。

如何找到最佳拟合矩形,即最大前景像素在内部而最大数量背景像素在外部的矩形?

(这是我对最佳匹配的初步定义,我愿意接受其他建议)

我正在寻找已知大小的矩形,但如果有任意大小的解决方案,那也很好。

示例 blob: 在此处输入图像描述

我想找到这些矩形: 在此处输入图像描述

到目前为止我的想法包括

  • 从最小的封闭矩形开始;但这不适合这些 blob
  • 最大封闭矩形;同样的问题,另外我没有算法
  • 用霍夫变换找到矩形边;数据太嘈杂了。

我意识到对于符合我的标准的同一个 blob 可能有多个矩形,理想情况下,我想要一些可以找到所有候选者的算法(认为因为这可能更难,我很乐意找到一种只找到一个候选者的方法) : 在此处输入图像描述 在此处输入图像描述

我主要使用 opencv 和 cvBlobLib 来处理我的数据,但我愿意接受任何通用解决方案。

4

1 回答 1

1

I have seen a thesis on a similar subject (circle covering on a RGB plane), based on an evolutionary approach.

  • The objective function was clearly defined (How many squares? How big? Can they overlap? You'd probably want to penalize small or overlapping squares).
  • You may start by running the k-means algorithm to preprocess the data, i.e. find potential center points of the squares.

As I recall, SGA, CGA and eCGA were compared (CGA started with initial, k-means-based covering), with SGA outperforming the others. They were ran on a per-image basis. There were around 30 individuals and 20 generations with runtimes around a couple of minutes.

As for the SGA, the crossover operator would take two parents at a time and pair up the closes/most similar circles from both of the parents. Then, for each pair, it would draw a children circle somewhere in between with a radius also in between that of the two circles'. (Though I would suggest not to take values exactly between those of the parents', but allow +/- 15% outside the range. It would keep the population from the premature convergence).

With rectangles, you'd have to slightly modify the approach; each rectangle could be a tuple (x, y, width, height, rotation), with x and y being the coordinates of the center.

于 2013-03-02T17:28:50.033 回答