def _uvw_scale_bias(image_parameters, grid_parameters):
    """Compute scale and bias values to turn UVW indices back into coordinates.

    The :mod:`preprocess` module quantises UVW coordinates; the values computed
    by this function can be used to convert them back to coordinates in
    wavelengths. Given quantised UV with grid cell :math:`g` and subpixel `s`,
    and W plane of :math:`w_p` in a W slice with centre :math:`w_0` wavelengths,
    the coordinates in wavelengths are

    .. math::

       uv &= uv_{scale}(oversample\\cdot g + s + 0.5)\\\\
       w &= w_0 + w_{scale}w_p + w_bias
    """
    ip = image_parameters
    gp = grid_parameters
    uv_scale = ip.cell_size / gp.oversample
    w_scale = gp.max_w / ((gp.w_slices - 0.5) * gp.w_planes)
    uv_scale = float(uv_scale / ip.wavelength)
    w_scale = float(w_scale / ip.wavelength)
    w_bias = (0.5 - 0.5 * gp.w_planes) * w_scale
    return uv_scale, w_scale, w_bias
