1. A method to process an image having a plurality of pixels, comprising: capturing an image using an image sensor; forming a first-layer to encode local patches on an image region; forming a second layer to jointly encode patches from the image region; and determining 1 n ⁢  X - BW  F 2 + λ 2 n ⁢ ∑ s , t ⁢ tr ⁡ ( S ⁡ ( W ( s , t ) ) ⁢ Ω ( s , t ) ⁡ ( α ) ) where Ω ( s , t ) ⁡ ( α ) ≡ ( ∑ k = 1 q ⁢ α k ⁡ ( ϕ k ( s , t ) ) ) - 1 is an inverse diagonal covariance for an (s,t)-th region, s=1,2, t=1,2, X is a set of image patches in a local region and X and W denote all 4×n patches and their first-layer codes in these 4 regions for a fixed α, φ is a basis describing a a spatial co-occurrence pattern, B is a codebook, log-likelihood of W is tr (S(W)Ω(α)), λ 2 is a sparsely regulation parameter.