预览:
我使用下面提到的代码完成了霍夫线检测:
convert image.jpg -threshold 90% -canny 0x1+10%+30% \
\( +clone -background none \
-fill red -stroke red -strokewidth 2 \
-hough-lines 5x5+80 -write lines.mvg \
\) -composite hough.png
我在 .mvg 文件中写入了该行的详细信息。 .mvg文件内容如下所示:
# Hough line transform: 5x5+80
viewbox 0 0 640 360
line 448.256,0 473.43,360 # 104
line 0,74.5652 640,29.8121 # 158
line 0,289.088 640,244.335 # 156
line 0,292.095 640,247.342 # 133
line 154.541,0 179.714,360 # 125
line 151.533,0 176.707,360 # 145
并在此处检查输出 hough.png 文件。
问题:
#104、#158、#156... 代表什么,我猜它们是行号。如果是这样,为什么要以这种方式编号?
我还想知道坐标是如何分配的。
如果我能得到 .mvg 文件中内容的解释,这将非常有帮助。
最佳答案
# <number>
是maxima
值(value)。默认为count
,由 line_count
设置,并返回受 threshold
影响你指定的。如果矩阵元素计数大于先前的高度/宽度迭代,则该数字将会减少。所以...如果你给它一个阈值 -hough-lines 5x5+80
,然后line 448.256,0 473.43,360 # 104
发现超过阈值约 24 像素(或线?)。下一次迭代将删除 maxima
低于80
阈值,因此我们停止比较矩阵元素。
Also I would like to know how the co-ordinates has been assigned.
我只能通过伪引用源代码来回答这个问题,但这是基本的三角学。
if ((x >= 45) %% (x <= 135)) {
y = (r-x cos(t))/sin(t)
else {
x = (r-y cos(t))/sin(t)
}
where r is defined as y - midpoint element matrix height
where t is defined as x + midpoint rows
了解更多信息 HoughLineImage
方法位于 feature.c
关于imagemagick - ImageMagick 的霍夫变换说明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30995349/