Detection and diabetic retinopathy grading using digital retinal images

Diabetic Retinopathy is an eye disorder that affects people suffering from diabetes. Higher sugar levels in blood leads to damage of blood vessels in eyes and may even cause blindness. Diabetic retinopathy is identified by red spots known as microanuerysms and bright yellow lesions called exudates. It has been observed that early detection of exudates and microaneurysms may save the patient’s vision and this paper proposes a simple and effective technique for diabetic retinopathy. Both publicly available and real time datasets of colored images captured by fundus camera have been used for the empirical analysis. In the proposed work, grading has been done to know the severity of diabetic retinopathy i.e. whether it is mild, moderate or severe using exudates and micro aneurysms in the fundus images. An automated approach that uses image processing, features extraction and machine learning models to predict accurately the presence of the exudates and micro aneurysms which can be used for grading has been proposed. The research is carried out in two segments; one for exudates and another for micro aneurysms. The grading via exudates is done based upon their distance from macula whereas grading via micro aneurysms is done by calculating their count. For grading using exudates, support vector machine and K-Nearest neighbor show the highest accuracy of 92.1% and for grading using micro aneurysms, decision tree shows the highest accuracy of 99.9% in prediction of severity levels of the disease.


Introduction
Diabetic retinopathy (DR) is a vision threatening medical condition in which the retina of the diabetic patients gets damaged to an enormous amount. It is a secondary disease caused in the people already suffering from Diabetes Mellitus. It has become one of the most leading and recurrent cases of blindness among children and adults who have been suffering from diabetes for an extremely long period of time. Approximately 93 million people have been reported to suffer from DR, 17 million people are targets of proliferative DR, whereas diabetic macular edema is prevalent in 21 million people worldwide (Rathmann and Giani 2004). The strong reasons and associations behind DR are longer duration of diabetes, poor blood pressure and glycemic control. These statistics point out the substantial growth of DR and the global health burden caused by it. In Indian urban population, the prevalence of diabetic retinopathy is found to be 18% with men at a higher risk (Raman et al. 2009).
Diabetic Retinopathy, also goes by the name of diabetic eye disease caused to the people with high blood sugar level that badly affects the retina's blood vessels by swelling and leaking. In some cases, they might also restrict the blood to pass through. The retina gets badly damaged by diabetes mellitus. The blindness happens due to this prolonged medical condition. Due to high and abnormal levels of glucose in blood, there is restriction of oxygen flow in the blood vessels which results in weakened smaller blood vessels in retina and their destruction which further leads to formation of newer but weaker blood vessels. The condition of diabetic retinopathy can happen to anyone who has been suffering either from diabetes type-1 or diabetes type-2. The consequences of this disease are life threatening but with proper care, medications and treatment, diabetics can have a normal life. If people show no urgency to the treatment of diabetes then it goes uncontrolled which can further cause bad effect on a persons' eyesight, cause damage to nervous system and spread infections on the feet also. The diagnosis of this disease at earliest possible stage is very important so that help in complete elimination and preservation of the vision of the people suffering from diabetic retinopathy is achieved. A lot of people can save themselves from being blind if the treatment to Diabetic Retinopathy is done at early possible stage. It has become very important for the formation of automatic detection of this problem and serve the people where there is lack of good quality infrastructure and experts. Thus, automated grading system for diabetic retinopathy has been proposed in this work that saves a lot of manual labor and with the help of image processing and machine learning, it can predict accurate results for large image dataset in very less time.

Lesions in retina due to diabetic retinopathy
The features like soft exudates, hard exudates, micro aneurysms and hemorrhages are the major representatives of diabetic retinopathy.

Soft exudates
Soft exudates also known by the name Cotton wool spots as this is what they appear like on the surface of retina. The appearance is usually cloud like, grayish-white or yellowish white with fringy borders. They cause swelling in the retina and may not lead to threatening vision loss in the diabetic patients only if they are present away from fovea which is the central portion of the eyes that gives high definition and focused vision. Because of reduction in axonal transport within the blood vessels, swelling happens due to ischemia. Figure 1b shows the presence of cotton wool spots or soft exudates in the retina.

Hard exudates
Due to suffocation caused in the blood vessels because of lack of oxygen due to formation of newer capillaries, this results in pressure and breakage of the blood vessels that result in the formation of white or yellow pots in retina that have sharper boundaries than soft exudates. These can be arranged as patches, dots or sheets in the retina. Around the retinal veins, their depositions can be found too. Hard exudates cause great damage to the retina by posing threat to the vision of the patients. The Fig. 1c shows the yellow exudates.

Micro aneurysms
Micro aneurysms are the earliest possible signs in the retina of people suffering from diabetic retinopathy. Their appearance is like small, red and round blots that have sharp boundaries. The swellings in the blood vessels and high pressure built up in the network of vessels results in rupture of blood from them, thus forming micro aneurysms. The treatment can reverse their presence as they are in the early stages of diabetic retinopathy and also by treating the high blood pressure patients. The Fig. 1d shows micro aneurysms in the retina.

Hemorrhages
The pressure built inside the network of blood vessels due to lack of oxygen and high levels of glucose in bloodstream results in formation of new, weak tiny capillaries as the existing blood vessels are not able to carry signal to the brain which causes the brain to react by forming new vessels but that are weaker in nature. Since these are weak, this results in the leakage of capillaries into retina thus forming flame shaped hemorrhages or dot or blot shaped hemorrhages. Dots are usually associated with diabetic retinopathy whereas flames are caused due to breakage of nerve fibers of retina. Their appearances are irregular shaped or distinct edged objects in the retina. The Fig. 1d shows the hemorrhages in the retinal image. Below are the contributions of the proposed work in brief.

