最精確的五線譜檢測(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ù)來(lái)作統(tǒng)計(jì)
計(jì)數(shù)出現(xiàn)的五線位置
缺陷,譜子傾斜無(wú)解统锤。若譜子很正,效果中上水平
2 霍夫空間法(預(yù)處理為candy邊緣檢測(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è)效果很差