The challenges associated with conventional methods of COVID-19 detection have prompted the exploration of alternative approaches, including the analysis of lung X-ray images. This paper introduces a novel algorithm designed to identify abnormalities in X-ray images indicative of COVID-19 by combining the maximally stable extremal regions (MSER) method with metaheuristic algorithms. The MSER method is efficient and effective under various adverse conditions, utilizing symmetry as a key property to detect regions despite changes in scaling or lighting. However, calibrating the MSER method is challenging. Our approach transforms this calibration into an optimization task, employing metaheuristic algorithms such as Particle Swarm Optimization (PSO), Grey Wolf Optimizer (GWO), Firefly (FF), and Genetic Algorithms (GA) to find the optimal parameters for MSER. By automating the calibration process through metaheuristic optimization, we overcome the primary disadvantage of the MSER method. This innovative combination enables precise detection of abnormal regions characteristic of COVID-19 without the need for extensive datasets of labeled training images, unlike deep learning methods. Our methodology was rigorously tested across multiple databases, and the detection quality was evaluated using various indices. The experimental results demonstrate the robust capability of our algorithm to support healthcare professionals in accurately detecting COVID-19, highlighting its significant potential and effectiveness as a practical and efficient alternative for medical diagnostics and precise image analysis.