Stage 1: Image Clustering and Pre-Processing

The intricate structure of the information in images makes the clustering of X-ray (radiographs) and CT-scan images challenging. A considerable visual resemblance exists between X-ray and CT images of the same class. Furthermore, because of the varied X-ray image types, orientation changes, alignments, and diseases, there was a significant variance within a class. The quality of the X-ray images also varied significantly, in addition to the contents. As illustrated in the accompanying diagram, the image clustering framework in this study was divided into two phases: image feature extraction and image clustering.

Then, the clustering process was carried out using the machine-learning enginespecific processors in contemporary mobile devices. Maintaining dataset characteristics while improving clustering efficiency was recommended [6].

Algorithm 3 outlined the primary steps for clustering the pixels in the input image, using the modified *k*-means clustering algorithm, as described earlier in this section.


Initially, patient X-ray and CT-scan images of COVID-19 disease were segmented using the *k*-means clustering algorithm, which then split the image into a set of regions that could be processed and analyzed. Due to the high performance achieved through the modification of the aforementioned algorithm, this step resulted in a thorough scan of the images and the segmentation of their content at a high speed, in preparation for the next stage, which was the application of the YOLOv4 algorithm.

Second, incoming images were resized to 640 by 640 px and normalized using a normalize procedure. The improved *K*-means clustering algorithm, based on mobile neural engine processors [6], was then used to further match the training data with the *k*-mean YOLOv4 model. A suitable anchor size setting facilitated model convergence and provided useful prior information, and this sped up the model training process and resulted in more accurate values. The full implementation flowchart of anchor sizes is provided.

Figure 3 summarizes the main steps of the first stage of image clustering.

**Figure 3.** Stage 1 image clustering architecture.

By clustering pixels in an image, we simplified the image by reducing the number of colors and tones. This assisted in removing noise and unwanted details from the image, making it easier to extract relevant features.

Once the pixels were clustered, a new image was created where each pixel was assigned to its corresponding cluster, based on the map image. This new image was called a clustered image. The clustered image contained fewer colors and tones than the original image and could be used to extract features that were more representative of the image content.

For example, in the medical image analysis, *k*-means clustering was used to segment an X-ray or CT-scan image into regions based on the density of the tissue. By clustering the pixels in the image, we identified regions that corresponded to bones, organs, and other tissues, which were then evaluated for feature extraction. These features included the size, shape, and texture of the tissue, which was then used to detect abnormalities and other features that could be indicative of a disease or condition.
