Purpose: Excessive scatter contamination fundamentally limits the image quality of cone-beam CT (CBCT), hindering its quantitative use in clinical applications. The author has previously proposed an effective scatter correction method for CBCT using primary modulation. A Fourier transform-based algorithm (FTPM) was implemented to estimate scatter from modulated projections, with a few limitations including the assumption of uniform modulation frequency and magnitude that becomes less accurate in the presence of beam-hardening and other nonideal effects. This paper aims to overcome the above drawbacks by developing a new algorithm for the primary modulation method with improved accuracy and reliability. Methods: Incident x-ray intensities for each detector pixel with and without the interception of the modulator blocker are estimated from a modulated flat-field image. A new signal relationship is then developed to obtain a first scatter estimate from a modulated projection using a spatially varying modulation distribution. The method empirically adjusts the effective modulation magnitude for each projection ray to account for the beam-hardening effects. Estimated scatter signals with high expected errors are discarded in the generation of the final scatter distribution. The author proposes a technique of local filtration to accelerate major portions of the signal processing, and the new algorithm is referred to as local filtration based primary modulation (LFPM). Results: The study on the Catphan® 600 phantom shows that LFPM effectively removes scatterinduced cupping artifacts on CBCT images and reduces the CT image error from 222 to 15 HU. In addition, the image contrast on eight contrast rods of the phantom is enhanced by a factor of 2 on average. On an anthropomorphic head phantom, LFPM reduces the CT image error from 153 to 18 HU and eliminates the streak artifacts observed on the result of FTPM with substantially improved image uniformity. On the Rando® phantom, LFPM reduces the CT image error from 278 to 4 HU around the object center. Conclusions: As compared with the previously developed FTPM algorithm, LFPM enhances the imaging performance by using a more flexible data processing framework that does not require projection data downsampling or uniform modulation frequency and magnitude. It also becomes possible to discard suspicious scatter estimate values prior to the generation of a final scatter distribution and to model the beam-hardening effects on modulation for improved scatter estimation accuracy. The presented research further exploits the potential of the primary modulation method on scatter correction and facilitates its clinical adoption in CBCT imaging. C 2016 American Association of Physicists in Medicine. [http://dx