In external beam radiotherapy, portal imaging is applied for verification of the patient setup. Current automatic methods for portal image registration, which are often based on segmentation of anatomical structures, are especially successful for images of the pelvic region. For portal images of more complicated anatomical structures, e.g., lung, these techniques are less successful. It is desirable to have a method for image registration that is applicable for a wide range of treatment sites. In this study, a registration method for two-dimensional (2D) registration of portal and reference images based on intensity values was tested on portal images of various anatomical sites. Tests were performed with and without preprocessing (unsharp mask filtering followed by histogram equalization) for 96 image pairs and six cost functions. The images were obtained from treatments of the rectum, salivary gland, brain, prostate, and lung. To get insight into the behavior of the various cost functions, cost function values were computed for each portal image for 20,000 transformations of the corresponding reference image, translating the reference image in a range of +/- 1 cm and rotating +/- 10 degrees with respect to the clinical match. The automatic match was defined as the transformation associated with the global minimum (found by an exhaustive search). Without preprocessing, the registration reliability was low (less than 27%). With preprocessing, about 90% of the matches were successful, with a difference with our gold standard (manual registration) of about 1 mm and 1 degree SD. All tested cost functions performed similarly. However, the number of local minima using mutual information was larger than for the other tested cost functions. A cost function based on the mean product of the corresponding pixel values had the least number of local minima. In conclusion, gray value based registration of portal images is applicable for a wide range of treatment sites. However, pre-processing of the images is essential.