A simple and effective technique for diabetic retinopathy
to grade the severity of diabetic retinopathy has been proposed i.e. whether it is mild, moderate or severe using exudates and micro aneurysms in the fundus images. 2. The research is carried out in two segments (a) one for exudates based upon their distance from macula and (b) another for micro aneurysms is done by calculating their count. 3. Both publicly available and real time datasets of colored images captured by fundus camera have been used for the empirical analysis. 4. Image processing for features extraction and machine learning models has been used for prediction of the exudates and micro aneurysms based grading.
The rest of the paper is organized as follows: Sect. 1 gives the introduction to the paper and Sect. 2 gives the relate work done in this area. Section 3 presents the preliminaries with Sect. 4 giving the methodology for the proposed technique. Section 5 lists the performance metrics used for analysis where result analysis is presented in Sect. 6. Section 7 concludes the paper.

Literature review
Diabetic retinopathy is one of the leading causes of vision loss and blindness in people suffering from diabetes for a long time. Its accurate detection is of primary concern for researchers that can help ophthalmologists for lesser manual efforts while dealing with increasing number of patients and data records.

Review on image processing techniques used in diabetic retinopathy detection
In machine learning approaches, image preprocessing is the fundamental step that has been used widely in detection of diabetic retinopathy recently. Akter et al. (2014) have focused primarily over the usage of morphological operations for detection of exudates in the fundus images. Majorly histogram equalization, thresholding to get binary image and watershed transformation has been put to use for pinning out the exudates. Dutta et al. (2017) have worked on Messidor, Drive and local database separately to make use of contrast enhancement, top hat transforms, and intensity thresholds to detect the exudates. For detection of red lesions, vessels detection and adaptive histogram equalization has been worked upon. They have classified into severe, mild, moderate and normal with the help of preprocessing techniques. Dutta et al. (2015) have used two methods of image preprocessing and their strategic combination to finally detect exudates in the fundus images. The first method revolves around vessel detection, intensity threshold and area threshold while the second method involves edge detection and morphological operation. Kayal et al. (2014) worked on detecting the hard exudates via image processing methods like median filtering, image subtraction, dynamic thresholding and image addition. Harini and Sheela (2016) have worked on detection of micro aneurysms and exudates using various image preprocessing methods like resizing the images, applying contrast limited adaptive histogram equalization and top hat filters for better detection. Removal of blood vessels is done as well for better results in case of micro aneurysm detection. Sindhu et al. (2017) have used ensemble of image processing methods and candidate extraction methods for grading according to micro aneurysms in retina. After application of several image enhancement methods and candidate extraction methods, CLAHE and circular hough transforms are used for processing the images and giving the final results. Siddalingaswamy and Prabhu (2010) have used image processing methods for grading according to exudates on the basis of their distances from the foveal zone. After detection of optic disc and macula, efforts are placed over hard exudates detection via green channel extraction, intensity difference and overlaying candidates and graded them accordingly. Palavalasa and Sambaturu (2018) have worked on the detection of yellow lesions detection with the help of image processing in fundus images collected from DiaretDb database. The fundus images have been converted into the green channels due to high contrast and better detection of objects. Contrast limited adaptive histogram equalization has been used for improving the illumination of the fundus images. With the help of morphological operations background removal and subtraction operations have been performed. Region growing algorithm has been applied for detecting the exudates in the images. Yaşar et al. (2018) have proposed similar use of image processing mechanisms for hard exudates detection in the fundus images by improving the image quality using median filter and improving illumination of images. Opening and erosion operations have been proposed along with optic disc removal. Edge detection like kirsch algorithm has been used along with these steps for exudates detection. Sinthanayothin et al. (2002) made use of image processing methods and a moat operator to detect diabetic retinopathy via exudates and micro aneurysms by working on a very small dataset of 30 retinal images. The colored images have been converted into IHS color format; application of contrast improvement has been done. The optic disc has been extracted also via working on area that has the highest variation in intensity. Blood vessels have been extracted with use of neural networks. With the help of recursive region growing algorithm detection of exudates has been done. To separate and detect the red lesions from the orange background, moat operator has been applied. Mirajkar and Patil (2013) focused on diabetic retinopathy detection by processing the images by converting them to grayscale, using adaptive histogram equalization, smoothening them and then extracted particular features like blood vessels network using kirsch's edge detection mechanism upon which application of 2-D gabor wavelet transform is done. Saiprasad Ravishankar et al. (2009) worked on detection of exudates and micro aneurysms by working on various features extraction along with the image processing methods. Work is done on detection of optic disc and blood vessels by using blood vessel network color model, also removal of fovea is done. Detection of exudates and micro aneurysms is done using various morphological operations. Harini and Sheela (2016) focused on detection of various features of diabetic retinopathy like exudates, micro aneurysms by using various image processing methods like contrast enhancement, conversion into green channel, morphological operations and extracted blood vessels as well. The textural features are extracted as well using gray level co-occurrence matrix. Ravivarma et al. (2014) drove their research towards low quality fundus images and used them for detection of exudates using median filter and segmentation using fuzzy c-means clustering algorithm. After segmentation, various features like color, texture and size were derived and optimized using particle swarm optimization and finally fed to svm classifier. Omar et al. (2016) worked on extraction of textural features by first acquiring particular regions of interest through image processing methods and then applying the local binary pattern feature extraction method for detecting the hard exudates from the fundus images. Zhang et al. (2013) have worked on extracting features of tongue for detection of diabetic retinopathy that includes color, geometry and texture of the tongue images. Using the 12 color features of the tongue, extracted by taking mean of some 8 color features along with other 9 features of color. Further 13 features are extracted based on certain distances, areas and measurements. With the combination of 34 features, work has been done for detection of diabetic retinopathy by classifying the tongue images into normal and affected ones. Seoud et al. (2015) have worked with the detection of red lesions on the basis of their dynamic shape-based features extraction. The contrast and illumination of the images have been improved in this approach, noises have been removed via mean filter and optic disc has been extracted out. Various dynamic features like elongation, relative area, circularity, rectangularity and solidity have been used for hemorrhages and micro aneurysms. Choudhury et al. (2016) have proposed detection of exudates from the fundus images with usage of various image preprocessing steps and extracting the exudates with the help of fuzzy c-means clustering that serve as features for their work and also usage of vessel density features. The images have been enhanced with contrast illumination and removal of noises using filters. Li and Chutatape (2000) have worked on a relatively smaller datasets that focuses on extraction of certain features like optic disc, blood vessels for exudates detection in diabetic retinopathy. Optic disc has been extracted with the help of sobel edge detection method and blood vessels are extracted with the kirsch's edge detection method. The exudates are extracted by application of kirsch edge detection in green channel of the colored images and the area and count of exudates are maintained. Carrera et al. (2017) worked on detection and classification of exudates and micro aneurysms. It extracted features like blood vessels by converting RGB into CMY representation and applying various morphological operations to hide the blood vessels. With the usage of hole filling algorithms and edge detection mechanism, thresholding mechanisms exudates and micro aneurysms are extracted and fed into SVM and decision tree classifier. Yu et al. (2017) proposed a method of classification of presence of exudates using various morphological operations and image processing steps for detection of optic disc, hiding the blood vessels and used opening operation for finding the exudates and then trained and tested the Convolutional Neural Networks (CNN) model on it. Chandran et al. (2016) proposed a technique with am-fm characterization of the images, where amplitude and frequency modulation were used along with demodulation mechanism and gabor filters were used for edge detection among the images. Textural features were acquired along with blood vessel features extraction which were fed into the random forest classifier and rule-based decisions were made regarding classification of diabetic retinopathy. Saravanan et al. (2013) worked on the micro aneurysms and used various steps of image processing like thresholding, binarization, blood vessels removal, and various morphological operations to detect the micro aneurysms better and classify using the Gaussian mixture model using the count of red lesions to show the severity of diabetic retinopathy. Yadav et al. (2017) proposed a classification mechanism for diabetic retinopathy to classify into normal, dot hemorrhages, exudates using various image processing steps like image addition, subtraction, thresholding and morphological operations, while also extracting certain features like optic disc, blood vessels and trained a feed forward neural network for the same. Tjandrasa et al. (2013) classified the diabetic retinopathy on the basis of exudates and application of soft margin support vector machine. The exudates are segmented using various morphological operations, subtractions and additions of images, intensity thresholding and then features like area, perimeter, standard deviation etc. are extracted from the segmented exudates which are fed into SVM for classification. Yu et al. (2017) proposed the usage CNN model for detection of the exudates in the fundus images. A 64× 64 patch has been used over the pixels of the green channel and illuminated fundus images. Optic disc has been extracted and removed and opening operation has been used for ultimate extraction of exudates. The method has been applied on e-optha database having 82 images. Yalçin et al. (2018) proposed the usage of convolutional neural networks for detection of exudates and classification of presence or absence of diabetic retinopathy in the patients. They worked by pre-treating the fundus images by standardizing the size of the images and converting them to grayscale images before feeding into the model for training and testing Santhakumar et al. (2016) made use of various machine learning algorithms incorporated with image preprocessing for detection of exudates and hemorrhages in the fundus images that includes removal of background details and optic disc as they consume a lot of memory without contributing to detection of diabetic retinopathy. Features like mean, standard deviation etc. have been extracted from all the channels of images and visualized through principal component analysis. Over the extracted features SVM has been used for classification purposes. Gurudath et al. (2014) proposed a method of detecting exudates, micro aneurysms and hemorrhages by classifying into no diabetic retinopathy, proliferative retinopathy and non-proliferative retinopathy using extraction of blood vessels with the help of Gaussian filters and automatic mask generation on fundus images from DRIVE and DIARETDB databases and also using their textural features which are fed into artificial neural network and SVM. Pal et al. (2017) used machine learning models like Naive Bayesian classifier, SVM, K nearest neighbor algorithm and decision trees for binary classification of diabetic retinopathy on the fundus images collected from Messidor database. The performances of the models used apart from SVM were quite average since no preprocessing on images and features extraction was used. The existing researches have focused either on the detection of the features of diabetic retinopathy or on the use of image processing for grading in diabetic retinopathy. In our work, grading has been done to know the severity of diabetic retinopathy i.e. whether it is mild, moderate or severe using exudates and micro aneurysms in 1361 fundus images. An automated approach that uses image processing, features extraction and machine learning models to predict accurately the presence of the exudates and micro aneurysms and accordingly grading has been proposed. The Table 1 gives the comparison between the methodologies discussed in the literature review.

