1. A method for retrieving an electronic document in response to receipt of an image patch, the method comprising: receiving an image patch; defining a two-dimensional structure in the image patch; encoding the two-dimensional structure of the image patch into a first one-dimensional structure; searching, from a library, for a second one-dimensional structure that is similar to the first one-dimensional structure of the image patch; and retrieving the electronic document corresponding to the second one-dimensional structure similar to the first one-dimensional structure of the image patch from document storage.