# Path: moonlight/staves/base.py
# class BaseStaffDetector(object):
# class ComputedStaves(BaseStaffDetector):
#   def __init__(self, image=None):
#   def data(self):
#   def staves_interpolated_y(self):
#     def _get_staff_center_line_y(staff):
#       def loop_body(i, ys_array):
#   def compute(self, session=None, feed_dict=None):
#   def __init__(self, staves, staffline_distance, staffline_thickness,
#                staves_interpolated_y):
#   def staves_interpolated_y(self):
#   def compute(self, session=None, feed_dict=None):
# 
# Path: moonlight/util/memoize.py
# class MemoizedFunction(object):
#   def __init__(self, function):
#   def __call__(self, *args):


import numpy as np
import scipy.ndimage
import tensorflow as tf
from moonlight.staves import base
from moonlight.util import memoize
  Detects peaks in the number of black pixels in each row, which should
  correspond to staff lines.
  """
  staves_tensor = None
  staffline_distance_tensor = None

  def __init__(self, image=None):
    super(ProjectionStaffDetector, self).__init__(image)
    projection = tf.reduce_sum(tf.cast(self.image <= 127, tf.int32), 1)
    width = tf.shape(self.image)[1]
    min_num_dark_pixels = width // 2
    staff_lines = projection > min_num_dark_pixels
    staves, staffline_distance, staffline_thickness = tf.py_func(
        _projection_to_staves, [staff_lines, width],
        [tf.int32, tf.int32, tf.int32])
    self.staves_tensor = staves
    self.staffline_distance_tensor = staffline_distance
    self.staffline_thickness_tensor = staffline_thickness

  @property
  @memoize.MemoizedFunction
  def staves(self):
    return self.staves_tensor

  @property
  @memoize.MemoizedFunction
  def staffline_distance(self):
    return self.staffline_distance_tensor

  @property

# Path: moonlight/staves/base.py
# class BaseStaffDetector(object):
# class ComputedStaves(BaseStaffDetector):
#   def __init__(self, image=None):
#   def data(self):
#   def staves_interpolated_y(self):
#     def _get_staff_center_line_y(staff):
#       def loop_body(i, ys_array):
#   def compute(self, session=None, feed_dict=None):
#   def __init__(self, staves, staffline_distance, staffline_thickness,
#                staves_interpolated_y):
#   def staves_interpolated_y(self):
#   def compute(self, session=None, feed_dict=None):
# 
# Path: moonlight/util/memoize.py
# class MemoizedFunction(object):
#   def __init__(self, function):
#   def __call__(self, *args):


# Path: moonlight/staves/projection.py
import numpy as np
import scipy.ndimage
import tensorflow as tf
from moonlight.staves import base
from moonlight.util import memoize

  Detects peaks in the number of black pixels in each row, which should
  correspond to staff lines.
  """
  staves_tensor = None
  staffline_distance_tensor = None

  def __init__(self, image=None):
    super(ProjectionStaffDetector, self).__init__(image)
    projection = tf.reduce_sum(tf.cast(self.image <= 127, tf.int32), 1)
    width = tf.shape(self.image)[1]
    min_num_dark_pixels = width // 2
    staff_lines = projection > min_num_dark_pixels
    staves, staffline_distance, staffline_thickness = tf.py_func(
        _projection_to_staves, [staff_lines, width],
        [tf.int32, tf.int32, tf.int32])
    self.staves_tensor = staves
    self.staffline_distance_tensor = staffline_distance
    self.staffline_thickness_tensor = staffline_thickness

  @property
  @memoize.MemoizedFunction
  def staves(self):
    return self.staves_tensor

  @property
  @memoize.MemoizedFunction
  def staffline_distance(self):
    return self.staffline_distance_tensor

  @property

  @memoize.MemoizedFunction