亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在圖像上繪制霍夫變換線

在圖像上繪制霍夫變換線

絕地無雙 2022-05-19 15:31:17
我正在嘗試自己實現霍夫線變換,但我無法完成繪制高投票 thetas/rhos 值的最后一步。我試圖自己做數學,但仍然得到錯誤的輸出。當我檢查其他一些實現時,他們總是使用這種方法從極坐標轉換為笛卡爾坐標以找到兩個點。for r,theta in lines[0]: # Stores the value of cos(theta) in a a = np.cos(theta) # Stores the value of sin(theta) in b b = np.sin(theta) # x0 stores the value rcos(theta) x0 = a*r # y0 stores the value rsin(theta) y0 = b*r # x1 stores the rounded off value of (rcos(theta)-1000sin(theta)) x1 = int(x0 + 1000*(-b)) # y1 stores the rounded off value of (rsin(theta)+1000cos(theta)) y1 = int(y0 + 1000*(a)) # x2 stores the rounded off value of (rcos(theta)+1000sin(theta)) x2 = int(x0 - 1000*(-b)) # y2 stores the rounded off value of (rsin(theta)-1000cos(theta)) y2 = int(y0 - 1000*(a)) # cv2.line draws a line in img from the point(x1,y1) to (x2,y2). # (0,0,255) denotes the colour of the line to be  #drawn. In this case, it is red.  cv2.line(img,(x1,y1), (x2,y2), (0,0,255),2) 來自GeeksForGeeks的先前代碼。我沒有得到的是那些方程x1 = int(x0 + 1000*(-b))& y2 = int(y0 - 1000*(a))。通過將這些方程轉換為數學形式:x1 = r cos(theta) + r (-sin(theta)) || y1 = r sin(theta) + r (cos(theta))這兩個方程對我來說很奇怪。當我們從極坐標轉移到笛卡爾坐標時,'r cos(theta)' 是正常的。但是,下一部分不清楚。誰能解釋它背后的原始數學?
查看完整描述

1 回答

?
達令說

TA貢獻1821條經驗 獲得超6個贊

(r cos, r sin) 是線上最接近原點的點。它不是線性方程。要畫一條線,你需要 2 個點。在這里,他只是沿著線 1000 和 -1000 移動,得到兩個保證在中等尺寸圖像之外的點


有很多方法可以得到直線方程。最簡單的是:r = x cos + y sin


If x1 = x - t sin

y1 = (1 / sin) (r - x cos + t sin cos)

= y + t cos

他使用 t=+/-1000 作為圖像大小


查看完整回答
反對 回復 2022-05-19
  • 1 回答
  • 0 關注
  • 113 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號