APP下载

基于局部二进制模式的乐谱谱线检测与删除*

2017-12-13孟凡奥申一汀

计算机与生活 2017年12期
关键词:中心点乐谱谱线

孟凡奥,李 锵,申一汀,关 欣

天津大学 电子信息工程学院,天津 300072

基于局部二进制模式的乐谱谱线检测与删除*

孟凡奥,李 锵,申一汀,关 欣+

天津大学 电子信息工程学院,天津 300072

谱线检测与删除是光学乐谱识别中重要和关键的环节之一。在乐谱中,谱线往往与大多数符号交叉或重叠,即存在像素属于谱线像素同时也属于符号像素的情况,因此删除谱线并且不破坏音乐符号并非易事。研究目标是需要删除仅仅属于谱线的像素,观察乐谱图像可以发现谱线像素与非谱线像素局部纹理存在差异,主要表现为谱线像素的局部纹理与谱线宽度相关,简洁明了,而非谱线像素的局部纹理除了存在仅与自己本身相关的情况,还存在与交叉点相关的情况。因此,采用局部二进制模式通过提取局部纹理特征,获得谱线像素与非谱线像素局部纹理的差异,对谱线与非谱线像素进行检测分类,进而将谱线像素删除。该方法不仅可以删除理想状态下乐谱谱线,对弯曲状态下乐谱谱线同样适用。实验结果证明了该方法在像素误差、片段误差等性能指标上优于现有常用方法。

谱线检测与删除;光学乐谱识别;局部纹理特征

1 引言

几个世纪以来,音乐主要通过口口相传和乐谱记录这两种方式传播,其中乐谱作为音乐信息交流和传承的载体具有重要意义。在数字化的今天,将纸质乐谱保存为计算机能“读懂”的二进制数据是发展趋势。为了实现传统纸质乐谱向数字乐谱的高速自动转换,光学乐谱识别(optical music recognition,OMR)技术产生[1]。OMR首要且重要的步骤是乐谱谱线的检测与删除。因为对于大多数OMR系统需要将符号从谱线中分离出来,而乐谱中谱线的一个显著特点是与绝大多数乐谱符号交叉或重叠,所以符号分离是一个障碍。目前分离最有效的方法是删除谱线。

乐谱中符号种类繁多,表现出的纹理特征各异,而谱线的主要特征是一组平行的水平线,纹理特征单一。由于纹理特征的不同,可以通过提取局部纹理特征,将谱线与非谱线元素分开。

近年来,局部二值模式得到广泛运用[2]。局部二值模式(local binary pattern,LBP)是一种灰度范围内的纹理描述方式,它从一种纹理局部近邻定义中衍生出来。本文提出基于局部二值模式的乐谱谱线检测与删除方法。

本文组织结构如下:第2章简要回顾了已有的谱线检测与删除方法和LBP基本算子;第3章提出了基于局部二值模式的乐谱谱线检测与删除方法;第4章叙述性能指标;第5章进行对比实验并分析实验结果;第6章总结全文。

2 研究现状与基本LBP算子

2.1 研究现状

谱线检测与删除是很多OMR系统的基础[1]。虽然有些研究者提出的乐谱识别算法并不需要删除谱线[3-5],但谱线的存在会打断音符或者成为一个新的符号,这增加了音符的识别难度。为了有效并准确识别音符,检测并删除谱线是必要的。

谱线检测常见方法可分为两类[6]:(1)基于统计变换的方法,例如水平投影[7]和Hough变换[8]等。统计变换方法具有抗噪声能力强的特点,但当谱线出现变形等不具有严格的直线形态时,会出现失效情况。(2)基于结构特征搜索的方法,如游程分析法[9]、行邻图法[10]、特征点DP匹配法[11]和路径搜索法[12]等。结构搜索方法具有较强的抗变形能力,但是过于依赖谱线的局部细节,容易受到噪声的干扰。

删除谱线的过程中不能破坏符号的完整性,目前有多种删除谱线的方法[13]。直线检测法[14]先检测到谱线的骨架,接着删除围绕在骨架点周围的不属于交叉音符的垂直黑色游程。有两种方法实现:第一种方法检查骨架点的垂直黑色游程是否超过两倍的谱线高度[15];第二种方法利用角度来计算通过骨架点的弦的长度,生成“角度-长度”直方图,如果直方图中只有一个峰值且出现在附近,表示观测点为谱线像素可安全删除,如果存在多个峰值则保留该点[16]。

