OpenCV:使用霍夫变换进行抛物线检测

发布于 2024-11-23 18:46:13 字数 685 浏览 0 评论 0原文

我想检测图像中 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) 的最大值条目并不总是给出预期的输出。有时第二个或第三个最大值,甚至第十个最大值给出了预期的输出。我需要大约。 'a'、'x1'、'y1' 的值(不是精确值)。

请帮我。难道我的观念有什么错误吗?

I want to detect parabola(s) of type : y^2 = 4a*x in an image[size: 512 X 512]. I prepared an accumulator array, acc[size: 512 X 512 X 512]. I prepared a MATRIX corresponding to that image. I used hough-transform. This is how I did it:

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
}

I faced following problems:

1) acc[512][512][512] takes large memory. It needs huge computation.How can I decrease array size and thus minimize computation?
2) Not always max valued-entry of acc(i,j,k) give intended output. Sometimes second or third maximum, and even 10'th maximum value give the intended output. I need approx. value of 'a', 'x1','y1'(not exact value).

Please help me. Is there any wrong in my concept?

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

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

发布评论

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

评论(1

醉态萌生 2024-11-30 18:46:13

我要说的可能只能部分回答你的问题,但它应该有效。

如果您想找到这些类型的抛物线

 y^2 = 4a*x

,那么它们仅由一个参数“a”进行参数化。因此,我真的不明白为什么你使用 3 维累加器。

当然,如果您想找到具有更一般方程的抛物线,例如 :

y = ax^2 + bx + c

或通过用 y 替换 x 来找到 y 方向的抛物线,您将需要一个 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
  }

我希望它可以帮助你,
这也是一件有趣的事情:
朱利安,

What i'm going to say may only partly answer your question, but it should work.

If you want to find these type of parabolas

 y^2 = 4a*x

Then they are parametrized by only one parameter which is 'a'. Therefore, i don't really understand why you use a accumulator of 3 dimensions.

For sure, if you want to find a parabola with a more general equation like :

y = ax^2 + bx + c

or in the y direction by replacing x by y, you will need a 3-dimension accumulator like in your example.

I think in your case the problem could be solved easily, saying you only need one accumulator (as you have only one parameter to accumulate : a)

That's what i would suggest :

  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
  }

I hope it can help you,
This is as well an interesting thing to look at :
Julien,

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