def threshad(f, f1, f2=None):
    """
    y = threshad(f, f1, f2=None)

    Threshold (adaptive)

    `threshad` creates the image y as the threshold of the image f
    by the images `f1` and `f2`. A pixel in `y` has the value 1 when the
    value of the corresponding pixel in `f` is between the values of
    the corresponding pixels in `f1` and `f2`.

    Parameters
    ----------
    f :  Gray-scale (uint8 or uint16) image.
    f1 : Lower value.
    f2 : Upper value.

    Returns
    -------
    y : Binary image.
    """

    if f2 is None:
        return f1 <= f
    return (f1 <= f) & (f <= f2)