1. A method comprising: extracting one or more target patterns from a portion of an image; forming a pattern matrix based on the one or more target patterns; approximating the pattern matrix using a complexity-regularized representation derived from the pattern matrix; and sending a query to search a library of images for vectors in the query to detect, using the complexity-regularized representation, any image in the library that contains image patches similar to the one or more target patterns.