Probabilistic matching of planar shapes