class TabPage

Last modified: May 13, 2016

Contents

TabPage

In module gamera.toolkits.otr.otr_staff

Stores a tablature and its information (e.g. staff position).

An object of this class provides the following functionality:

Note

The removal of the staff lines is done by the inherited MusicStaves object. Thus, the MusicStaves toolkit is required.

A TabPage object has several public properties, that can be manipulated by the user. The following table gives a detailed view on this.

music_staves The inherited MusicStaves object.
image A reference to music_staves.image (for convenience).
staffline_height A reference to music_staves.staffline_height
staffspace_height A reference to music_staves.staffspace_height
on_lines Determines the position of the symbols (see the constructor for details).
tab_type Determines the type of the tablature (see the constructor for details).
num_lines The number of lines per staff. (only set after remove_staves).
Author:Christoph Dalitz and Thomas Karsten

__init__

Constructs and returns a TabPage object.

Signature:

__init__(image, online=0, tab_type='french', staffline_height=0, staffspace_height=0)

with

image:
Onebit or greyscale image a TabPage should be created of.
online:
Determines the position of the glyphs in a staff. When online is set to 1 the tab symbols are supposed to be on the staff lines. A value of 0 indicates that the tab symbols are located between the staff lines.
tab_type:
Classifies the type of the tablature. Possible values are french and italian.
staffline_height:
Vertical thickness of a staff line. When not specified here, it will be detected automatically.
staffspace_height:
Thickness of the vertical space between adjacent staff lines. When not specified here, it will be detected automatically.

remove_staves

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

Signature:

remove_staves(crossing_symbols='auto', num_lines=0)

with

crossing_symbols:
Determines which symbols crossing staff lines the removal should try to keep intact. In addition to the possible values are all, bars and none (see the MusicStaves module for details), the value auto is supported for a setting based upon onlines.
num_lines:
Number of lines within one staff. A value of zero means, that this number should be guessed automatically.

get_staffcourse

Returns the two values [Int staff, Int course] for a symbol at position (x, y). Both staff and course are counted from top to bottom, starting with 1 each. Symbols that are above the first course (e.g. flags) get the course number 0. An empty array [] is returned, when (x, y) is out of range.

Signature:

get_staffcourse(x, y)

with

(x, y):
x- and y-position of the symbol to query.

get_staffboxes

Returns a list of rectangular bounding boxes, that contains a bounding box for each staff.

Signature:

get_staffboxes(tightness=1)

with

tightness:
Controls the y-borderwidth around the staff. The output of this function for the two possible values 0 and 1 can be seen in the image below.

If there are n tablature systems on the page, a sequence of n objects with the properties x, y, nrows and ncols are returned. These properties describe the tablature system rectangular bounding box (dependent of the value of tightness) as shown in the figure below.

images/staffboxes.png

remove_barlines

Removes bar lines from a music/tablature image and returns them as a list of Cc's. the returned Cc's are classified heuristically as "bar".

Signature:

remove_barlines()

Bar line candidates are built from filaments of short horizontal runlength by a number of heuristic rules. As these rules make use of the staffline positions, this method can only be called after remove_staves.

As the bar lines are removed from tab.image, the returned Cc's point to a different image (Python's garbage collector will take care of keeping or deleting this image as necessary).