我想检测图像中类型为 y^2 = 4a*x 的抛物线[尺寸:512 X 512]。我准备了一个累加器数组 acc[size: 512 X 512 X 512]。我准备了一个对应于该图像的矩阵。我使用霍夫变换。我是这样做的:
for x = 1 to 512
for y= 1 to 512
if image_matrix(x,y)> 245//almost white value, so probable to be in parabola
{
for x1= 1 to 512
for y1= 1 to 512
{
calculate 'a' from (y-y1)^2 = 4*a*(x-x1).
increment acc(i,j,k) by 1
}
}
if acc(i,j,k) has a maximum value.
{
x1=i, y1=j,a =k
}
我遇到了以下问题:
1) acc[512][512][512] 占用内存大。它需要大量的计算。我怎样才能减少数组的大小,从而最大限度地减少计算量? 2) 并不总是 acc(i,j,k) 的最大值输入给出预期的输出。有时第二个或第三个最大值,甚至第 10 个最大值给出预期的输出。我需要大约。 'a'、'x1'、'y1'的值(非精确值)。
请帮帮我。是我的概念有问题吗?
最佳答案
我要说的可能只能部分回答您的问题,但它应该有效。
如果你想找到这些类型的抛物线
y^2 = 4a*x
然后它们仅由一个参数“a”进行参数化。因此,我真的不明白你为什么要使用 3 维的累加器。
当然,如果你想用更一般的方程式找到抛物线,例如:
y = ax^2 + bx + c
或者在 y 方向上用 y 替换 x,您将需要一个 3 维累加器,就像您的示例中那样。
我认为在你的情况下这个问题很容易解决,说你只需要一个累加器(因为你只有一个参数要累加:a)
这就是我的建议:
for every point (x,y) of your image (x=0 exclusive) {
calculate (a = y^2 / 4x )
add + 1 in the corresponding 'a' cell of your accumulator
(eg: a = index of a simple table)
}
for all the cells of your accumulator {
if (cell[idx] > a certain threshold) there is a certain parabola with a = idx
}
希望对你有帮助 This is as well an interesting thing to look at : 朱利安,
关于image - OpenCV:使用霍夫变换进行抛物线检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6688277/