Read Should you normalize RGB values by 255 or 256?
Read Should you normalize RGB values by 255 or 256? about two common apprroaches:
Standard division by 255
pixels = img / 255.0
result = process(pixels)
output = np.trunc(result * 255 + 0.5)
Alternative division by 256
pixels = (img + 0.5) / 256.0
result = process(pixels)
output = np.trunc(result * 256)