def datatype(f):
    """
    type = datatype(f)

    Return the image datatype string

    datatype returns a string that identifies the pixel datatype
    of the image `f`.

    Consider using f.dtype.

    Parameters
    ----------
    f : Unsigned gray-scale (uint8 or uint16), signed (int32) or binary image
        Any image

    Returns
    -------
    type : str
        String representation of image type: 'binary',
        'uint8', 'uint16' or 'int32'
    """
    from numpy import bool, uint8, uint16, int32
    code = f.dtype
    if code == bool:
        type = 'binary'
    elif code == uint8:
        type = 'uint8'
    elif code == uint16:
        type = 'uint16'
    elif code == int32:
        type = 'int32'
    else:
        assert 0, 'Does not accept this typecode: %s' % code
    return type
