In the case of a weak signal from a photon counting lidar and strong noise from the solar background, the signal is completely submerged by noise, potentially resulting in the appearance of multiple peaks in the denoising algorithm of photon counting entropy. Consequently, a clear distinction between the signal and noise may become challenging, leading to significant fluctuation in the ranging error. To solve this problem, this paper proposes an improved offset parameter optimization algorithm under the framework of photon counting entropy, aiming to effectively eliminate peak interference caused by noise and enhancing ranging accuracy. The algorithm includes two aspects. First, we introduce the solar irradiance prediction of an MLP network and least squares linear conversion to accurately estimate the noise rate of the solar background noise. Then, we propose the offset parameter optimization method to effectively mitigate the interference caused by noise. In simulation and experimental analyses, the ranging error of our proposed method is within 5 and 30 cm, respectively. Compared with the denoising method of photon counting entropy, the average ranging error is increased by 81.99% and 73.76%. Furthermore, compared to other anti-noise methods, it exhibits superior ranging capability.