With the spread of COVID-19, there is an urgent need for a fast and reliable diagnostic aid. For the same, literature has witnessed that medical imaging plays a vital role, and tools using supervised methods have promising results. However, the limited size of medical images for diagnosis of CoVID19 may impact the generalization of such supervised methods. To alleviate this, a new clustering method is presented. In this method, a novel variant of a gravitational search algorithm is employed for obtaining optimal clusters. To validate the performance of the proposed variant, a comparative analysis among recent metaheuristic algorithms is conducted. The experimental study includes two sets of benchmark functions, namely standard functions and CEC2013 functions, belonging to different categories such as unimodal, multimodal, and unconstrained optimization functions. The performance comparison is evaluated and statistically validated in terms of mean fitness value, Friedman test, and box-plot. Further, the presented clustering method tested against three different types of publicly available CoVID19 medical images, namely X-ray, CT scan, and Ultrasound images. Experiments demonstrate that the proposed method is comparatively outperforming in terms of accuracy, precision, sensitivity, specificity, and F1-score. Keywords CoVID19 diagnosis • Clustering • Metaheuristic algorithm • Gravitational search algorithm 1 Introduction With the rapid outbreak of the Corona virus Disease (CoVID19) around the globe [1], the World health organization (WHO) has been declared CoVID19 as a Public Health Emergency of International Concern (PHEIC) [2]. Pathogenically, the virus identified in CoVID19 is "severe acute respiratory syndrome coronavirus 2" (SARS-CoV-2) which is quite distinct from other respiratory viruses like MERS-CoV, SARS-CoV, avian influenza, and influenza [3]. Usual symptoms in a COVID19 patient are fever, dry cough, and tiredness. Other signs experienced by patients include sore throat, diarrhea, headache, loss of taste