This link is to a 3rd-party but faithful and improved implementation of the CVPR 12 paper "Computing Nearest-Neighbor Fields via Propagation-Assisted KD-Trees".