Review on machine learning algorithms used in diabetic retinopathy detection system
In Zhang et al. (2021) the authors have proposed an O-shaped neural network to detect junctions in biomedical images with attention modules and without segmentation. It contains local enhancement branch and junction detection branch for junction detection and complement the relationship to compile the contextual information and local features integration. It achieved good F-1 scores but it is computationally expensive. In Li et al. (2020) a fully attention-based network (FANet) method has been proposed which combines the multi-set information and learns features adaptively. It uses CLAHE, U-Net and selective kernel (SK) for convolution and experimented on public datastes such as CHASE_DB1, STARE and DRIVE to yield competitive performance. It is a complex network to implement and also time consuming while requiring GPU for expensive computation. In Aleem et al. (2018), the authors have proposed a fast and accurate system to identify retina while differentiating the thick/thin blood vessels for wavelet responses. The limitation is that identification rate is not high due to noise in the pathological images. It also consumes more identification time as compared to clear images according to the authors therefore image enhancement module needs to be included. The training database size also needs to be enhanced for the size over a longer periods of data collection. In addition to PCA, other discriminant analytics can be explored as well. The deep learning model proposed in Xu et al. (2017) uses CNN which needs a larger training dataset to extract complex features of exudates. The images are quite specific and complex for exudates detection for the CNN model and thus hand crafted features using the image processing techniques along with traditional machine learning algorithms for a good combination for classification. Another state-of-the-art model ConvNet proposed in Quellec et al. (2017) was proposed which was trained on 90,000 public images. The deep learning models require GPU computation power and are also time consuming to extract efficient features from medical images. If the dataset is small which is often in case of medical imaging and transfer learning may be not possible due to diverse nature of trained and underlying medical data, it is good to use handcrafted image features (with the advice of medical expert) along with traditional ML model. The proposed technique is simple and effective for diabetic retinopathy to grade the severity (mild, moderate or severe) and the research is carried out in two segments (a) one for exudates based upon their distance from macula and (b) another for micro aneurysms is done by calculating their count. Original data has also been collected and experimented for the analysis and the choice of relevant and simple techniques for feature extraction and ML makes it efficient. Most contemporary techniques require deep learning which is expensive for GPU computation and also need massive data for the training. Our technique needs fewer images with handcrafted image features and traditional lightweight ML techniques. The deep learning model proposed in Xu et al. (2017) uses CNN which needs a larger training dataset to extract complex features of exudates. The images are quite specific and complex for exudates detection for the CNN model and thus hand crafted features using the image processing techniques along with traditional machine learning algorithms for a good combination for classification. Another state-ofthe-art model ConvNet proposed in Quellec et al. (2017) was proposed which was trained on 90,000 public images. The deep learning models require GPU computation power and are also time consuming to extract efficient features from medical images. If the dataset is small which is often in case of medical imaging and transfer learning may be not possible due to diverse nature of trained and underlying medical data, it is good to use handcrafted image features (with the advice of medical expert) along with traditional ML model. The proposed technique is simple and effective for diabetic retinopathy to grade the severity (mild, moderate or severe) and the research is carried out in two segments (a) one for exudates based upon their distance from macula and (b) another for micro aneurysms is done by calculating their count. Original data has also been collected and experimented for the analysis and the choice of relevant and simple techniques for feature extraction and ML makes it efficient. Most contemporary techniques require deep learning which is expensive for GPU computation and also need massive data for the training. Our technique needs fewer images with handcrafted image features and traditional lightweight ML techniques.

