Linearly transform image data

What kind of transformation would linearly map an RGB image with values in [0,256] linearly to values in [-1,1]?

I’m not sure, if that’s what you are looking for, but this should work:

x = torch.arange(0, 256).float()
x /= x.max() / 2. 
x -=1
x.min() # tensor(-1.)
x.max() # tensor(1.)