The image contrast of a single-walled carbon nanotube (SWCNT) is investigated via high resolution transmission electron microscopy (HRTEM) experiments and image simulations. It is found that the common practice of determining the tube diameter by measuring the two dark lines in the HRTEM image of a SWCNT is not very accurate, and this is especially so for tubes with diameters smaller than 1 nm. Depending on the imaging conditions, both amplitude contrast and phase contrast may be generated by a carbon nanotube in a HRTEM image. In images taken at the Scherzer defocus, a SWCNT usually appear as two dark lines corresponding to the two walls of the nanotube but in general the distance between the two dark lines is smaller than the real diameter of the SWCNT. The discrepancy between these two values varies with the size of the tube and the alignment of the tube relative to the electron beam, and can be as large as 30% for sub-nanometer carbon nanotubes. For tubes larger than 1.0 nm, the discrepancy is typically less than 10%. The phase contrast of a SWCNT changes with defocus condition. The reverse contrast appears at a small underfocus, while the two dark lines associated with the two walls of the SWCNT become broader for a large underfocus. For accurate nanotube diameter determination, we recommend that measurements based on HRTEM images should be combined with image simulations and structural relaxation of the atomic models of the carbon nanotubes.