def to_uint8(f):
    """
    img = to_uint8(f)

    Convert an image to an uint8 image.

    `to_uint8` clips the input image between the values 0 and 255 and
    converts it to the unsigned 8-bit datatype.

    Parameters
    ----------
    f : Any image

    Returns
    -------
    img : Gray-scale uint8 image. The converted image

    Examples
    --------
    ::

        print to_uint8([-3, 0, 8, 600])

    prints out

    ::

        [  0   0   8 255]
    """
    from numpy import array, clip, uint8
    img = array(clip(f, 0, 255), uint8)
    return img
