Pneumonia is a pulmonary disease resulting from infections caused by bacteria, viruses, or fungi that invade the lungs. This condition leads to inflammation due to the accumulation of fluids, blood cells, and other substances in the alveoli. Common symptoms experienced by patients include fever, coughing, and production of phlegm. Although pneumonia can affect individuals of any age, those with weakened immune systems are particularly vulnerable. Children and elderly individuals are especially prone to contracting this illness. The present research employs an ensemble learning approach for pneumonia detection using chest x-ray images to address this issue, specifically integrating support vector machines (SVMs) and random forests (RFs). The primary aim is to evaluate the effectiveness of ensemble learning through a voting classifier in improving pneumonia detection accuracy compared to individual machine learning models. The methodology includes preprocessing the data with contrast-limited adaptive histogram equalization (CLAHE), which minimizes noise by defining a kernel matrix and substituting each pixel's intensity with the weighted average of its neighboring pixels and itself. The research also involves training models using SVM and RF algorithms with hyperparameter optimization. These individual models are then assessed and compared using performance metrics such as accuracy, area under the curve (AUC), specificity, sensitivity, confusion matrix, and computational efficiency. By harnessing the strengths of ensemble learning, this research aims to contribute to the development of reliable pneumonia detection systems, with potential applications in clinical environments where timely and accurate diagnosis is essential for patient management. This research achieved 99.40% and 96.32% accuracy, 99.97% and 96.52% AUC, and 0.0436% and 0.0451% loss. This method tackles others that use deep learning and single machine learning with all balanced datasets.