def norm_range(vec, lower=0, upper=255, type=int):
    """
    clips vector to range [lower, upper] and a tuple with integers

    :param vec: vector
    :param lower: 0
    :param upper: 255
    :param type: int
    :return:
    """
    newvec = []
    upper = type(upper)
    lower = type(lower)
    for i in vec:
        if i > upper:
            newvec.append(upper)
        elif i < lower:
            newvec.append(lower)
        else:
            newvec.append(type(i))
    return tuple(newvec)
