Accurate knowledge of defocus and tilt parameters is essential for the determination of three-dimensional protein structures at high resolution using electron microscopy. We present two computer programs, CTFFIND3 and CTFTILT, which determine defocus parameters from images of untilted specimens, as well as defocus and tilt parameters from images of tilted specimens, respectively. Both programs use a simple algorithm that fits the amplitude modulations visible in a power spectrum with a calculated contrast transfer function (CTF). The background present in the power spectrum is calculated using a low-pass filter. The background is then subtracted from the original power spectrum, allowing the fitting of only the oscillatory component of the CTF. CTFTILT determines specimen tilt parameters by measuring the defocus at a series of locations on the image while constraining them to a single plane. We tested the algorithm on images of two-dimensional crystals by comparing the results with those obtained using crystallographic methods. The images also contained contrast from carbon support film that added to the visibility of the CTF oscillations. The tests suggest that the fitting procedure is able to determine the image defocus with an error of about 10nm, whereas tilt axis and tilt angle are determined with an error of about 2 degrees and 1 degrees, respectively. Further tests were performed on images of single protein particles embedded in ice that were recorded from untilted or slightly tilted specimens. The visibility of the CTF oscillations from these images was reduced due to the lack of a carbon support film. Nevertheless, the test results suggest that the fitting procedure is able to determine image defocus and tilt angle with errors of about 100 nm and 6 degrees, respectively.