1. A method to classify an input image, comprising a. determining a spatial-pyramid image representation based on sparse coding; b. determining a descriptor for each interest point in the input image; c. encoding the descriptor; and d. applying max-pooling to form the spatial-pyramid image representation e. solving an unconstrained convex optimization problem min w c ⁢ { J ⁡ ( w c ) =  w c  2 + C ⁢ ∑ i = 1 n ⁢ ℓ ⁡ ( w c ; y i c , z i ) } where y i c =1 if y i =c, otherwise y i c =−1, and l(w c ;y i c , z i ) is a hinge loss function, where w is a data vector, z is test datum, C is a constant, and J is a cost function.