def LinearGainLine(x1,y1,x2,y2):
    """
    returns tuple (m,b)
    that satisfies the equation y=mx+b

    uses two points in histogram space to determine slope
    x : 0..nbins
    y : 0..255
    """
    if (x2 > x1):
        m = -(y1-y2) / (x2-x1)
    else:
        m = 0
    b  = x1
    return m,b