Roach和Tatem[17]使用一个基于角度信息和邻接像素的标签去分辨谱线像素。这样就获得了水平方向的线像素,其中有些像素是属于符号的,为了避免删除在谱线上符号的像素,一些水平方向的线像素会根据自身周围像素的标签重新迭代,标记为非水平方向的像素,最终删除所有水平方向的像素。

Carter等人[10]使用行邻图方法将乐谱图像进行分割。谱线片段寻找明显的水平片段,然后垂直连接与水平方向有重叠并且有一个垂直的距离大约是谱线间距的片段。这些片段通过水平外推与其他片段水平连接,最终谱线片段的结果集不包含符号,因而可以被直接删除。除了上述几种方法,近几年研究人员还提出灰度域方法[18]、机器学习方法[19-20]和形态学方法[21-22]等。

2.2 基本LBP算子

局部二值模式最早是由Ojala等人[23]提出的,能很好地提取图像的局部纹理特征,近年来被广泛地用于纹理分类、人脸图像分析等领域。局部二值模式是一种能够有效地度量和提取图像局部及全局纹理信息的算子。最基本的LBP算子的定义如下[24]:

在一个3×3的窗口,以中心像素点的灰度值为阈值,将相邻的8个像素点的灰度值与其进行比较。图像中某个像素为中心点gc,周围的8个像素点为g0,g1,…,g7,则这个局部区域的纹理T的分布可定义为局部区域内像素灰度的联合分布密度:

局部区域的纹理可以用中心点和其周边点像素的值之差的联合分布来表示:

改写为:

由于t(gc)只是描述了整个图像的亮度分布情况,而跟图像的局部纹理无关,可以忽略不计:

只考虑差值的符号得:

通过式(5)和(6)得到一个8位的二进制数,对像素不同位置进行加权求和,即得到以(xc,yc)为中心点的LBP值:

这个LBP值可以反映以该像素点为中心的3×3方形区域的纹理信息。这种基本LBP算子被称作LBP/C,对比度分量C是邻域中所有大于等于中心点像素的均值与其余像素的均值之差,如图1所示。

Fig.1 Original LBP operator图1 基本LBP算子

3 基于局部二进制模式的谱线检测与删除

3.1 本文的LBP算子

对于基本的LBP算子,本文结合乐谱图像内容特点进行了改进,对于经过二值化处理的乐谱图像,在一个3×3的窗口,以黑色像素点的灰度值0为阈值,将相邻的8个像素点的灰度值与其进行比较。若等于中心灰度值则标记1,否则标记0。这样一来,产生了总数为8的若干1或0,不设加权直接将所有值相加,即可得到该窗口的LBP值。

3.2 理想乐谱谱线的删除

在理想乐谱图像中,一条五线谱谱线宽度所占像素为3个像素,如图2所示。

Fig.2 Ideal music score and width of staff line pixel图2 理想乐谱与谱线宽度像素

在3×3的窗口下,假设中心像素的坐标为(xc,yc),当谱线宽度占3个像素时,可以看到在中心像素点左右存在8个像素点与之灰度值相等,因此中心像素点的LBP值为8。

考虑到谱线所在像素的LBP值与非谱线像素的LBP值存在相同的情况,在一个5×5的窗口中,判断中心点上下两点(xc,yc-2)和(xc,yc+2)是否为白色,若是则删除中心点及上下两点。具体流程如图3所示。

Fig.3 Flow chart of staff line detection and removal method based on local binary patterns图3 基于局部二值模式的谱线检测与删除方法流程图

3.3 非理想乐谱谱线的删除

在非理想乐谱图像中,乐谱的谱线所占像素可能少于或多于3个像素,整个乐谱也可能出现弯曲等现象,对于这几类非理想情况,本文方法也可以很好地解决。

(1)谱线宽度小于理想谱线宽度(如图4)

①当谱线宽度占一个像素时,可以看到仅仅在中心像素点左右存在两个像素点与之灰度值相等,因此中心点(xc,yc)的LBP值为2。若点(xc,yc-1)、(xc,yc-2)、(xc,yc+1)和(xc,yc+2)均为白色。则删除中心点(xc,yc)。

Fig.4 The width of staff line pixel is less than ideal one图4 谱线像素宽度小于理想谱线像素宽度

②当谱线宽度占两个像素时,可以看到在中心像素点周围存在5个像素点与之灰度值相等,因此中心点(xc,yc)的LBP值为5。若中心点下方点(xc,yc+1)的LBP值为5,并且点(xc,yc-1)、(xc,yc-2)、(xc,yc+2)和(xc,yc+3)均为白色,则删除中心点(xc,yc)与其下方点(xc,yc+1)。

(2)谱线宽度大于理想谱线宽度(如图5)

