I don't know what is the term for this, but what get the closest to it is the process of contrasting an image.
Basically i have a list of values going from 0 to 100. I would like that values over 50 come closer to 100 and values under 50 come closer to 0.
for example :
[0, 23, 50,58,100]
would become something like this (roughly) :
[0, 10, 50, 69, 100]
is their a mathematic formula for this ?
CodePudding user response:
The following code might give you some ideas. If it doesn't meet your needs then you need to clearly explain just what those needs are.
def contrast(nums):
contrasted = []
for num in nums:
if num < 50:
contrasted.append(num//2)
elif num > 50:
contrasted.append((num 100)//2)
else:
contrasted.append(num)
return contrasted
data = [0, 23, 50,58,100]
print(contrast(data))
Output: [0, 11, 50, 79, 100]