Rationale: Peak detection is an important step in mass spectrometry, accurately identifying characteristic peaks is key to data analysis. However, the spectrum being analyzed often contains random noise and baseline variations, which present significant challenges in the process of peak detection. In order to address the issue of false peak detection, while simultaneously ensuring accurate detection of weak and overlapped peaks, this paper introduces an improved algorithm for mass spectrometry integrating weighted continuous wavelet transform with particle swarm optimization-based Otsu (WWTPO). Methods: The algorithm utilizes the Mexican hat wavelet as the mother wavelet and applies the weighted continuous wavelet transform (WCWT) to compress the frequency spectrum signal into a smaller scale range, which allows for the acquisition of more distinct and informative peak information. Moreover, the algorithm employs the particle swarm optimization (PSO) algorithm to iteratively optimize the optimal image segmentation threshold, which addresses the challenge of inaccurate Otsu image segmentation. Furthermore, the algorithm effectively utilizes the information of ridge lines, valley lines and the original spectrum in the wavelet space to enable accurate identification of peak positions. Results: The proposed method was applied to detect simulated peaks as well as MALDI-TOF datasets. The performance evaluation was conducted using receiver operating characteristic (ROC) curves, F1 measure and F-scores. Through comparison with continuous wavelet transform (CWT) and genetic algorithm-based threshold segmentation (WSTGA), multi-scale peak detection (MSPD) and CWT and image segmentation (CWT-IS), the results demonstrated that the WWTPO method exhibits high performance in peak detection. Conclusions: This method not only maintains a low false peak identification rate but also detects more weak peaks and overlapping peaks, further improving the accuracy and efficiency of peak detection in mass spectrometry. It possesses a higher capability for efficient peak detection.