class MusicStaves

Last modified: October 27, 2015

Contents

MusicStaves

In module gamera.toolkits.musicstaves.musicstaves

Virtual class providing a unified interface to staff line removal from a music/tablature image and for querying the staff positions afterwards. For typical usage see the user's manual.

Note

This class cannot be used itself. You must use one of the derived classes which actually implement staff removal algorithms.

Author:Christoph Dalitz and Thomas Karsten

__init__

Constructor of MusicStaves. This base constructor should be called by all derived classes.

Signature:

__init__(image, staffline_height=0, staffspace_height=0)

with

image:
Onebit or greyscale image of which the staves are to be removed. MusicStaves creates a copy of the given image, so that the original image is not altered. The staff line removal will be done on MusicStaves.image
staffline_height:
average height of a single black staff line. When zero is given, MusicStaves computes it itself (recommended, unless you know exactly what you are doing).
staffspace_height:
average distance between adjacent lines of the same staff. When zero is given, MusicStaves computes it itself (recommended, unless you know exactly what you are doing).

remove_staves

Detects and removes staff lines from a music/tablature image.

This method is virtual and must be implemented in every derived class. Each implementation must at least support the following keyword arguments:

crossing_symbols:
Determines which symbols crossing staff lines the removal should try to keep intact. Possible values are 'all', 'bars' (only keeps long vertical lines uncut) or 'none' (does not care about crossing smyblos).
num_lines:
Number of lines within one staff. In general it can be hard to guess this number automatically; if the staff removal algorithm supports this, a value num_lines=0 can be used to indicate that this number should be guessed automatically.

Additional algorithm specific keyword are possible of course. If crossing_symbols cannot be chosen in the algorithm, this option must be offered nevertheless (albeit with no effect).

get_staffpos

Returns the y-positions of all staff lines at a given x-position. Can only be called after remove_staves.

This method is virtual and must be implemented in every derived class. Each implementation must have the following signature:

get_staffpos(x=0)

with

x:
x-position at which the staffpositions are computed. For x=0, the average y-positions over the full staffwidth is returned. A value differnt from zero only makes sense, when the staff removal algorithm supports skewed or otherwise deformed staff lines. For most algorithms the value of x will have no effect on the output.

The return value is a list of StaffObj.

blabla

Note

This interface for querying the staffposition is not not too suitable for OMR applications. Consequently a better interface (e.g. returning a stafffinder object or parts thereof) will be implemented in the future.

Consequently this interface is deprecated and you are advised to directly copy the staff positions from the appropriate member variables described in the documentation of the derived classes in case you need the positions for further OMR processing.