如何用python精確定位五線譜

最精確的五線譜檢測(cè):

源碼位置

連通域法
完美5線
  • 連通域檢測(cè)標(biāo)注label
  • 判斷連通域的頂部(底部)是否是平的:
  • 判斷連通域面積大小


    經(jīng)過上面條件限制后的直線
  • 合并近似直線
  • 判斷5線名稱
    先輸出1,5線的位置,再對(duì)其余位置合并以及判斷位置
for i in (finallist):
    if (i.get_deltan()>15) and(i.get_deltal()<=15):
        i.set_5(5)
    elif (i.get_deltan()<=15 ) and(i.get_deltal()>15):
        i.set_5(1)
    
'''
pos:156 l5:5    distribute:None last:1  next:41
pos:198 l5:1    distribute:None last:38 next:3
pos:201 l5:None distribute:None last:2  next:3
pos:205 l5:None distribute:None last:3  next:1
pos:207 l5:None distribute:None last:1  next:2
pos:211 l5:None distribute:None last:2  next:2
pos:216 l5:5    distribute:None last:1  next:34
pos:254 l5:1    distribute:None last:32 next:8
pos:265 l5:None distribute:None last:5  next:5
pos:271 l5:None distribute:None last:2  next:3
pos:276 l5:5    distribute:None last:2  next:42
pos:321 l5:1    distribute:None last:40 next:5
pos:327 l5:None distribute:None last:2  next:2
pos:330 l5:None distribute:None last:1  next:5
pos:336 l5:None distribute:None last:4  next:5
pos:342 l5:5    distribute:None last:4  next:44
pos:386 l5:1    distribute:None last:43 next:3
pos:391 l5:None distribute:None last:3  next:2
pos:394 l5:None distribute:None last:1  next:2
pos:396 l5:None distribute:None last:1  next:1
pos:398 l5:None distribute:None last:1  next:5
'''
  • 確認(rèn)五線后調(diào)整間距
  • 輸出位置數(shù)據(jù)

其余嘗試過的方法:

1 統(tǒng)計(jì)法

  • 每根五線譜在y軸上的像素累積作統(tǒng)計(jì)
像素平均值
  • 使用計(jì)數(shù)來作統(tǒng)計(jì)


    計(jì)數(shù)出現(xiàn)的五線位置

缺陷,譜子傾斜無解。若譜子很正,效果中上水平

2 霍夫空間法(預(yù)處理為candy邊緣檢測(cè))

霍夫直線檢測(cè)原理

極坐標(biāo)下的霍夫變換

使用candy檢測(cè)邊緣后霍夫直線檢測(cè)
  • 分段完美,五線定位需要迂回操作:從段落中均分出5條直線
    (預(yù)計(jì)效果很完美,還未嘗試)

3 霍夫空間法(預(yù)處理為卷積邊緣檢測(cè))

fit = np.array([
    [-2,-2,-2,-2,-2],
    [-1,-1,-1,-1,-1],
    [-0,-0,-0,-0,-0],
    [1,1,1,1,1],
    [2,2,2,2,2]    
])

fit = np.array([
    [-0,-0,-0,-0,-0],
    [2,2,2,2,2],
    [-0,-0,-0,-0,-0],
    [-2,-2,-2,-2,-2],
    [0,0,0,0,0]
    
])

  • 1 使用兩個(gè)fitter的轉(zhuǎn)置,過濾出豎線,再由原圖減去
    過濾出的縱向圖像

    消去縱向后的圖像
  • 噪音太大,霍夫直線檢測(cè)效果很差
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容