Weighted finite automatas using spectral methods for computer vision