Skeleton-Based Generative Model for Shape and Its Applications to Object Recognition and Segmentation