Last modified: February 17, 2010
In module gamera.toolkits.psaltiki.psaltiki_page
Performs layout analysis on a psaltiki page.
Important properties that are computed in the constructor:
Constructs and returns a PsaltikiPage object. Signature:
__init__(image, oligon_height=0, oligon_width=0)
with
- image:
- Onebit or greyscale image of psaltiki music. Is copied to self.image.
- oligon_height, oligon_width:
- Vertical thickness and horizontal width of an oligon. When left zero, it will be computed automatically from the image.
Returns a onebit copy of self.image containing only CCs with a ratio width/height >= 3.
Finds the baselines in an image and returns them in a list. Signature:
find_baselines(classified_ccs=None)
Baselines are detected as maxima in the horizontal projection profile of a filtered image. When classified_ccs are not None, the filter only keeps CCs with a class name containing the keyword baseline. When it is not provided, the filter only keeps wide CCs (width/height >= 3).
Removes all lyrics from self.image. Signature:
remove_lyrics(classified_ccs=None, debug=0, headline=False)
Parameters:
- classified_ccs:
When not given (or set to None), the lyrics removal is done purely rule based.
When provided, it must contain a list of classified glyphs with potential lyrics candidates classified as lyrics. As lyric glyphs can also appear within teh neumes, a classification as lyrics does not necessarily imply a removal.
- headline:
- When headline is True, headlines will be removed either. Headlines may be titles over the first baseline or when the distance between two baselines is large (greater than 1.5 times median of the baseline distance) there may be more than one textline. These textlines will be removed, when the number of horizontal black pixels is more than oligon_width/2.
Returns an RGB image showing the occurence of the characteristic dimensions oligon_height and oligon_width.
All CCs with a width of oligon_width are marked in red. Vertical black runs of length oligon_height are will be marked in green. When both criterions are fulfilled the overlapping pixels will be yellow.
Estimates the oligon height (pen stroke thickness) and width.
The values are estimated on a filtered image in which CCs with a ratio width/height < 3 are removed as follows:
- oligon_height = most frequent black vertical runlength
- oligon_width = median of CC width
The output is a list [oligon_width, oligon_height]. When no CC is left after filtering, [0,0] is returned.