class StaffFinder_dalitz

Last modified: October 27, 2015

Contents

StaffFinder_dalitz

In module gamera.toolkits.musicstaves.stafffinder_dalitz

Finds staff lines with the aid of long quasi black run extraction and skeletonization.

The method works as follows:

  1. Extract long horizontal runs with an average blackness above a certain threshold. The resulting filaments are vertically thinned and among the resulting lines, those shorter than 2 * staffspace_height are removed.
  2. Vertically link line segments that overlap horizontally and have a vertical distance about staff_space_height + staff_line_height.
  3. Remove line segments without links and label the remaining segments with a staff and line label. Staffs are identified as connected components and line numbers are assinged based upon vertical link steps.
  4. "Melt" overlapping segments of the same staff line to one segment. This is done by selecting the segment that is closer to a least square fit of the total line.
  5. Remove staffs that have too few staff lines and remove additional staff lines on top of and below the staff.
    • If the number of lines in every staff is given: Get the shortest of the upper and lower line and remove it. Do this until the correct number of staff lines is reached.
    • If the number of lines is unknown: Remove every line in a staff that is much shorter than the maximum length in this staff.
  6. Remove staffline groups that overlap with other staffline groups. From all overlapping groups the widest is kept. Then join adjacent groups, whose distance is smaller then 2 * staffspace_height
  7. [Remove groups that are narrower than half the widest group.] This step has been removed!
  8. Interpolate between non-overlapping skeleton segments of the same staff line.
Authors:Christoph Dalitz, Thomas Karsten and Florian Pose

find_staves

Method for finding the staff lines.

Signature:

find_staves(num_lines=0, window=3, blackness=60, tolerance=25, align_edges=True, join_interrupted=True, debug=0)

with

  • num_lines:

    Number of lines per staff. If unknown, set to 0.

  • window and blackness:

    Parameters for the extraction of long horizontal runs. Only pixels are extracted that have an average blackness greater than blackness within a window of the width window * staff_space_height.

  • tolerance:

    The tolerance that is used while connecting line segments that belong to the same staff. They may have a vertical distance of staff_line_height + staff_space_height with a deviation of tolerance in percent.

  • align_edges:

    When True, staff line edges in a staff are aligned up to the left most and right most found staff line within this staff.

  • debug:

    0 = Be quiet. 1 = Show Progress messages. 2 = print images with prefix 'dalitzdebug' to current directory

This method fills the self.linelist attribute for further processing.