# A Deep Learning Model for Detecting Diabetic Retinopathy Stages with Discrete Wavelet Transform
## 3 Materials and Methods
### Image Preprocessing  
For machine learning and deep learning to succeed in their respective fields, image preprocessing is essential. The photos were first resized by a ratio of 1/255. To improve the stability and effectiveness of the model training process, the picture pixel values need to be normalized to the range [0, 1]. Rescaling the pixel values aids in preventing numerical instabilities and promotes quicker convergence during the training phase. After rescaling, other preprocessing methods improved the pictures further in preparing for the later feature extraction and classification phases, such as converting RGB to grayscale, CLAHE, and DWT.  
Converting the color image to grayscale is the next stage in preprocessing, followed by applying CLAHE. CLAHE is an image processing method employed to enhance the contrast and visibility of fine features in images, particularly those exhibiting uneven lighting conditions or poor contrast. CLAHE prevents contrast over-amplification in adaptive histogram equalization (AHE). Tiles, not the complete image, are what CLAHE processes. It removes spurious borders by combining nearby tiles using bilinear interpolation. This method boosts the visual contrast [57].  
Contrary to typical AHE, CLAHE restricts contrast. The CLAHE established a clipping limit to alleviate noise amplification [61]. In this study, after applying CLAHE preprocessing, the images were resized to a similar size. The image size varied in each dataset; for example, the APTOS images were 3216 \(\times\) 2136 pixels, and DDR was 512 \(\times\) 512 pixels. Therefore, to make it similar, the image size parameter was set to 224 \(\times\) 224 pixels. Then, the DWT method was applied to each image.  
Discrete Wavelet Transform  
A mathematical method for processing signals and images, the DWT allows the examination of distinct signal components at varying resolutions or scales. Particularly, the DWT breaks down a signal into two sets of coefficients: approximation and detail, which  
Figure 3: Example of an augmented image from a random image in training data. From left to right: the original image, followed by a horizontally flipped image, height-shifted image, width-shifted image, and rotated image.  
stand for the signal's low-frequency and high-frequency components, respectively [62]. In frequency, among the most often used techniques for image processing is the wavelet transform, which allows the information in images to be represented collectively [63]. Using the Python wavelet framework, the DWT is represented by  
\[\text{cA},(\text{cH},\text{cV},\text{cD})=\text{dwt2}(\text{image}) \tag{1}\]  
where cA represents the approximation coefficients, cH is the horizontal coefficients, cV is the vertical coefficients, and cD is the diagonal coefficients. Here, cH, cV, and cD are the detailed coefficients.  
The first step in the DWT method is to run the original image through two filters: a high-pass filter to extract the cV, cH, and cD coefficients and a low-pass filter to extract the cA component, as shown in Equation (1). These filters separate the signal's fine and coarse features. Following filtering, both sets of coefficients are downsampled by two, halving the image resolution. As our primary wavelet for the DWT procedure, we chose the 'db1' wavelet, also referred to as the Daubechies wavelet, with one vanishing moment. We used a single-level decomposition of the original retinal images. Figure 4 depicts the image decomposition into different coefficients.  
We manipulated these coefficients after the decomposition to produce a four-channel composite image. As each channel is devoted to a single set of coefficients, the whole information from the original image was captured such that our CNN could efficiently learn from it.