Fig.5 The width of staff line pixel is larger than ideal one图5 谱线像素宽度大于理想谱线像素宽度

当谱线宽度占4个像素时,可以看到存在两种情况,LBP值分别为5和8。设LBP值是8的点为中心点(xc,yc),若点(xc,yc+1)的LBP值为8,点(xc,yc-1)和(xc,yc+2)的LBP值为5,并且点(xc,yc-2)和(xc,yc+3)均为白色,则删除点(xc,yc)、(xc,yc-1)、(xc,yc+1)和(xc,yc+2)。

这两种谱线宽度与理想乐谱谱线宽度不一致时,与上一节删除方法相同,只需要通过不同的LBP值和约束条件,判断像素点是否为谱线像素即可。

(3)谱线弯曲

乐谱在扫描等图像采集过程中,由于纸张的厚度或是其他原因,造成乐谱弯曲的现象时常发生。从整体看谱线是弯曲的,但从小范围观察,弯曲的谱线是由一小段直线构成,如图6所示。直线部分删除条件同理想情况,但删除后会残留,接着判断若中心点(xc,yc)与斜下方点(xc+1,yc+1)或是(xc,yc)与斜上方点(xc-1,yc-1)的LBP值同时为4,则删除点(xc,yc)与(xc+1,yc+1)及上下两点或是(xc,yc)与(xc-1,yc-1)及上下两点。

Fig.6 Pixel distribution of curved score staff lines图6 弯曲乐谱谱线的像素分布

4 误差测度

为了统一观测这些谱线检测与删除方法的表现,本文使用像素和片段区域误差测度[13]。

4.1 像素误差

谱线删除问题在像素层面可以被看成是一个二分类的问题(谱线像素和非谱线像素),使用如下公式计算:

4.2 片段区域误差

谱线删除也可以被看成是一个分割问题,把谱线片段从符号片段里分割出来,使用如下公式计算:

谱线片段错误分类如表1所示。

Table 1 Classification of staff segment errors表1 谱线片段错误分类

4.3 统计分析方法

用合适的统计分析方法对于一个对比分析的评估来说是必要的。Mao和Kanungo[25]提出了一个成对模型方法。对于一个真实差的置信区间Δii′在给定的置信程度α下的结果为:

其中,n是测试乐谱数量;是样本均值;是样本方差;tα/2,n-1是n-1自由度的t分布的百分位。

为了测试误差测度对于算法之间是否是统计上的差异,假设 Δii′=0 ,且,n-1的自由度的t分布的概率密度函数为f(t),得:

5 实验结果与分析

实验所用的数据库是文献[13]提供的,包含32个乐谱图像,其中理想谱线乐谱15个,非理想谱线乐谱17个。本文使用的弯曲乐谱图像是通过文献[13]中的方法将理想乐谱图像变换得到的,即通过正弦波的幅度与谱线宽度之比得到曲率,将理想乐谱图像转变成弯曲程度不同的图像,弯曲的曲率参数为:

如图7所示本文方法在谱线弯曲时能很好地删除谱线。

Fig.7 Curved music score(fragment)and symbol image图7 弯曲的乐谱(片段)和删除谱线的音符图

表2和表3分别展示的是本文方法与其他4种方法的关于像素和片段误差的成对模型分析。表中的负值代表本文方法比对比方法好。从表中可以看出,本文方法对于像素和片段误差在相同的数据库条件下表现较好。从图8中可以看到,本文方法在高音谱号、符桥等细节方面比其他方法有很好的表现。图9所示为不同方法对不同弯曲程度的乐谱处理的像素误差对比图,从图中可以看出本文方法处理效果好于对比方法。

Table 2 Paired model results for pixel error on same test set表2 相同测试集下成对模型对比像素误差结果

Fig.8 Results of different staff removal methods图8 不同谱线删除方法细节结果

Table 3 Paired model results for segmentation error on same test set表3 相同测试集下成对模型对比片段误差结果

Fig.9 Pixel error of different methods on different curvatures图9 不同方法不同弯曲程度的像素误差对比图

6 总结

本文提出了一种利用局部纹理信息来检测与删除乐谱谱线的方法。实验结果表明本文方法在相同条件下效果优于其他方法,并且对于弯曲的乐谱也能很好地删除谱线。

[1]Rebelo A,Fujinaga I,Paszkiewicz F,et al.Optical music recognition:state-of-the-art and open issues[J].International Journal of Multimedia Information Retrieval,2012,1(3):173-190.

[2]Huang Feifei.Research on face recognition based on LBP operator[D].Chongqing:Chongqing University,2009.

