def ndbi(swir, red, nir, blue):
    """
    Converts the swir, red, nir and blue band of Landsat scene to a
    normalized difference bareness index.

    Source: Zao and Chen, "Use of Normalized Difference Bareness Index
    in Quickly Mapping Bare from TM/ETM+", IEEE Conference Paper, 2005
    DOI: 10.1109/IGARSS.2005.1526319

    :param swir: numpy.array, shortwave infrared band
    :param red: numpy.array, red band
    :param nir: numpy.array, near infrared band
    :param blue: numpy.array, blue band
    :return: normal difference bareness index
    """
    # bareness index components
    x = (swir + red) - (nir + blue)
    y = (swir + red) + (nir + blue)

    # prevent division by zero error
    y[y == 0.0] = 1.0

    # bareness index
    img = x / y

    img[y == 1.0] = 0.0

    # clip range to normal difference
    img[img < -1.0] = -1.0
    img[img > 1.0] = 1.0

    return img