Preliminaries
Diabetion Retinopathy, also goes by the name of diabetic eye disease caused to the people with high blood sugar level that badly affects the retina's blood vessels by swelling and leaking.

Machine learning in diabetic retinopathy
Machine learning is a technique for recognizing patterns that can be applied to medical images. Machine learning typically begins with the algorithm system computing the image features that are believed to be of importance in making the prediction or diagnosis of interest. The machine learning algorithm system then identifies the best combination of these image features for classifying the image or computing some metric for the given image region. Computer-aided detection and diagnosis performed by using machine learning algorithms can help ophthalmologists interpret medical imaging findings and reduce interpretation times. These algorithms have been used for several challenging tasks. If a machine learning algorithm is applied to a set of data (in our case, fundus images for detection and grading of diabetic retinopathy) and to some knowledge about these data (in our case, exudates, micro aneurysms extracted using image processing methods and textural features using Gray Level Cooccurrence Matrix (GLCM)), then the algorithm system can learn from the training data and apply what it has learned to make a prediction (in our case, grading the severity of diabetic retinopathy). If the algorithm system optimizes its parameters such that its performance improve that is, more test cases are diagnosed correct then it is considered to be learning that task very well. The Fig. 2 summarizes the role of machine learning algorithms in grading of diabetic retinopathy in terms of the severity of the problem in the diabetic patients. The machine learning techniques used in the case study have been explained briefly as follows: 1. Decision trees (DT) Song and Ying (2015) is a supervised machine learning learning algorithm for regression and classification and non-parametric in nature. It calculates the target value through simple piecewise decision rules applied on the features of the data. As an example if a cosine curve has to be approximated using if-else functions then more the rules, complex will be the decision tree system and finer will be the model. The advantages of DT is its simplicity, little data preprocessing, complexity is log(training size), handles categorical data, easy to interpret the test results being a white-box model, statistical validation is possible and resistant to violations of data distribution assumptions of the model.

Linear Discriminant (Izenman 2013) uses Bayes'
rule to draw linear classification boundary around the Gaussian data densities by assuming that all classes have identical covariance matrix. Linear Discriminant Analysis is also used for dimension reduction. It projects the data towards the direction which is most discriminating through data transformation. The simplicity of use, multi-classification ability and no parameter tuning requirement makes it popular in machine learning. 3. Support Vector Machine (SVM) (Noble 2006) is another popular algorithm for regression, classification and outlier detection. It is efficient for high-dimensional, complex data, yields support vectors to help selective data retention to save memory, tuning parameters to deal with various decision functions and ignore outliers through regularization. 4. K-nearest neighbours (Zhang et al. 2017) based classification uses instances of training data to compare the majority vote of nearest neighbours for each point. K stands for number of closest neighbors for each query point specified by the user. Knn is easy to implement, highly data dependent, larger K means ignoring the noise and vague boundary. Sometimes the data is not sampled uniformly and a little sparse so a variant technique known as Radius Neighbours classifier is used. 5. Boosted Tree ensemble (Deng 2019) is about the sequential learning of each classifier which are weak individually but combine with each other to make an efficient estimate for the final decision. Random forests is also a type of ensemble learning of various decision tree classifiers. Gradient tree boosting and adaptive boosting are quite popular for classification and regression. Gradient tree boosting develops on errors of the prior weak learn-ers and tends to minimise the loss (wrong predictions) while adding new trees sequentially. It uses voting crieteria of individual weak classifiers and subsequently adding weights to the wrong predictions so that the iterative learning can be modified. 6. Subspace discriminant ensemble (Bouveyron et al. 2005) calculates the decision boundary in the lower dimensional subspace. Various sub-spacing, re-sampling and re-weighting methods are used and affect the ensemble performance for learning. If a random subspace method is used then it is called RSM which is not quite efficient due to randomness involved. Thus majority voting is used where an individual classifier uses a subset of feature space and uses it ability to identify new instances. This is followed by voting the predictions to find out final classification. 7. Subspace Knn ensemble (Zhang et al. 2019) works on the voting of individual KNN classifiers which are applied to a subset of feature space. 8. RUSBoosted (Seiffert et al. 2009) trees is a hybrid approach to deal with imbalanced data issues. Data imbalance might lead to sub-optimal classifiers when one class outnumbers other classes with a considerable margin. RUSBoost is a combination of RUS (random undersampling) and AdaBoost with intelligent sampling. RUSBoost also deletes the class examples of majority group randomly and thus have light computation complexity. Moreover it results in shorter training times due to deletion of the dominant class instances.