[3]Bellini P,Bruno I,Nesi P.Optical music sheet segmentation[C]//Proceedings of the 1st International Conference on Web Delivering of Music,Florence,Italy,Nov 23-24,2001.Washington:IEEE Computer Society,2001:183-191.

[4]Pugin L.Optical music recognitoin of early typographic prints using hidden Markov models[C]//Proceedings of the 7th International Conference on Music Information Retrieval,Victoria,Canada,Oct 8-12,2006:53-56.

[5]Sheridan S,George S E,Sheridan S,et al.Defacing music score for improved recognition[C]//Proceedings of the 2nd Australian Undergraduate Students’Computing Conference,2004:1-7.

[6]Liu Xiaoxiang,Zhou Mi,Chen Shuangping.Key issues and solutions of optical music recognition[J].Computer Simulation,2015,32(7):253-258.

[7]Szwoch M.Guido:a musical score recognition system[C]//Proceedings of the 9th International Conference on Document Analysis and Recognition,Curitiba,Brazil,Sep 23-26,2007.Washington:IEEE Computer Society,2007:809-813.

[8]Chen Genfang,Zhang Liyin,Zhang Wenjun,et al.Detecting the staff-lines of musical score with Hough transform and mathematical morphology[C]//Proceedings of the 2010 International Conference on Multimedia Technology,Ningbo,China,Oct 29-31,2010.Piscataway,USA:IEEE,2010:443-446.

[9]Fujinaga I.Staff detection and removal[M]//George S E.Visual Perception of Music Notation:On-Line and Off Line Recognition.Hershey,USA:IGI Global,2004:1-39.

[10]Carter N P,Bacon R A.Automatic recognition of printed music[M]//Baird H S,Bunke H,Yamamoto K.Structured Document Image Analysis.Berlin,Heidelberg:Springer,1992:456-465.

[11]Miyao H,Okamoto M.Stave extraction for printed music scores using DP matching[J].Journal of Advanced Computational Intelligence and Intelligent Informatics,2004,8:208-215.

[12]Dos S C J,Capela A,Rebelo A,et al.Staff detection with stable paths[J].IEEE Transactions on Pattern Analysis and Machine Intelligence,2009,31(6):1134-1139.

[13]Dalitz C,Droettboom M,Pranzas B,et al.A comparative study of staff removal algorithms[J].IEEE Transactions on Pattern Analysis and Machine Intelligence,2008,30(5):753-766.

[14]Bainbridge D,Bell T C.Dealing with superimposed objects in optical music recognition[C]//Proceedings of the 6th International Conference on Image Processing and Its Applications,Dublin,Ireland,Jul 14-17,1997:756-760.

[15]Randriamahefa R,Cocquerez J P,Fluhr C,et al.Printed music recognition[C]//Proceedings of the 2nd International Conferenceon Document Analysis and Recognition,Tsukuba City,Japan,Oct 20-22,1993.Piscataway,USA:IEEE,1993:898-901.

[16]Martin P,Bellissant C.Low-level analysis of music drawing images[C]//Proceedings of the 1st International Conference on Document Analysis and Recognition,Saint-Malo,France,Sep 30-Oct 2,1991.Amsterdam:Elsevier Science Publishers,1991:417-425.

[17]Roach J W,Tatem J E.Using domain knowledge in low-level visual processing to interpret handwritten music:an experiment[J].Pattern Recognition,1988,21(1):33-44.

[18]Rebelo A,Cardoso J S.Staff line detection and removal in the grayscale domain[C]//Proceedings of the 12th International Conference on Document Analysis and Recognition,Washington,Aug 25-28,2013.Washington:IEEE Computer Society,2013:57-61.

[19]Montagner I D S,Hirata R,Hirata N S T.A machine learning based method for staff removal[C]//Proceedings of the 22nd International Conference on Pattern Recognition,Stockholm,Sweden,Aug 24-28,2014.Washington:IEEE Computer Society,2014:3162-3167.

[20]Calvo-Zaragoza J,Micó L,Oncina J.Music staff removal with supervised pixel classification[J].International Journal on DocumentAnalysis and Recognition,2016,19(3):211-219.

[21]Géraud T.A morphological method for music score staff removal[C]//Proceedings of the 21st International Conference on Image Processing,Paris,Oct 27-30,2014.Piscataway,USA:IEEE,2014:2599-2603.

[22]Montagner I S,Hirata R,Hirata N S T.Learning to remove staff lines from music score images[C]//Proceedings of the 2014 International Conference on Image Processing,Paris,Oct 27-30,2014.Piscataway,USA:IEEE,2014:2614-2618.

