## 2 Methodology  
Regular inspection of fundus images is important for patients suffering from diabetic retinopathy. Early signs of lesions, such as hemorrhages, exudates, microaneurysms and blood vessel dilation, can be detected in fundus images. The detection process becomes harder if the fundus images are affected by non-uniform illumination and low contrast. Some fundus images suffer from boundary reflectance due to over-exposure. Boundary reflectance can obscure abnormalities and other symptoms in its vicinity. In this paper, an approach to correct uneven contrast and luminosity in fundus images suffering from boundary reflectance is presented. The method is implemented in five stages, which are image input, filtering, luminosity correction, histogram stretching and post-processing. Figure 1 shows a fundus image with boundary reflectance and its red, green and blue channels. The gist of the method is to construct a smooth luminosity surface (LS) of the ROI via one-dimensional lowpass filtering (1 DLF). This luminosity surface (LS) provides an estimate of the background brightness for each pixel in the ROI. It is assumed that the ROI is small enough that every pixel in it should have the same luminosity (or background brightness). Using the LS, the background brightness of every pixel in the ROI is equalized to 128 so that all pixels experience the same luminosity. Then, the contrast of the ROI is enhanced via histogram stretching. The flow of the stages in the process is shown in Figure 2.  
Figure 1: A fundus image with strong boundary reflectance at its top left border with its red, green and blue channels. Figure 2: Flow of stages in the process. In the image input stage, the blue, red and green channels of a fundus image are read and stored in separate arrays. Then, the eye area along with its border is identified via thresholding. The threshold value is obtained via trial and error. Next, the ratios of R-to-G and B-to-G of each pixel in the ROI are calculated and kept along with copies of the B, G and R channels. In the 1 DLF stage, the ROI of the image is filtered for all three channels, one by one. It is noticed that in an image affected by reflectance, the epicenter of the reflectance always falls near the border of the ROI. After finding the position of the epicenter, the intensities of pixels on the boundary of the ROI should be filtered to reduce the effect of the reflectance. First, the intensities of the boundary pixels are placed in a 1D array. Then, circular 1 DLF is performed on the array repeatedly, 4 times over. The length of the filter starts at 11, and it increases by 10 in each iteration. As the length of the filter increases to 41, the filtered data become smoother. Then, the circular 1 DLF is repeated on another layer of pixels neighboring the boundary pixels, one pixel inward towards the center of the ROI. This step is repeated a few more times as a few contiguous layers of pixels starting from the boundary pixels are subjected to 1 DLF. The next step is to perform 1 DLF row by row and then column by column throughout the ROI. One-dimensional lowpass filtering is performed on the row or column array repeatedly 4 times over, but, unlike before, it is non-circular. Again, the length of the filter starts at 11 and increases by 10 in each iteration. However, for elements at the beginning and at the end of the array, the filter is shortened since there are not enough neighbors for them. The result is a smooth luminosity surface (LS) of the background brightness. Three types of lowpass filters are used, and they are the median filter, mean filter and inverse distance filter. Figure 3 shows the LSs of the green channel obtained using the median, mean and inverse distance filters. For every element in the array, there should be an equal number of elements before and after it, called neighbors. For instance, if the length of the filter is 11, there should be 5 neighbors before and after it.