## 2 Materials and Methods
### Input Module  
The input module has four main functions: image decomposition on color channels, primary processing of each component, box division on each color channel, and blood vessel segmentation in each box. Because the retinal images have zones with different brightness and also contain noises with different small patterns in the background, primary processing for image enhancement is needed. Therefore, the first operation in primary processing is noise rejection. Due to efficiency and edge preserving, for noise reduction, a median filter (3 \(\times\) 3 kernel) and morphological filter (erosion and dilation) were used in the PP for each component of interest of the color spaces (R, G, B, and H). Because the eye fundus images have usually low local contrast the histogram equalization is performed. Another primary processing operation, binarization, is used in the blood vessel segmentation (IM) and also in the final RoI segmentation (OP). The above operations are commonly used and will not be detailed in this work. Due to primary processing methods (noise elimination), _EX_s or _HE_s of less than 3 \(\times\) 3 pixels cannot be detected. As we mentioned above, two types of box division algorithms are used. For _OD_ and _MA_ localization we used a sliding box algorithm as it is necessary that a box contains the entire RoI to be analyzed. We have chosen the sliding window approach for _OD_ and _MA_ localization because it is more possible to get a fine matching of these regions of interest in a sliding window rather than in a traditional approach (nonoverlapping--fixed--windows). For _EX_ and _HE_, a nonoverlapping algorithm is used because it is simpler in terms of computing effort and it is necessary for the global evaluation of diseases (the spread on the entire image). The algorithm for creating the sliding boxes starts with the box from the upper left corner of the image and a specified step sliding (Figure 2a). The analyzed box slides until it touches the right margin of the image. Then, the sliding box returns to the beginning and performs a vertical down slide, moving on to the next row. The algorithm runs until the lower right corner is touched. The nonoverlapping box algorithm for \(EX\) and \(HE\) is presented in Figure 2b. In this case, the box division has a smaller range than \(OD\) or \(MA\) (\(\frac{1}{4}\) of the sliding box dimension). Figure 1: Intelligent System for diagnosis and evaluation of regions of interest from Retinal Images concept (Roi – Region of Interest). For high-precision localization, an optimum box size must be chosen depending on the database and a good framing of the RoI (the minimum dimension framing the RoI). This dimension is experimentally chosen (input BDS). At each step of the sliding box algorithm, a new box is considered. Thus, a matrix of boxes (grid of boxes) is created. The box has a unique ID consisting of the row number and column number in the grid of boxes. The size of the sliding step depends of the resolution of the input images (like the patch dimension); for example, in the case of the STARE database it was experimentally chosen to be 10 pixels, while in the case of the MESSIDOR database it was 15 pixels. Blood vessel detection is necessary only for F1 and F4 functions (_OD_ and _HE_ detection). The blood vessel segmentation (BVS block) is necessary in two situations: for more accurate detection of the _OD_ in function F1 (in this case blood vessels need to be highlighted) and for more accurate detection of the HEs in function F4 (in this case blood vessels need to be removed). In other cases, blood vessel detection is not considered. The input to BVS is a box obtained from box division algorithms on the green channel (for better contrast of blood vessels). This box is divided into smaller boxes of dimension \(27\times 27\) pixels using a sliding box algorithm with a sliding step size of 1 pixel. The new boxes represent the input in the main module of BVS, namely the CNN.