Proposed method
An automated system for grading in diabetic retinopathy is proposed to understand and learn about the severity levels of the disease and the degree of threat of vision loss. A combined dataset of fundus images of Messidor, DiaretDb and E-optha has been used for the purpose. Initially, to grade with respect to exudates, detection of optic disc and macula are done. The images are fed to image preprocessing mechanism and techniques for better detection of the lesions which are exudates and micro aneurysms in our case. Image processing helps in removal of unwanted entities and bring us closer to better results and detection of regions of interest. Also, to grade according the micro aneurysms, their count helps to grade the severity levels of the disease. The second step involves application of features extraction mechanism which is Gray Level Co-occurrence Matrix (GLCM) in our case, that extracts the textural features of the segmented binary images. After the grading information and features information gets stored in excel sheet, this information is an input to the machine learning algorithms. The proposed approach as shown in Fig. 3 works on two features of diabetic retinopathy i.e. exudates and micro aneurysms. Image dataset containing 1361 images is collected and resized. Images are processed separately with respect to the detection of interested lesions where steps are different for yellow and red lesions. The grading is done with respect to exudates and micro aneurysms and stored in excel sheet. The textural features are extracted using Gray level co-occurrence matrix and stored with grading information. The machine learning models are used for grading system.

Image pre-processing
Image processing helps in improvement of the quality of the image by removing the unnecessary details and noises in the images. The features extraction and grading tasks are done better and give more accurate results if important information is extracted from the images with appropriate processing techniques. The detection of macula is important for the grading purpose as nearer the exudates to the macula, higher is the severity of the disease. The macula has the darkest intensity at the center of retina and is about optic disc diameter away from the optic disc's center. With the help of vessel map least density of vessels is found out since macula is found where vessel density is almost zero, distance from the optic disc and local minima to extract the darkest region macula's center point is detected.

Image processing for exudates
1. Optic Disc Removal: Optic disc has similar intensity value as that of exudates due to which its detection and removal is a very vital step for extraction and detection of exudates. Optic disc's center points are detected by resizing the image, thresholding the image to get bright lesions while ignoring the smaller lesions and vessel map is created to extract bigger vessels since the vessels having highest density are found at the center of optic disc. With help of midline in the image and vessel map, the center of optic disc is detected. The optic disc is removed with the help of the known center. The optic disc is masked and hidden by merging it with background so that while detection of exudates, their inten-sities being similar, are not confused and detection of exudates is done better and error free. This ensures that our detection methods will extract out the exudates and not the optic disc. 2. Resizing the images: The fundus images are resized into a standard size of 512×512 pixels so that the images are of same dimension and the preprocessing steps can yield same effects on all the images as different sized images are prone to some errors and some of the results may not be satisfactory. By not standardizing the image size, the detection of exudates gets tough and inaccurate with the image processing steps that have been used for this work. 3. Green Channel Extraction: The fundus images are originally of RGB pattern and are converted into their respective green channels. Green channel is less saturated as compared to blue and show lesions and other objects distinctly and better as compared to red channel. Green channel is used as this color is sensitive to the human eyes and the proper illuminations and intensity variances are easily visible in green channel which helps us in detection of regions of interest easily. For a particular image I, green channel is extracted from RGB images, using the equation 4.1, where J is a green channel extracted image.
Green channel shows comparatively lesser noises than other channels. As shown in Fig. 4, light absorption is maximum by green channels which shows objects more clearly and with lesser noise as well. 4. Morphological Operations: These operations are set of handy tools that are useful for extraction of particular components of images that can be used for description and representation of certain shapes of particular regions, boundaries etc. They process the images on the basis of shapes. Structuring element is used in morphological operations that are applied on the input images to deliver output images with same size. Structuring element is used as a template which is an odd matrix of (1) J = I(, , 2)     zeros or ones, placed on all the pixels of the input image and then comparison is done with the pixels of image under inspection with the neighborhood of pixels of the structuring element. In some operations, the pixels of image fit with that of neighborhood and intersect or hit in other cases as shown in Fig. 5. • Erosion: A binary image f's erosion is carried out using a structuring element s (represented as f ⊖ s) that forms a new binary image g of same size that has 1's in postions (x,y) of element's origin where the element s fits f, i.e. g(x,y)=1 if s fits f else 0, repeating for all (x,y) coordinates. The Fig. 6 displays use of a 3x3 structuring element that shrinks the input image by removing away a layer of pixels from outer and inner boundaries of image. • Dilation: Dilation has an opposite effect to that of erosion. Dilation of input image f using structuring element s (represented f ⊕ s) gives a new binary image g that has 1's in all the positions (x,y) of element's origin at which s hits the f, i.e. g(x,y)=1 if s hits f else 0, repeating for all (x,y). The holes or gaps between different areas become smaller and the image expands as shown in Fig. 7. • Opening operation: This operation is erosion followed by dilation using the same structuring element. This helps us to remove the smaller entities in the image and retains the shape and structure of the bigger objects as shown in Fig. 8. • Closing operation: This operation is dilation followed by erosion with the same structuring element. It preserves the shape and size of the objects in the image and helps in filling the holes or gaps in between the regions as shown in Fig. 9. • Bottom Hat Filtering Operation: Bottom hat filter is applied on the green channel extracted images. A disc structuring element of radius 5 has been used in our case. This morphological filter first closes the image and then subtracts the closed image from the input original image. It helps in finding smaller darker objects in the images by highlighting the intensity troughs of the image as shown in Fig. 10. • Top Hat Filtering Operation: Top hat filter is applied on the green channel extracted images with disc structuring element of radius 8. This filter opens the input image and then subtracts the opened image from the input original image. It isolates and highlights the brighter smaller objects and also improves the contrast of non-uniformly illuminated image as shown in Fig. 11.

