I'm working on a program that lets the user draw a digit in a "scribbling area" and with the press of a button the application will predict the digit that he entered, using a neural net classifier.
Now, to train the neural net, I used MNIST database which specifies the following: "images from NIST were size normalized to fit in a 20x20 pixel box while preserving their aspect ratio [...] the images were centered in a 28 x 28 image by computing the center of mass of the pixels".
The problem that I'm facing is that after resizing the digit that the user drew in the scribbling area to a size of 20 x 20, I need to compute the center of mass of the pixels so I can center it in the middle of the 28 x 28 image.
How can I compute that ?