In the article two problems of structure segmentation were investigated: the problem of finding facades of buildings on photos and the problem of finding cars against the backdrop of buildings. For these problems formal conditions and solutions were proposed. A picture and a segmentation are seen as random variables, and the desired segmentation is the most probable. Algorithms for finding the optimal segmentation for these problems were presented.