To address critical issues in traditional quality control methods for discrete Eulerian solutions in underwater magnetic target detection—such as excessive filtering of valid solutions during divergence suppression, parameter settings reliant on subjective experience, and insufficient noise resistance—this study proposes a novel approach combining the Artificial Protozoa Optimizer (APO) with DBSCAN clustering. Based on the distribution characteristics of discrete Euler solutions, an optimization objective function incorporating Euler solution residual penalty terms and contour line coefficients was constructed. The APO algorithm identifies DBSCAN clustering parameters that minimize this objective function, thereby enhancing clustering precision and accuracy. This method selects optimal Euler solution sets, enabling high-precision localization of magnetic targets. Simulation and field test results demonstrate that compared to statistical screening methods, the optimized algorithm achieves a 52.52% and 76.33% increase in the retention rate of valid solutions for noise-free and noisy data, respectively, while reducing the retention rate of invalid solutions by 28.57% and 94.21%. In field data, the average deviation from the true center of gravity is reduced by 26.37%.