def image_displacement_to_defocus(dz, fno, wavelength=None):
    """Compute the wavefront defocus from image shift, expressed in the same units as the shift.

    Parameters
    ----------
    dz : `float` or `numpy.ndarray`
        displacement of the image
    fno : `float`
        f/# of the lens or system
    wavelength : `float`, optional
        wavelength of light, if None return has units the same as dz, else waves

    Returns
    -------
    `float`
        wavefront defocus, waves if Wavelength != None, else same units as dz

    """
    if wavelength is not None:
        return dz / (8 * fno ** 2 * wavelength)
    else:
        return dz / (8 * fno ** 2)