Detection of exudates:
The images obtained after the morphological bottom hat and top hat operations are used for extraction of the exudates. Subtraction of the bottom hat filtered images is taken with top hat filtered images that results in the extraction of exudates.

Image processing for micro aneurysms
1. Green Channel Extraction: Just like for exudates, for micro aneurysms too green channel of the original RGB images is extracted so as to bring out the differences among entities and lesions quite clear. 2. Contrast Enhancement: Contrast enhancement works out well for detection of micro aneurysms since the red lesions and other entities are segmented well from the background. Contrast limited adaptive histogram equalization (CLAHE) is used for improving the contrast of the images. A good contrast image becomes more suitable for further stages of processing of images. The averaging filter that helps in blurring effect as shown in Fig. 13 which helps to reduce the presence of unwanted objects and makes sure that they don't get involved in the next image processing steps like binarization. • Average Filter: Average or Mean filter helps in smoothing the images by reducing the variations of intensities between pixels with the help of sliding kernel/window. The average is obtained by replacing each pixel of the image with the average of the value of pixels in its window as shown in the Fig. 14. Here the central value 1 is replaced with value 5 using (5 + 3 + 6 + 2 + 1 + 9 + 8 + 4 + 7 = 45), 45/9 = 5. 4. Morphological Operation: Bottom hat filtering operation is used on the smoothened images with a disc structuring element of radius 25. This morphological filter first closes the image and then subtracts the closed image from the input original image. It helps in finding smaller darker objects in the images by highlighting the intensity troughs of the image. 5. Thresholding and noise removal: The images are subjected to binarization for proper segmentation into foreground and background objects that helps to detect the lesions quite effectively. An intensity threshold value is chosen and the images are binarized successfully following which they are filtered using median filter that helps to remove tiny objects of noises that may affect the performance of the system in detection of micro aneurysms. The Fig. 15 displays the concept of thresholding where the image intensities whose value is greater than a threshold value are partitioned from background as foreground objects. The Fig. 16 shows the before and after effect on the application of thresholding on the image. • Median Filtering: Filtering method helps in improving the accuracy of the proposed methodology as it makes sure different entities are not mistaken to be micro aneurysms. Edge preservation is also done by application of median filter. This filter removes small objects and noises with a sliding window where the central value of the window gets replaced with the median of pixel values in the window neighborhood. The Fig. 17 shows how median filter works with a 3 × 3 window by ordering the values 0, 2, 3, 3, 4, 6, 10, 15, 97 and replacing 97 with 4. 6. Extraction of blood vessels: The blood vessels have similar intensity to that of micro aneurysms, so their extraction and removal is a vital step so that while features extraction they are not confused with micro aneurysms. Area filtering method is used to extract the large connected blood vessels and remove them. bwareafilt is used in Matlab that extracts connected area of image as per the mentioned range. 7. Detection of micro aneurysms: After removal of blood vessels, focus is shifted on to detection of micro aneurysms which is done via opening operation that is a morphological operation which removes the unwanted objects and noises whose size is smaller than a particular radius. It effectively brings out numerous micro aneurysms.

Features extraction
Feature extraction plays a very important role in reduction of dimension of data and giving meaning to the data and extracting useful and non-redundant information from it. It proves to be quite effective and informs about certain patterns that can't be recognized directly. The set of features extracted mostly contain relevant information about the input data and helps in fulfillment of desired tasks using insights provided by the features. Gray Level Co Occurrence Matrix (GLCM) is used in our case which is a statistical mechanism that focuses over the textural properties of the images and represents them. It also goes by the name of Gray Level Spatial Dependence Matrix because the features are extracted by calculating the frequency of certain pairs of pixels that occur together in a particular fashion or specific spatial relationship in the images and draws the information out of them in terms of textural properties. The GLCM is created with the help of graycomatrix function available in Matlab and thus the characteristics are extracted out using graycocrops. The Fig. 18 displays the usage of graycomatrix. In the Fig. 18, it is shown how the first three values of the GLCM matrix have been computed. The spatial relationship between two pixels say a and b has been taken as how frequently these two pixels are present horizontally adjacent to each other in the input image matrix. The gray levels taken in this example are 8 which is why the size of GLCM is 8x8. Gray levels denote the level of variations in intensities. The first entry of GLCM matrix for pixels (1,1) is 1 since the occurrences of these two-pixel values adjacent to each other is just once in the input image matrix. Similarly, the second entry in the GLCM matrix representing the pixels (1,2) has value 2 as that's how frequently these pixel values occur as per mentioned spatial relationship. The pixel values (1,3) do not occur adjacent to each other in the image, hence their GLCM value is 0. The properties extracted by GLCM are contrast, correlation, energy and homogeneity. These are second order statistics that give handful information about grey level positions that are present within the image.
• Contrast: Contrast measures the values of intensity of a particular pixel with respect to its neighbor pixel. All the local variations happening in the gray level co-occurrence matrix are captured as contrast.
• Correlation: Correlation measures the correlation between a particular pixel and its neighbor pixel. It computes for particular pair of pixels, their joint probability of occurrence.
• Energy: Energy measures the degree of similarity in image. It measures uniformity. It computes the GLCM elements' squared values' sum.
• Homogeneity: Homogeneity describes the closeness of pixels in an image. It shows how closely the different elements of GLCM are distributed and arranged with respect to the diagonal of GLCM.
where m = no of rows in matrix, n = no of columns in matrix, R mn = Element m, n of normalized symmetric geometry, P = Gray levels used for the image, = mean of values of GLCM.

