A method and apparatus for optimizing a blocking grating for cone beam CT image scattering correction, wherein the method comprises: scanning a blocking grating to establish a swinging model thereof; setting initial coordinates of the blocking grating along a longitudinal direction of a detector in an initial projection, and establishing an objective function between CBCT image data missing voxel values and the coordinates of the blocking grating along the longitudinal direction of the detector according to the swinging model; minimizing the objective function with a mesh-adaptive direct search algorithm to generate optimized coordinates of the blocking grating along the longitudinal direction of the detector. The present disclosure proposes a brand new scattering correction method not requiring any source compensation, performs a mathematical optimization modeling of the data missing caused by the blocking grating in the image domain, quantitatively evaluates the influence on the reconstructed image by a blocker, solves a geometric optimal structure of the blocker using a mesh-adaptive direct search algorithm, and lays a solid theory foundation for the scattering correction method based on the blocker measurement.