Due to the energy-dependent nature of the attenuation coefficient and the polychromaticity of the X-ray source, beam hardening effect occurs when X-ray photons penetrate through an object, causing a nonlinear projection data. When a linear reconstruction algorithm, such as filtered backprojection, is applied to reconstruct the projection data, beam hardening artifacts which show as cupping and streaks are present in the CT image. The aim of this study was to develop a fast and accurate beam hardening correction method which can deal with beam hardening artifacts induced by multi-materials objects. Based on spectrum estimation, the nonlinear attenuation process of the X-ray projection was modeled by reprojecting a template image with the estimated polychromatic spectrum. The template images were obtained by segmenting the uncorrected into different components using a simple segmentation algorithm. Numerical simulations, experimental phantom data and animal data which were acquired on a modern diagnostic CT scanner (Discovery CT750 HD, GE Healthcare, WI, USA) and a modern C-Arm CT scanner (Artis Zee, Siemens Healthcare, Forchheim, Germany), respectively, were used to evaluate the proposed method. The results show the proposed method significantly reduced both cupping and streak artifacts, and successfully recovered the Hounsfield Units (HU) accuracy.