Application of machine learning algorithms
Machine learning is a subfield of artificial intelligence that results in a system that intelligently learns from the environment and improves its performance from experience. It revolves around such computations and developing certain algorithms that use data and learns certain patterns from them. Various algorithms are applied on the information collected after image processing and feature extraction stages that are collected in an excel table. The algorithms are applied for both the exudates and micro aneurysms and grading information is fed to the algorithms and different performance parameters are computed as well.

Grading mechanism
To know the severity of diabetic retinopathy in the fundus images, grading has been done accordingly. The major four grades that have been used to know the degree of damage caused to the retina due to diabetic retinopathy are listed in Table 2.

Grading via exudates
The grading via exudates is done depending on the distance and position of exudates with respect to the macula which is the central portion of retina that gives the best color vision. Nearer the exudates, more is the risk of loss of vision as shown in Fig. 19. The exudates in smaller circular region are closest to macula and show severe level of disease and a drastic threat to vision loss. The exudates present in the second biggest circle show moderate signs of disease and can gradually lead to severity if not treated. The biggest circle show the mild case of diabetic retinopathy.

Grading via micro aneurysms
The grading via micro aneurysms is done using the count of these lesions. More the number of micro aneurysms, greater the threat of vision loss as shown in Table 3.

Performance metrics
The various performance metrics that have been used for comparison among the machine learning algorithms have been explained below.

Confusion matrix
The correctness and how accurate a model behave is calculated through confusion matrix which is also termed as error matrix. This helps us in getting a clear view of what correct and incorrect behavior in predictions is being carried out by our model. In our case multi class confusion matrix is created where we have four classes. Class 0 means no DR, class 1 means mild DR, class 2 means moderate DR and class 3 means severe DR. The confusion matrix for the same has been shown in Table 4. The terms associated with the confusion matrix are: • E ij : This entry depicts that predicted class by the model is j but the actual class is i. • True Positive (TP): This is the case when the predicted and actual classes are same. For example, in table, TP 0 , TP 1 , TP 2 , TP 3 is when the model predicted the class as 0, 1, 2, 3 and it in actual is class 0, 1, 2, 3 respectively. • True Negative (TN): This is the case when the model predicted that a particular instance did not belong to a class which in actual is true. For example in

Accuracy
Accuracy refers to the total number of correct predictions and classifications done by the model out of the total number of predictions as shown in Table 5.

Sensitivity
Sensitivity refers to true positive rate of the class under observation in case of multi class confusion matrix. It shows what proportion of values that actually belonged to a particular class are also predicted to belong in that class as shown in Table 6. The overall sensitivity is the average of values of sensitivity of all the classes.

Specificity
Specificity is referred to as the true negative rate of the class under consideration. It depicts what proportion of values that actually did not belong to a particular class, were predicted to not belong to that particular class as shown in Table 7. The overall specificity is the average of values of specificity of all the classes.

ROC curve
Receiver Operating curve (ROC) is a graphical represenation of how well a model is performing interms of its accuracy in predictions. It is a plot between sensitivity and specificity. The closer the ROC curve is towards the upper left corner the better and higher is the accuracy of the model as shown in Fig. 20.
As discussed in above sections, the methodology carried out in the thesis focuses on the severity levels of diabetic retinopathy in the fundus images with the help of image processing methods like green channel extraction, removal of noises and extraction of exudates and micro aneurysms, GLCM textural features like energy, correlation, homogeneity and contrast, machine learning algorithms like support vector machine, k nearest neighbor, decision tree etc. that train and test on the information received and stored in excel sheet. A comparison is drawn out on how well the machine learning algorithm grades the severity level of diabetic retinopathy algorithms in terms of accuracy, sensitivity, specificity and ROC curve.

Result analysis
In our research work, MATLAB 2018a has been used for carrying out the image processing, features extraction and application of various machine learning models on the system having processor Intel Core i5-4210U CPU @1.70 GHz 2.40 GHz with 8 GB RAM and 64-bit operating system. The combined dataset of publicly available datasets Messidor, E-optha and DiaretDb have been used with a total of 1361 colored fundus images.
• Messidor: This dataset has 1200 colored fundus images that have been occupied by three departments of ophthalmology with a colored 3CCD camera having a view field of 45 • . Pupil were dilated using Tropicamide and 800 fundus images were taken whereas 400 fundus images are without dilation. 1200 images have been separately stored in 3 sets with one set belonging to each ophthalmology department. • E-optha: This dataset contains 82 colored fundus images with purpose of providing research in the field of diabetic retinopathy, 47 images are found with presence of lesions whereas 35 images have no lesions. A tele-medical network named OPHDIAT © generated these fundus images. • DiaretDb: This dataset includes 89 colored fundus images out of which 84 images show traces of at least mild severity level of diabetic retinopathy and 5 fundus images are normal retinal images with no sign of diabetic retinopathy. 50 o view field was utilized for capturing the fundus images. These images correspond to good usage in practical environment where images being comparable are used to compute and compare performances of the methods used for diabetic retinopathy detection and grading.
The Fig. 21 shows a snapshot of some of the images having varying illuminations and colors that have been used for our work. A combined dataset of Messidor, e-optha and DiaretDb have been used so that bigger dataset is used in comparison to other works already done in the field of diabetic retinopathy. Also, this helps in better training and testing of the machine learning algorithms.

Grading via exudates
As discussed earlier, grading of diabetic retinopathy according to exudates is done by computing its location and position from macula.

