Connecting Markov Randm Fields and Active Contour Models: Application to Gland Segmentation and Classification