[23]Ojala T,Harwood I.A comparative study of texture measures with classification based on feature distributions[J].Pattern Recognition,1996,29(1):51-59.

[24]Ojala T,Pietikäinen M.Multiresolution gray-scale and rotation invariant texture classification with local binary patterns[J].IEEE Transactions on Pattern Analysis and Machine Intelligence,2002,24(7):971-987.

[25]Mao Song,Kanungo T.Empirical performance evaluation methodology and its application to page segmentation algorithms[J].IEEE Transactions on Pattern Analysis and Machine Intelligence,2001,23(3):242-256.

附中文参考文献:

[2]黄非非.基于LBP的人脸识别研究[D].重庆:重庆大学,2009.

[6]刘晓翔,周密,陈双平.乐谱识别关键技术问题及其解决方案[J].计算机仿真,2015,32(7):253-258.

Staff Detection and Removal Based on Local Binary Patterns*

MENG Fan'ao,LI Qiang,SHEN Yiting,GUAN Xin+

School of Electronic and Information Engineering,Tianjin University,Tianjin 300072,China

2016-08,Accepted 2016-12.

Staff detection and removal are important and fundamental stages in many optical music recognition(OMR)systems.In scores,staff lines cross or overlap with the majority of symbols,that is,the pixels belong to the staff lines pixels and also belong to the symbol pixels,so it is not easy to remove the staff lines not destroying the music symbol.The purpose is to remove the pixels that only belong to the staff lines.By observing the music image,it can be found that the local texture of the staff pixel is different from that of the non-staff pixel.The local texture of the staff pixel is related to the width of staff line,and the local texture of the non-staff pixel is not only related to its own situation,but also there is a situation associated with the intersection.Therefore,this paper uses the local binary pattern to extract the local texture feature,and obtains the difference of the local texture between the staff line pixel and the non-staff line pixel.Then this paper detects and classifies the pixels of staff line and non-staff line,and removes the staff line pixels.The method proposed in this paper can not only delete the music line under the ideal state,but also apply to the curve of the music score.And the experimental results show that the proposed method is better than the existing methods on pixel error and segment error.

staff detection and removal;optical music recognition;local texture feature

+Corresponding author:E-mail:guanxin@tju.edu.cn

10.3778/j.issn.1673-9418.1608085

*The National Natural Science Foundation of China under Grant Nos.61101225,60802049,61471263(国家自然科学基金);the Natural Science Foundation of Tianjin under Grant No.16JCZDJC31100(天津市自然科学基金).

CNKI网络优先出版:2016-12-21,http://www.cnki.net/kcms/detail/11.5602.TP.20161221.1128.004.html

MENG Fan'ao,LI Qiang,SHEN Yiting,et al.Staff detection and removal based on local binary patterns.Journal of Frontiers of Computer Science and Technology,2017,11(12):2015-2022.

A

TP391.4

MENG Fan'ao was born in 1991.He is an M.S.candidate at Tianjin University.His research interest is optical music recognition.

孟凡奥(1991—),男,安徽合肥人,天津大学人工智能实验室硕士研究生,主要研究领域为光学乐谱识别。

LI Qiang was born in 1974.He received the Ph.D.degree in signal and information processing from Tianjin University in 2003.Now he is a professor and Ph.D.supervisor at Tianjin University.His research interests include intelligence information processing,filter design,digital system and micro-system design,etc.

李锵(1974—),男,山西太原人,2003年于天津大学获得博士学位,现为天津大学教授、博士生导师,主要研究领域为智能信息处理,滤波器设计,数字系统和微系统设计等。

SHEN Yiting was born in 1994.She is an M.S.candidate at Tianjin University.Her research interest is digital image processing.

申一汀(1994—),女,陕西宝鸡人,天津大学硕士研究生,主要研究领域为数字图像处理。

GUAN Xin was born in 1977.She received the Ph.D.degree from Tianjin University in 2009.Now she is a lecturer at Tianjin University.Her research interests include music information retrieval,statistical learning and information processing,etc.

关欣(1977—),女,河北石家庄人,2009年于天津大学获得博士学位,现为天津大学讲师,主要研究领域为音乐信息检索,统计学习,信息处理等。

猜你喜欢

中心点乐谱谱线
山之高
是你一直想着我
基于HITRAN光谱数据库的合并谱线测温仿真研究
Scratch 3.9更新了什么?
乐谱:放飞梦想
如何设置造型中心点?
铁合金光谱谱线分离实验研究
一毛学琴记——乐谱失踪
锶原子光钟钟跃迁谱线探测中的程序控制
汉字艺术结构解析(二)中心点处笔画应紧奏