How is length normalization done for images done in R




While trying to solve the Handwritten digit recognizer problem in R I read about length normalization as a way to reduce the feature space.In the Kaggle problem:

Each image is 28 pixels in height and 28 pixels in width, for a total of 784 pixels in total. Each pixel has a single pixel-value associated with it, indicating the lightness or darkness of that pixel, with higher numbers meaning darker. This pixel-value is an integer between 0 and 255, inclusive.

The training data set, (train.csv), has 785 columns. The first column, called “label”, is the digit that was drawn by the user. The rest of the columns contain the pixel-values of the associated image.
In a research paper related to image recognition I came across:

This method of length normalization will help in reducing the feature space from 784 to 400 which will ultimately result in the algorithms converging faster.
How can this be achieved in R?Can someone please help me on this??r