I considered that, but I chose this way so that I can use this preprocessing on CIFAR10, MNIST, and other datasets in pylearn2 that inherit from DenseDesignMatrix.