0
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ 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. $\endgroup$ Jul 9 '18 at 6:11
  • $\begingroup$ 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 $\endgroup$
    – O'noel
    Jul 9 '18 at 6:33
  • $\begingroup$ 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? $\endgroup$
    – A_A
    Jul 9 '18 at 6:57
  • $\begingroup$ 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. $\endgroup$
    – O'noel
    Jul 9 '18 at 7:25
1
$\begingroup$

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.

Subtracting the mean does not change the story as it can be equivalently done before or after the multiplication.

$\endgroup$
1
  • $\begingroup$ Thanks a lot Olli Niemitalo. your answer is more close to why the author had done that. hence I will accept it. $\endgroup$
    – O'noel
    Jul 9 '18 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.