This article addresses automated segmentation and classification of COVID-19 and normal chest CT scan images. Segmentation is the preprocessing step for classification, and 12 DWT-PCA-based texture features extracted from the segmented image are utilized as input for the random forest machine-learning algorithm to classify COVID-19/non-COVID-19 disease. Diagnosing COVID-19 disease through an RT-PCR test is a time-consuming process. Sometimes, the RT-PCR test result is not accurate; that is, it has a false negative, which can cause a threat to the person’s life due to delay in starting the specified treatment. At this moment, there is an urgent need to develop a reliable automatic COVID-19 detection tool that can detect COVID-19 disease from chest CT scan images within a shorter period and can help doctors to start COVID-19 treatment at the earliest. In this article, a variant of the whale optimization algorithm named improved whale optimization algorithm (IWOA) is introduced. The efficiency of the IWOA is tested for unimodal (F1–F7), multimodal (F8–F13), and fixed-dimension multimodal (F14–F23) benchmark functions and is compared with the whale optimization algorithm (WOA), salp swarm optimization (SSA), and sine cosine algorithm (SCA). The experiment is carried out in 30 trials and population size, and iterations are set as 30 and 100 under each trial. IWOA achieves faster convergence than WOA, SSA, and SCA and enhances the exploitation and exploration phases of WOA, avoiding local entrapment. IWOA, WOA, SSA, and SCA utilized Otsu’s maximum between-class variance criteria as fitness function to compute optimal threshold values for multilevel medical CT scan image segmentation. Evaluation measures such as accuracy, specificity, precision, recall, Gmean, F_measure, SSIM, and 12 DWT-PCA-based texture features are computed. The experiment showed that the IWOA is efficient and achieved better segmentation evaluation measures and better segmentation mask in comparison with other methods. DWT-PCA-based texture features extracted from each of the 160 IWOA-, WOA-, SSA-, and SCA-based segmented images are fed into random forest for training, and random forest is tested with DWT-PCA-based texture features extracted from each of the 40 IWOA-, WOA-, SSA-, and SCA-based segmented images. Random forest has reported a promising classification accuracy of 97.49% for the DWT-PCA-based texture features, which are extracted from IWOA-based segmented images.