Although two-dimensional principal component analysis (2DPCA) extracts image features directly from 2D image matrices rather than one dimensional vectors, 2DPCA is only based on the whole images to preserve total variances by maximizing the trace of feature covariance matrix. Thus, 2DPCA cannot extract localized components, which are usually important for face recognition. Inspired by nonnegative matrix factorization (NMF), which is based on localized features, we propose a novel algorithm for face recognition called two-dimensional nonnegative principal component analysis (2DNPCA) to extract localized components and maintain the maximal variance property of 2DPCA. 2DNPCA is a matrix-based algorithm to preserve the local structure of facial images and has the nonnegative constraint to learn localized components. Therefore, 2DNPCA has both advantages of 2DPCA and NMF. Furthermore, 2DNPCA solves the time-consuming problem by removing the restriction of minimizing the cost function and extracting only the base matrix. The nearest neighbor (NN) classifier and linear regression (LR) classifier are used for classification and extensive experimental results show that 2DNPCA plus NN and 2DNPCA plus LR are both very efficient approaches for face recognition.