class StaffFinder_miyao

Last modified: October 27, 2015

Contents

StaffFinder_miyao

In module gamera.toolkits.musicstaves.stafffinder_miyao

This staff finding algorithm is a based on a paper by H. Miyao (see below).

The method as described by Miyao:

  1. Find stave candidate points on equally spaced vertical scan lines
  2. Use Dynamic Programming Matching to link stave candidate points
  3. Link points vertically and identify stave groups as connected components
  4. Adjust the edge point positions

Deviations from Miyao's method by Dalitz:

Limitations:

References:

Note that the first two references are almost identical, with the second somewhat more detailed.

Author:Christoph Dalitz (after an algorithm by H. Miyao)

find_staves

Finds staff lines from a music/tablature image with Miyao's method.

Signature:

find_staves(num_lines=0, scanlines=20, blackness=0.8, tolerance=-1, debug=0)

with

num_lines:
Number of lines within one staff. When zero, the number is automatically detected.
scan_lines:
Number of vertical scan lines for extracting candidate points.
blackness:
Required blackness on the connection line between two candidate points in order to consider them matching.
tolerance:
How much the vertical black runlength of a candidate point may deviate from staffline_height. When negative, this value is set to max([2, staffline_height / 4]).
debug:
When > 0, information about each step is printed to stdout (flushed immediately). When > 1, runtime information is printed. When > 2, the information about some steps is more detailed. When > 3, a number of images is written into the current working directory; the image names have the prefix miyaodebug.