Detection of Optic disc and macula
The detection of optic disc and macula are very important as they play a vital role in detection of exudates and their 1 3 grading. The detected centre points and masked optic disc have been shown in Fig. 22, respectively. Figure 23 shows the green channel extracted from the original colored image and application of bottom hat filtering that brings out the small dark objects of the image, respectively. Figure 24 show the result of top hat filtering on the green channel extracted image which brings out the brighter objects and extracted exudates after subtraction operation, respectively. Figure 25 outlines the presence of exudates and shows their distance from macula for grading purpose, respectively.

Features extraction in exudates
The textural features like contrast, correlation, energy and homogeneity have been extracted using Gray level co-occurrence matrix shown in Table 8. The grades have been shown along with features.

Comparison of various machine learning algorithms applied for grading via exudates
Various machine learning models and their performances have been compared in the Table 9. Support Vector Machine (Linear) and K Nearest Neighbor (Medium) show highest accuracy of 92.1%. Figure 31 shows the ground truth and the detected results using the proposed technique.

Comparison of various machine learning algorithms' confusion matrix for grading via exudates
Confusion matrix of all the models that have been applied are shown in Fig. 26.

Image pre processing
Green channel is extracted from the original colored images and the contrast is enhanced as shown in Fig. 27. Green channel is less saturated as compared to blue and show lesions and other objects distinctly and better as compared to red channel. Contrast enhancement works out well for detection of micro aneurysms since the red lesions and other entities are segmented well from the background. The images are then smoothened and bottom hat filtered as shown in Fig. 28. Smoothening operation is carried out using averaging filter that helps in blurring effect that helps to reduce the presence of unwanted objects.
Binarization of the images bring out the lesions well segmented from the background and blood vessels are extracted from images so that they are not confused with the micro aneurysms as shown in Fig. 29. The blood vessels are removed and the micro aneurysms are extracted with the help of morphological opening operation as shown in Fig. 30. The count of micro aneurysms helps in grading.

Features extraction of micro aneurysms
The textural features like contrast, correlation, energy and homogeneity have been extracted using Gray level cooccurrence matrix shown in Table 10. The count of micro aneurysms and grades have been shown along with features.

Comparison of various machine learning algorithms applied for grading via micro aneurysms
Various machine learning models and their performances have been compared in the Table 11. The decision tree and bagged trees ensemble outperform every other model with accuracy as high as 99.9%.

Comparison of various machine learning algorithms' confusion matrix for grading via micro aneurysms
Confusion matrix of all the models that have been applied are shown in Fig. 32.

Comparisons of the models used for grading via exudates v/s grading via micro aneurysms
A comparison is drawn out between grading via exudates v/s grading via micro aneurysms in terms of the accuracy of the similar machine learning algorithms that have been used in our research work. Figure 33a shows that decision tree gives more accuracy of 99.9% for grading via micro aneurysms as compared to grading via exudates. Figure 33b shows that linear discriminant gives more accuracy of 90.1% in grading via exudates as compared to grading via micro aneurysms. Figure 34 depicts that in grading via exudates SVM linear gives more accuracy of 92.1% and SVM cubic gives higher accuracy of 96.8% in grading via micro aneurysms. Figure 35 shows that all the variants of KNN show higher accuracy for grading via exudates except KNN weighted that shows accuracy of 63.6% in grading via micro aneurysms.  Figure 36 shows that the ensemble classifiers show higher accuracy for grading via micro aneurysms except for boosted trees that shows accuracy of 91.8% in grading via exudates.
Hence, variety of machine learning algorithms have been used in the research work for both exudates and micro aneurysms. The fundus images are processed with different image processing techniques along with textural features extraction and finally trained and tested using machine learning algorithms whose comparisons have been detailed above. Decision tree performs well for grading via micro aneurysms with an accuracy of 99.9% whereas support vector machine and k nearest neighbor predicts the severity levels with an accuracy of 92.1% which is higher than the other models. Thus, with the help of these machine learning algorithms the procedure of grading in diabetic retinopathy to know the severity levels can be automated helping the     2017) using CNN has been used to train and test the diabetic retinopathy. It yield the accuracy of 78.2%. The reason of lesser accuracy as compared to the traditional machine learning models is due to the smaller size of the dataset for training the deep learning model. Moreover the images are quite specific and complex for exudates detection for the CNN model and thus hand crafted features using the image processing techniques along with traditional machine learning algorithms for a good combination for classification. Another state-of-the-art model ConvNet proposed in Quellec et al. (2017) has been tested on our dataset which yield the accuracy of 83.7%. This model was pre-trained on 90,000 public images but because the complex nature of our images as compared to the trained images again lead to lesser value of accuracy. Thus for the underlying complex dataset of our retinal images, the detection of diabetic retinopathy is superior using custom features and traditional machine learning model.

Conclusion
Diabetic retinopathy has become one of the most leading and recurrent cases of blindness among children and adults. Inspection and detection of the features of diabetic retinopathy like exudates, micro aneurysms, hemorrhages and cotton wool spots is very challenging, time consuming and highly prone to errors especially if it needs to be done for a huge population and larger data sets. We have combined fundus images from Messidor, e-optha and DiaretDb datasets and grading is done to analyse the severity levels of diabetic retinopathy in two modules, once using exudates and then using micro aneurysms. Image processing has been used separately for the features of the diabetic retinopathy where textural features have been extracted that are given as input to the machine learning models. Various machine learning models like decision tree, SVM, KNN as well as ensemble classifiers have been used for training and testing the fundus images and predicting the grade of severity level of diabetic retinopathy. Decision tree performs well for grading via micro aneurysms with an accuracy of 99.9% whereas support vector machine and k nearest neighbor performs well for grading via exudates with an accuracy of 92.1%. In future, grading using the combination of both exudates and micro aneurysms will be performed. Other features such as cotton wool spots, hemorrhages will also be used for diabetic retinopathy detection. The size of the dataset will also be increased.

Conflict of interest
There is no conflict of interest.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http:// creat iveco mmons. org/ licen ses/ by/4. 0/.