1. A computer-implemented method comprising: receiving a spatial feature descriptor representing a binary string of comparison results between specified pairings of N patches in a region of an image, N being an integer greater than one; and compressing the spatial feature descriptor by: determining a minimum number of bits needed to represent N−1; and generating a sorted array representing a ranking of the N patches based on the binary string of comparison results, each element of the sorted array associated with a corresponding patch of the N patches and storing a value representing a ranking of the patch relative to other patches of the N patches, wherein the value is coded and has a number of bits based on a position of the corresponding element in the sorted array, and wherein the number of bits in the value is less than or equal to the minimum number of bits needed to represent N−1.