# why multiply grayscale images by 256

I am a newbie in image processing. in an open source code for convolution neural networks, the author is multiplying a gray scale image from MNIST dataset by 256. Please can any one tell me why?

ADDITION: the greyscale images have a max value of 0.8681 and a min of -0.1319

Many thanks.

• This can't be answered without very much more context. Generally: it's just a scaling, so ignore it for processing? Often, things like that are done because e.g. some file format has 8 bit integer width, but in your case, you'd actually need 9 bit (because the sign requires one bit, too). Again, context is necessary. Jul 9 '18 at 6:11
• This data was first normalized by subtracting ts mean, but later he multiplied it by 256. i did not think of rescaling because he already normalized the dataset. The code is not my so that is all i know about the context. thanks Marcus Jul 9 '18 at 6:33
• Do you think you could provide a slightly more elaborate answer to the question and accept it, or, perhaps consider deleting the question if you think it is not valid anymore?
– A_A
Jul 9 '18 at 6:57
• A_A, unfortunately that is all I have nothing to elaborate, I got this from a code and there was no comment about it. the context is very clear. It is used in convolution neural networks (machine learning) training. The images are multiplied with 256 before they are fed to the network for training. I cant see what more information is needed. Jul 9 '18 at 7:25

Grayscale images are typically stored as 8 bits per pixel in files. Perhaps the network was trained to work with such data. $2^8 = 256,$ so 8 bits can represent any number from 0 to 255. It may well be that the author was converting from range $[0, 1]$ to $[0, 255]$. Note that $0.8681 - (-0.1319) = 1.$ Multiplying by 255 to stay within the range would have been more appropriate, but multiplying by 256 is appealing because it does not introduce any rounding error in finite precision floating point arithmetic.