Graphical models for segmenting images, volumes and videos