## 2 Methodology
The exception would be for elements at the beginning and end of the array where there are insufficient neighbors before and after them, respectively. For circular 1 DLF, this is not a problem as the beginning and end of the array are considered connected. For noncircular 1 DLF, the filter is truncated. An element and its neighbors form a set called the members of the neighborhood. The mean (\(\mu\)) of the members of the neighborhood must be computed before the distance between each member and the mean is calculated. The reciprocal of the distance is the inverse distance (INVD) between a member and the mean. Any inverse distance should not exceed one, and if it is bigger than one, it is set to one. The sum of all inverse distances is called the denominator sum (DENSUM). Next, each member of the neighborhood is multiplied by its inverse distance and the sum of these multiplications is divided by the DENSUM and assigned to the element being filtered. This step creates a smooth array (SA) for the row or column. The operation is summarized by Equation (1). \[\text{SA(x)}=\sum_{\text{m}\in\text{N}}\frac{\text{I(m)*INVD}}{\text{DENSUM}} \tag{1}\]  
Figure 3: The LSs of the green channel in Figure 1 obtained using the three different filters. where  
N is the neighborhood of element x;  
m is a member of N, where x is the center;  
I(m) is the intensity of m;  
\(\mu\) is the mean of N;  
INVD is the inverse distance of m to the mean = 1/\(\left|\text{I(m)}-\ \mu\right|\);  
DENSUM is the sum of all the inverse distances of the members in N;  
SA(x) is the value of the smooth array at position x after filtering. The smooth arrays obtained from row-wise 1 DLF form a smooth surface that is subjected to column-wise 1 DLF. The result of this operation is the luminosity surface (LS) that approximates the background brightness of the ROI. Since the eye area is small, the background brightness of every pixel in the ROI can be equalized. In the luminosity correction stage, the background luminosity of all pixels is levelled as follows: The intensity of each pixel in the B(x,y), G(x,y) and R(x,y) channels can be lower or higher than their respective luminosity surfaces LS(x,y). Thus, at any position (x,y) in the ROI, the gap between the channel, say, G(x,y), and its background LS(x,y) is recorded, as this gap will be preserved after the background LS(x,y) is corrected for each pixel in the ROI. In order to equalize the LS(x,y), it is shifted to 128 at every location (x,y) since 128 is the middle-intensity level. For example, at position (x = m, y = n), let us assume that LS(m,n) needs to move up or down by a certain amount to become 128. Thus, G(m,n) has to move up or down by the same amount to maintain the gap to L(m,n). The results of the luminosity correction are the equalized channels, EB(x,y), ER(x,y) and EG(x,y). Then, the equalized channels undergo histogram stretching to improve the contrast of the ROI. This step generates contrast-adjusted blue, red and green channels denoted as CB(x,y), CR(x,y) and CG(x,y). Figure 4 shows the CG(x,y) of the image in Figure 1 obtained from the three filters. In most instances, histogram stretching does not affect the equalized channels much since they already have good contrast. The B, G and R channels of a fundus image can be diagnosed separately in greyscale. Nonetheless, it is desirable to recombine the three channels to form an improved color image. However, if the channels are combined without adjustment, the resulting color image will look different than the color of the original image. It is important to preserve the original color shades using the old R and B ratios over G. For this objective, the stored ratios of the old R and B channels divided by the old G channel are used. The new R and B channels are obtained by multiplying the respective color ratio by CG(x,y), as stated in Equation (2). The green channel is the anchor for this conversion since it contains the most information. For the G channel, CG(x,y) is used directly.