1. A method for generating an image representation comprising: generating a set of embedded patch descriptors, comprising, for each of a set of patches of an image, extracting a patch descriptor which is representative of the pixels in the patch; and embedding the patch descriptor in a multidimensional space to form an embedded patch descriptor; generating an image representation comprising aggregating the set of embedded patch descriptors, wherein in the aggregation, each patch descriptor is weighted with a respective weight in a set of weights, the set of weights being computed based on the extracted patch descriptors for the image, wherein the generating of the image representation comprises identifying an image representation that optimizes the probability that when a matrix of the embedded patch descriptors is multiplied by the image representation, the result is a vector in which each element of the vector has a constant same value, the optimization including identifying an image representation Ψ that minimizes the expression ∥Φ T Ψ−c M ∥ 2 +λ∥Ψ∥ 2 , where Φ is a D×M matrix that contains the D-dimensional patch embeddings, c M is the vector in which all values are the same, and λ represents a non-zero regularization parameter; and outputting information based on the image representation, wherein at least one of the extracting of the patch descriptors, embedding of the patch descriptors, generating the image representation, and outputting information is performed with a computer processor.