If I have a series of pixels, which range from say -500 to +1000, how would I normalize all the pixels on the same gradient so that they fall between a specific range, say 0
foreach( pixel_value in pixel_values): # between -500 and 1000
position = (pixel_value + 500) / 1500 # gives you a 0 to 1 decimal
new_value = int(postion * 255) # or instead of casting, you could round it off