def RgbToHsv(RGB):
    """ Converts an integer RGB tuple (value range from 0 to 255) to an HSV tuple """
    # Unpack the tuple for readability
    R, G, B = RGB
    # Compute the H value by finding the maximum of the RGB values
    RGB_Max = max(RGB)
    RGB_Min = min(RGB)
    # Compute the value
    V = RGB_Max
    if V == 0:
        H = S = 0
        return (H,S,V)
    # Compute the saturation value
    S = 255 * (RGB_Max - RGB_Min) // V
    if S == 0:
        H = 0
        return (H, S, V)
    # Compute the Hue
    if RGB_Max == R:
        H = 0 + 43*(G - B)//(RGB_Max - RGB_Min)
    elif RGB_Max == G:
        H = 85 + 43*(B - R)//(RGB_Max - RGB_Min)
    else: # RGB_MAX == B
        H = 171 + 43*(R - G)//(RGB_Max - RGB_Min)
    return (H, S, V)