A Hidden Markov Contour Tree Model for Spatial Structured Prediction