class StaffFinder_projections

Last modified: October 27, 2015

Contents

StaffFinder_projections

In module gamera.toolkits.musicstaves.stafffinder_projections

Finds staff lines as maxima in the y projection profile.

The process is as follows:

  1. Optionally, the image is preprocessed in order to remove stuff "irrelevant" for staff line finding (eg. short black runs)

  2. The horizontal projection profile is computed and lowpass filtered with an averaging kernel of width staffspace_height. In this filtered profile, staff breaks are seeked as minima below a certain (hard coded) threshold.

    Per estimated staff system, a local threshold for accepting maxima in step 3) is set as a (choosable) fraction of the maximum projection value per estimated staff system. Apart from setting the local threshold values, the estimated staff breaks have no further effect on the algorithm.

  3. The original projection profile is lowpass filtered with an averaging kernel of width staffline_height. All maxima above the threshold from step 2) are computed. These peaks are grouped into staff systems based upon their distance.

  4. In each staff system, peaks lying on a grid with distance about staffspace_height are detected. As reference peak the highest peak in the staff system is chosen.

  5. Step 4) typically results in more or less than num_lines peaks. Staff systems with less peaks are removed, staff systems with more peaks are reduced to num_lines peaks by removing the lowest edge peaks.

    If num_lines is not given, it is computed as the maximum in the lines-per-staff histogram.

The horizontal edge points are found by scanning the vertical projection profile from the left resp. right until a projetion value larger than staffline_height is found. Note that this fails when the image contains black borders from the scanning process; in that case use the preprocessing plugin remove_border from the gamera core.

Author:Christoph Dalitz

find_staves

Finds staff lines from a music/tablature image with the aid of y projections. Signature:

find_staves(num_lines=0, peakthreshold=0.0, preprocessing=1, postcorrect=True, debug=0)

with

num_lines:
Number of lines within one staff. When zero, the number is automatically detected.
peakthreshold:
Threshold factor (relative to maximum projection value within a stave group) for accepting peaks. When zero, it is set automatically, depending on the chosen preprocessing (see next parameter).
preprocessing:
Whether the image should be prepared in such a way that "obvious" non staff segments should be removed. Possible values: 0: no preprocessing 1: extract filled horizontal runs 2: filter short horizontal black runs
postcorrect:
When True, the number of lines per staff is automatically adjusted to the num_lines.
follow_wobble:
When True, each staffline is postprocessed with follow_staffwobble for a (hopefully) more accurate representation.
debug:
When > 0, information about each step is printed to stdout (flushed immediately). When > 1, a number of images and datafiles are written into the current working directory; file names have the prefix projdebug. For the datafiles a gnuplot command file projdebug.plot is written.