Jan-31-2023, 02:41 AM
Hello everyone,
I have to agree that I am not great at coding and math but this forum has helped me a lot before and come seeking your help once again.
Let's say I have a multi dimensional array "a" with numbers ranging from -256 to 256. Not necessary the min and max value in that array will be at positive or negative 256.
I normalize this array between the range of 0 to 255 (unsigned 8 bit integer) using:
I know there will be some resolution loss, but I am okay with it.
Respectfully,
PythonNPC.
I have to agree that I am not great at coding and math but this forum has helped me a lot before and come seeking your help once again.
Let's say I have a multi dimensional array "a" with numbers ranging from -256 to 256. Not necessary the min and max value in that array will be at positive or negative 256.
I normalize this array between the range of 0 to 255 (unsigned 8 bit integer) using:
c = (255*(a - np.min(a))/np.ptp(a)).astype(int)Or I can normalize between -128 to 127 (signed 8 bit integer using:
l, u = np.amin(a), np.amax(a) ints = np.rint((a- l) * (255 / (u - l))) - 127My question is, if I know the original min and max values of the array "a", how can I expand it back to those min and max values?
I know there will be some resolution loss, but I am okay with it.
Respectfully,
PythonNPC.