Semantic image segmentation with a multi-dimensional Hidden Markov Model