A new approach to align an image of a medical object with a given prototype is proposed. Visual appearance of the images, after equalizing their signals, is modelled with a new Markov-Gibbs random field with pairwise interaction model. Similarity to the prototype is measured by a Gibbs energy of signal co-occurrences in a characteristic subset of pixel pairs derived automatically from the prototype. An object is aligned by an affine transformation maximizing the similarity by using an automatic initialization followed by gradient search. Experiments confirm that our approach aligns complex objects better than popular conventional algorithms.