Exemple #1
0
def high_pass_median(numpy_arr, medscale):
    """Remove everything below 1/2 of the median
    value."""
    # remove noise
    median = numpy.median(numpy_arr)
    def hp(x, m):
        return 0 if x < m else x
    return numpy.vectorize(hp)(numpy_arr, median * medscale)
Exemple #2
0
def get_average_line_height(top_bottoms):
    """Tricksy - get height of median line?
    """
    lheights = [b - t for t, b in top_bottoms]
    lhm = numpy.max(lheights)
    def weight(val):
        return 0 if val < (lhm / 2) else 1
    weights = numpy.vectorize(weight)(lheights)
    return numpy.average(numpy.array(lheights), weights=weights)
def high_pass_median(numpy_arr, medscale):
    """Remove everything below 1/2 of the median
    value."""
    # remove noise
    median = numpy.median(numpy_arr)

    def hp(x, m):
        return 0 if x < m else x

    return numpy.vectorize(hp)(numpy_arr, median * medscale)
def get_average_line_height(top_bottoms):
    """Tricksy - get height of median line?
    """
    lheights = [b - t for t, b in top_bottoms]
    lhm = numpy.max(lheights)

    def weight(val):
        return 0 if val < (lhm / 2) else 1

    weights = numpy.vectorize(weight)(lheights)
    return numpy.average(numpy.array(lheights), weights=weights)