## 3 Proposed System
### Hard Exudates (HaExs) Segmentation Module  
The objective of the first module is to segment HaEx lesions utilizing CNN from RGB fundus images to obtain a binary mask of these lesions. Figure 2 presents the processes inside the module in detail. For dataset preparation, three datasets, Messidor [28], Retinal Lesions [29], and DDR [30] were considered. Retinal Lesions and DDR are public datasets with RGB retinal images and ground truth (GT) masks of DR lesions, which are labeled based on the consensus of several ophthalmologists [29; 30]. In the case of Messidor, the GT masks are privately generated by two ophthalmologists based on the Messidor RGB images. The final GT masks were decided by their consensus. Each dataset provides different types of ground truth masks for HaExs. For example, Messidor and Retinal Lesions provide rough segmentation, grouping agglomeration of exudate spots. Meanwhile, in the DDR dataset, each exudate spot is segmented separately. Figure 3 shows examples of images and corresponding GT masks from three datasets. We decided to use the Messidor dataset and Retinal Lesions dataset to train and evaluate the HaEx segmentation module because the amount and shape of the leak of lipids play an important role in causing HaEx lesions identified by  
Figure 1: Proposed System Diagram. The DME grading is performed using the macular region (circle) and optic disc (square). Figure 2: HaEx segmentation module subprocesses. yellowish-white deposits [31]. Therefore, rough segmentation used in Messidor and Retinal Lesion is more adequate for the segmentation module. A cropping process was employed on the images to keep only the region of interest, removing the greater black background as shown in Figure 1. Then the datasets are divided into two sets: train and test with approximately 80% and 20% of the images. Table 2 presents the number of images in training and test sets. ConvUNeXt [32] was used to achieve our goal of accurate HaEx segmentation because it is a model based on UNet for medical image segmentation with the advantage of reducing the number of parameters and enhancing the convolution blocks by using large convolution kernels and depth-wise separable convolution. This parameter reduction allows ConvUNeXt to achieve a lightweight design while maintaining segmentation performance. It also integrates a gating mechanism for feature fusion and a lightweight attention mechanism (Attention Gate) to filter out noise and highlight relevant information. These mechanisms enhance the model's ability to capture both high-level and low-level semantic information, resulting in more accurate segmentation outcomes [32]. The attention gate mechanism controls the importance of features at different spatial locations, allowing the model to suppress irrelevant areas in the input image while highlighting relevant features in specific local areas, leading to improved accuracy in medical image segmentation tasks, as shown by a review paper [33]. The quality of retinal images is highly variable and influenced by several factors, including the type of ophthalmoscopy employed, the precision of the ophthalmoscopic focus, and the environmental conditions during image acquisition, such as the level of \begin{table}
\begin{tabular}{c c c} \hline \hline
**Dataset** & **Training Set** & **Test Set** \\ \hline Messidor [28] & 900 & 236 \\ Retinal Lesions [29] & 400 & 96 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Datasets and their respective division into training and test sets. Figure 3: Example of an image for each dataset and its respective GT mask for HaEx segmentation. illumination. Therefore, in some cases, the preprocessing stage to enhance HaEx lesions is required to obtain accurate segmentation. We consider two image-enhancing methods: contrast enhancement (CE) [34] and the conversion in CIELAB color space from RGB. The CE preprocessing is given by (1).