This script demonstrates the influence of range reduction algorithm at low bitrate encoding using JPEG encode. The range [0-255] of pixel values is mapped to [64-235] in this script using a look-up-table. Subsequently, the file is compressed to achieve the same bit-rate (file size) as that of the compressed full range image. (The quality factor chosen may need adjustment if changing the input image.) The compressed files are uncompressed for quality comparison. In case of range reduction, the range is restored back on uncompression. SSIM is used for quality metrics.
The effect of range reduction is to increase spatial correlation of neighborhood pixels and thereby improving compression ratio.