def eqtype(I, J):
    """
    Ensure that `I` and `J` have the same NumPy type.

    If both images have the same type, returns the type name as string.
    Otherwise, a `ValueError` is raised.
    """

    if I.dtype != J.dtype:
        raise ValueError("Images have different NumPy types ('{}', '{}')".format(I.dtype, J.dtype))
    else:
        return I.dtype