## 3 The Proposed Method
### McCann Retinex Algorithm  
The McCann Retinex algorithm is a contrast enhancement algorithm; however, it has not been validated on medical images, because it is an iterative algorithm. Each iteration changes the details of the medical image. [PERSON] [19] improved the retinex random walk algorithm by implementing the one-dimensional into a multilevel retinex algorithm. [PERSON] and [PERSON] proposed the retinex iterative algorithm based on a multiresolution image pyramid. The multiresolution image pyramid is based on four operations called ratio-product-reset-average operations. As represented in Figure 2, the iterative retinex algorithm generates a multiresolution image pyramid from the input image and produces an average output image by forming pyramid data layers based on the image. The mathematical representation of the process is explained below. [PERSON]'s algorithm is based on image transformation operations from linear to logarithmic form to streamline the process from multiplication to addition and from division to subtraction. The whole retinex iterative algorithm is based on the ratio-product-reset and average arithmetic operation. The main purpose of the ratio and product is to estimate the initial reflectance of the image; then, the average operation updates the estimated reflectance of the image. The main purpose of applying the arithmetic operation is to calcu  
Figure 1: Proposed Approach for Brain MRI and Retinal Fundus Images. (**a**) shows the proposed approach for the brain MRI. (**b**) shows the proposed approach for the retinal fundus images. late the ratio between the I image and its shifted version updated with some shift distance, as represented in Equation (1). \[\text{logS}^{*}_{\text{x,y}}=\frac{\text{Reset}\big{[}\big{(}\text{ logM}_{\text{x,y}}-\text{logN}^{\prime}_{\text{xs,ys}}\big{)}+\text{logS}_{\text{xs,ys}} \big{]}+\text{logS}_{\text{x,y}}}{2}, \tag{1}\]  
where \(\big{(}\text{logM}_{\text{x,y}}-\text{logN}^{\prime}_{\text{xs,ys}}\big{)}\) is the ratio, and \(\big{[}\big{(}\text{logM}_{\text{x,y}}-\text{logN}^{\prime}_{\text{xs,ys}} \big{)}+\text{logS}_{\text{xs,ys}}\big{]}\) shows the product in the form of the log domain. The next step is the reset operation, which updates the maximum intensity level with respect to the given iteration. The \(logS(x,y)*\) is an average of \(logS^{\prime}(x,y)\) and \(logS(x,y)*\) as the updated output obtained at each iteration, used as input for the next iteration, until the final reflectance at the last iteration obtains the final output image. The retinex algorithm calculates brightness and its impact on the image, which compares pixels values to correct pixels in the image. The pixel comparison of a multiresolution image begins with three operations (ratio-product-reset). The average process is performed from the top level of the pyramid to the final iteration to produce the final output image. As a result of the calculation, the pixels illuminate the image value at a lower resolution (upper level of the image pyramid). The resulting brightness values are propagated downward by pixel replication of the next level of the image pyramid as long as the initial level of brightness is encountered. The retinex process for image pixels based on the multiresolution image pyramid relies on iteration computation. The long distance between variation pixels in each iteration is the calculation process of the iteration, and each iteration has variation at the initial phase; then, it moves a short distance between each pixel per iteration. Pixel spacing is calculated at each step of the modified retinex algorithm, and it gradually decreases by one pixel offset per distance. The operation of the pixel process is based on clockwise steps, and at each step the pixels are compared to the estimated reflectance of the image based on their operations [21], which are calculated iteratively.