from gamera.core import *
import numpy as np

init_gamera()
image = load_image('C:/Users/Radim/OneDrive/Documents/Projects/notes/OMRnotes/tests/notes/notateme52.png')
imgbin = image.djvu_threshold(0.2, 512, 64, 2)
angle, rotation_angle_and_accuracy1 = imgbin.rotation_angle_projections(-2.5, 2.5, 0.0)
imgrot = image.rotate(angle, None, 1)
imgbinrot = imgrot.djvu_threshold(0.2, 512, 64, 2)
musicstaves0 = imgbinrot.MusicStaves_linetracking(staffline_height=0, staffspace_height=0)
scale = (20 / float(musicstaves0.staffspace_height + musicstaves0.staffline_height))
imgscale = imgrot.scale(scale, 0)
imgbinscale = imgscale.djvu_threshold(0.2, 512, 64, 2)
musicstaves1 = imgbinscale.MusicStaves_linetracking(staffline_height=0, staffspace_height=0)
musicstaves1.remove_staves(u'all', 5, u'runlength', 0, 0)
musicstaves1_image0 = musicstaves1.image.image_copy()

musicstaves1_image0.save_PNG("pre.png")