Algorithm for Finding Longest Stretch of a Value at any Angle in a 2D Matrix

我是研究僧i 提交于 2020-01-16 18:18:31

问题


I am currently working on a computer-vision program that requires me to determine the "direction" of a color blob in an image. The color blob generally follows an elliptical shape and thus can be used to track direction (with respect to an initially defined/determined orientation) through time.

The means by which I figured I would calculate changes in direction are described as follows:

  1. Quantize possible directions (360 degrees) into N directions (potentially 8, for 45 degree angle increments).
  2. Given a stored matrix representing the initial state (t0) of the color blob, also acquire a matrix representing the current state (tn) of the blob.
  3. Iterate through these N directions and search for the longest stretch of the color value for that given direction. (e.g. if the ellipse is rotated 45 degrees with 0 being vertical, the longest length should be attributed to the 45 degree mark / or 225 degrees).

The concept itself isn't complicated, but I'm having trouble with the following:

  • Calculating the longest stretch of a value at any angle in an image. This is simple for angles such as 0, 45, 90, etc. but more difficult for the in-between angles. "Quantizing" the angles is not as easy to me as it sounds.

Please do not worry about potential issue with distinguishing angles such as 0 and 90. Inertia can be used to determine the most likely direction of the color blob (in other words, based upon past orientation states).

My main concern is identifying the "longest stretch" in the matrix.

Thank you for your help!


回答1:


You can use image moments as suggested here: Matlab - Image Momentum Calculation.

In matlab you would use regionprops with the property 'Orientation', but the wiki article in the previous answer should give you all of the information you need to code it in the language of your choice.



来源:https://stackoverflow.com/questions/11454254/algorithm-for-finding-longest-stretch-of-a-value-at-any-angle-in-a-2d-matrix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!