def calculate_color_temperature(r, g, b):
    """Converts the raw R/G/B values to color temperature in degrees Kelvin."""
    X = -0.14282 * r + 1.54924 * g + -0.95641 * b
    Y = -0.32466 * r + 1.57837 * g + -0.73191 * b
    Z = -0.68202 * r + 0.77073 * g + 0.56332 * b
    if X + Y + Z == 0:
        return None
    xc = X / (X + Y + Z)
    yc = Y / (X + Y + Z)
    if 0.1858 - yc == 0:
        return None
    n = (xc - 0.332) / (0.1858 - yc)
    cct = 449.0 * n ** 3.0 + 3525.0 * n ** 2.0 + 6823.3 * n + 5520.33
    return int(cct)
