PurposeInsufficient image contrast associated with radiation therapy daily setup x‐ray images could negatively affect accurate patient treatment setup. We developed a method to perform automatic and user‐independent contrast enhancement on 2D kilo voltage (kV) and megavoltage (MV) x‐ray images. The goal was to provide tissue contrast optimized for each treatment site in order to support accurate patient daily treatment setup and the subsequent offline review.MethodsThe proposed method processes the 2D x‐ray images with an optimized image processing filter chain, which consists of a noise reduction filter and a high‐pass filter followed by a contrast limited adaptive histogram equalization (CLAHE) filter. The most important innovation is to optimize the image processing parameters automatically to determine the required image contrast settings per disease site and imaging modality. Three major parameters controlling the image processing chain, i.e., the Gaussian smoothing weighting factor for the high‐pass filter, the block size, and the clip limiting parameter for the CLAHE filter, were determined automatically using an interior‐point constrained optimization algorithm.ResultsFifty‐two kV and MV x‐ray images were included in this study. The results were manually evaluated and ranked with scores from 1 (worst, unacceptable) to 5 (significantly better than adequate and visually praise worthy) by physicians and physicists. The average scores for the images processed by the proposed method, the CLAHE, and the best window‐level adjustment were 3.92, 2.83, and 2.27, respectively. The percentage of the processed images received a score of 5 were 48, 29, and 18%, respectively.ConclusionThe proposed method is able to outperform the standard image contrast adjustment procedures that are currently used in the commercial clinical systems. When the proposed method is implemented in the clinical systems as an automatic image processing filter, it could be useful for allowing quicker and potentially more accurate treatment setup and facilitating the subsequent offline review and verification.